diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2013-07-25 19:22:33 +0800 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2013-09-01 08:04:32 -0400 |
commit | f2a09da9d0cba17ad4041e7e54f1ca840b12d0be (patch) | |
tree | 6b86b60c711d8d874cb321bad816f956edb90de2 /fs/btrfs/extent_io.c | |
parent | 09a7f7a28939fe281b6f2fef0fb1a733007d91fe (diff) |
Btrfs: add branch prediction hints in the read page end IO function
This patch add some branch prediction hints into the end IO function
of the read page, it reduced the percentage of the branch misses from
5.5% to 4.9%.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5d31f80c056..0297f6f4d4c 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2502,7 +2502,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) spin_lock(&tree->lock); state = find_first_extent_bit_state(tree, start, EXTENT_LOCKED); - if (state && state->start == start) { + if (likely(state && state->start == start)) { /* * take a reference on the state, unlock will drop * the ref @@ -2512,7 +2512,8 @@ static void end_bio_extent_readpage(struct bio *bio, int err) spin_unlock(&tree->lock); mirror = io_bio->mirror_num; - if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) { + if (likely(uptodate && tree->ops && + tree->ops->readpage_end_io_hook)) { ret = tree->ops->readpage_end_io_hook(page, start, end, state, mirror); if (ret) @@ -2521,12 +2522,15 @@ static void end_bio_extent_readpage(struct bio *bio, int err) clean_io_failure(start, page); } - if (!uptodate && tree->ops && tree->ops->readpage_io_failed_hook) { + if (likely(uptodate)) + goto readpage_ok; + + if (tree->ops && tree->ops->readpage_io_failed_hook) { ret = tree->ops->readpage_io_failed_hook(page, mirror); if (!ret && !err && test_bit(BIO_UPTODATE, &bio->bi_flags)) uptodate = 1; - } else if (!uptodate) { + } else { /* * The generic bio_readpage_error handles errors the * following way: If possible, new read requests are @@ -2547,7 +2551,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err) continue; } } - +readpage_ok: if (uptodate && tree->track_uptodate) { set_extent_uptodate(tree, start, end, &cached, GFP_ATOMIC); |