]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: tag as unlikely branches that call extent_io_tree_panic()
authorFilipe Manana <fdmanana@suse.com>
Wed, 11 Mar 2026 12:07:03 +0000 (12:07 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 Apr 2026 16:56:03 +0000 (18:56 +0200)
It's unexpected to ever call extent_io_tree_panic() so surround with
'unlikely' every if statement condition that leads to it, making it
explicit to a reader and to hint the compiler to potentially generate
better code.

On x86_64, using gcc 14.2.0-19 from Debian, this resulted in a slightly
decrease of the btrfs module's text size.

Before:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1999832  174320   15592 2189744  2169b0 fs/btrfs/btrfs.ko

After:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1999768  174320   15592 2189680  216970 fs/btrfs/btrfs.ko

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-io-tree.c

index 68e48b49395017658905dcdc7e2f83b088ee533c..93dca919924960d3269149fae0822ab8467f0c15 100644 (file)
@@ -696,7 +696,7 @@ hit_next:
                        goto search_again;
                ret = split_state(tree, state, prealloc, start);
                prealloc = NULL;
-               if (ret) {
+               if (unlikely(ret)) {
                        extent_io_tree_panic(tree, state, "split", ret);
                        goto out;
                }
@@ -762,7 +762,7 @@ hit_next:
                if (!prealloc)
                        goto search_again;
                ret = split_state(tree, state, prealloc, end + 1);
-               if (ret) {
+               if (unlikely(ret)) {
                        extent_io_tree_panic(tree, state, "split", ret);
                        prealloc = NULL;
                        goto out;
@@ -1203,7 +1203,7 @@ hit_next:
                if (!prealloc)
                        goto search_again;
                ret = split_state(tree, state, prealloc, start);
-               if (ret)
+               if (unlikely(ret))
                        extent_io_tree_panic(tree, state, "split", ret);
 
                prealloc = NULL;
@@ -1293,7 +1293,7 @@ hit_next:
                if (!prealloc)
                        goto search_again;
                ret = split_state(tree, state, prealloc, end + 1);
-               if (ret) {
+               if (unlikely(ret)) {
                        extent_io_tree_panic(tree, state, "split", ret);
                        prealloc = NULL;
                        goto out;
@@ -1448,7 +1448,7 @@ hit_next:
                }
                ret = split_state(tree, state, prealloc, start);
                prealloc = NULL;
-               if (ret) {
+               if (unlikely(ret)) {
                        extent_io_tree_panic(tree, state, "split", ret);
                        goto out;
                }
@@ -1532,7 +1532,7 @@ hit_next:
                }
 
                ret = split_state(tree, state, prealloc, end + 1);
-               if (ret) {
+               if (unlikely(ret)) {
                        extent_io_tree_panic(tree, state, "split", ret);
                        prealloc = NULL;
                        goto out;