Commit ee39b432b4ac083acdafd7b4f156283722e3bf14

Authored by David Sterba
1 parent 5d99a998f3

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 <dsterba@suse.cz>

Showing 5 changed files with 10 additions and 10 deletions Side-by-side Diff

fs/btrfs/extent-tree.c
... ... @@ -9694,7 +9694,7 @@
9694 9694  
9695 9695 int btrfs_start_nocow_write(struct btrfs_root *root)
9696 9696 {
9697   - if (unlikely(atomic_read(&root->will_be_snapshoted)))
  9697 + if (atomic_read(&root->will_be_snapshoted))
9698 9698 return 0;
9699 9699  
9700 9700 percpu_counter_inc(&root->subv_writers->counter);
... ... @@ -9702,7 +9702,7 @@
9702 9702 * Make sure counter is updated before we check for snapshot creation.
9703 9703 */
9704 9704 smp_mb();
9705   - if (unlikely(atomic_read(&root->will_be_snapshoted))) {
  9705 + if (atomic_read(&root->will_be_snapshoted)) {
9706 9706 btrfs_end_nocow_write(root);
9707 9707 return 0;
9708 9708 }
... ... @@ -452,7 +452,7 @@
452 452 if (unlikely(copied == 0))
453 453 break;
454 454  
455   - if (unlikely(copied < PAGE_CACHE_SIZE - offset)) {
  455 + if (copied < PAGE_CACHE_SIZE - offset) {
456 456 offset += copied;
457 457 } else {
458 458 pg++;
... ... @@ -1792,7 +1792,7 @@
1792 1792 if (sync)
1793 1793 atomic_inc(&BTRFS_I(inode)->sync_writers);
1794 1794  
1795   - if (unlikely(file->f_flags & O_DIRECT)) {
  1795 + if (file->f_flags & O_DIRECT) {
1796 1796 num_written = __btrfs_direct_write(iocb, from, pos);
1797 1797 } else {
1798 1798 num_written = __btrfs_buffered_write(file, from, pos);
... ... @@ -7802,9 +7802,9 @@
7802 7802 atomic_inc(&dip->pending_bios);
7803 7803  
7804 7804 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 ||
7806 7806 bio_add_page(bio, bvec->bv_page, bvec->bv_len,
7807   - bvec->bv_offset) < bvec->bv_len)) {
  7807 + bvec->bv_offset) < bvec->bv_len) {
7808 7808 /*
7809 7809 * inc the count before we submit the bio so
7810 7810 * we know the end IO handler won't happen before
... ... @@ -8017,8 +8017,8 @@
8017 8017 ret = btrfs_delalloc_reserve_space(inode, count);
8018 8018 if (ret)
8019 8019 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)) {
8022 8022 inode_dio_done(inode);
8023 8023 flags = DIO_LOCKING | DIO_SKIP_HOLES;
8024 8024 wakeup = false;
... ... @@ -3167,7 +3167,7 @@
3167 3167 em->start + em->len - 1, 0);
3168 3168 }
3169 3169  
3170   - if (unlikely(ret))
  3170 + if (ret)
3171 3171 set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
3172 3172 &BTRFS_I(inode)->runtime_flags);
3173 3173 }
fs/btrfs/transaction.c
... ... @@ -418,7 +418,7 @@
418 418 /*
419 419 * Do the reservation for the relocation root creation
420 420 */
421   - if (unlikely(need_reserve_reloc_root(root))) {
  421 + if (need_reserve_reloc_root(root)) {
422 422 num_bytes += root->nodesize;
423 423 reloc_reserved = true;
424 424 }