Skip to content

Commit ee39b43

Browse files
committed
btrfs: remove unlikely from data-dependent branches and slow paths
There are the branch hints that obviously depend on the data being processed, the CPU predictor will do better job according to the actual load. It also does not make sense to use the hints in slow paths that do a lot of other operations like locking, waiting or IO. Signed-off-by: David Sterba <[email protected]>
1 parent 5d99a99 commit ee39b43

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

fs/btrfs/extent-tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9694,15 +9694,15 @@ void btrfs_end_nocow_write(struct btrfs_root *root)
96949694

96959695
int btrfs_start_nocow_write(struct btrfs_root *root)
96969696
{
9697-
if (unlikely(atomic_read(&root->will_be_snapshoted)))
9697+
if (atomic_read(&root->will_be_snapshoted))
96989698
return 0;
96999699

97009700
percpu_counter_inc(&root->subv_writers->counter);
97019701
/*
97029702
* Make sure counter is updated before we check for snapshot creation.
97039703
*/
97049704
smp_mb();
9705-
if (unlikely(atomic_read(&root->will_be_snapshoted))) {
9705+
if (atomic_read(&root->will_be_snapshoted)) {
97069706
btrfs_end_nocow_write(root);
97079707
return 0;
97089708
}

fs/btrfs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static noinline int btrfs_copy_from_user(loff_t pos, int num_pages,
452452
if (unlikely(copied == 0))
453453
break;
454454

455-
if (unlikely(copied < PAGE_CACHE_SIZE - offset)) {
455+
if (copied < PAGE_CACHE_SIZE - offset) {
456456
offset += copied;
457457
} else {
458458
pg++;
@@ -1792,7 +1792,7 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb,
17921792
if (sync)
17931793
atomic_inc(&BTRFS_I(inode)->sync_writers);
17941794

1795-
if (unlikely(file->f_flags & O_DIRECT)) {
1795+
if (file->f_flags & O_DIRECT) {
17961796
num_written = __btrfs_direct_write(iocb, from, pos);
17971797
} else {
17981798
num_written = __btrfs_buffered_write(file, from, pos);

fs/btrfs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7802,9 +7802,9 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
78027802
atomic_inc(&dip->pending_bios);
78037803

78047804
while (bvec <= (orig_bio->bi_io_vec + orig_bio->bi_vcnt - 1)) {
7805-
if (unlikely(map_length < submit_len + bvec->bv_len ||
7805+
if (map_length < submit_len + bvec->bv_len ||
78067806
bio_add_page(bio, bvec->bv_page, bvec->bv_len,
7807-
bvec->bv_offset) < bvec->bv_len)) {
7807+
bvec->bv_offset) < bvec->bv_len) {
78087808
/*
78097809
* inc the count before we submit the bio so
78107810
* we know the end IO handler won't happen before
@@ -8017,8 +8017,8 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
80178017
ret = btrfs_delalloc_reserve_space(inode, count);
80188018
if (ret)
80198019
goto out;
8020-
} else if (unlikely(test_bit(BTRFS_INODE_READDIO_NEED_LOCK,
8021-
&BTRFS_I(inode)->runtime_flags))) {
8020+
} else if (test_bit(BTRFS_INODE_READDIO_NEED_LOCK,
8021+
&BTRFS_I(inode)->runtime_flags)) {
80228022
inode_dio_done(inode);
80238023
flags = DIO_LOCKING | DIO_SKIP_HOLES;
80248024
wakeup = false;

fs/btrfs/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,7 @@ static void clone_update_extent_map(struct inode *inode,
31673167
em->start + em->len - 1, 0);
31683168
}
31693169

3170-
if (unlikely(ret))
3170+
if (ret)
31713171
set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
31723172
&BTRFS_I(inode)->runtime_flags);
31733173
}

fs/btrfs/transaction.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ start_transaction(struct btrfs_root *root, u64 num_items, unsigned int type,
418418
/*
419419
* Do the reservation for the relocation root creation
420420
*/
421-
if (unlikely(need_reserve_reloc_root(root))) {
421+
if (need_reserve_reloc_root(root)) {
422422
num_bytes += root->nodesize;
423423
reloc_reserved = true;
424424
}

0 commit comments

Comments
 (0)