From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 03/11] btrfs: tag as unlikely branches that call extent_io_tree_panic()
Date: Mon, 16 Mar 2026 16:14:06 +0000 [thread overview]
Message-ID: <5dcbfac4fdd15ca6693668ca01c93b5d1121705f.1773676775.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1773676775.git.fdmanana@suse.com>
From: Filipe Manana <fdmanana@suse.com>
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>
---
fs/btrfs/extent-io-tree.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 68e48b493950..93dca9199249 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -696,7 +696,7 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
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 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
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 @@ static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
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 @@ static int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
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 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}
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 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}
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;
--
2.47.2
next prev parent reply other threads:[~2026-03-16 16:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 16:14 [PATCH 00/11] btrfs: some optimizations and cleanups for io trees fdmanana
2026-03-16 16:14 ` [PATCH 01/11] btrfs: optimize clearing all bits from the last extent record in an io tree fdmanana
2026-03-16 16:14 ` [PATCH 02/11] btrfs: turn extent_io_tree_panic() into a macro for better error reporting fdmanana
2026-03-16 16:14 ` fdmanana [this message]
2026-03-16 16:14 ` [PATCH 04/11] btrfs: make add_extent_changeset() only return errors or success fdmanana
2026-03-16 16:14 ` [PATCH 05/11] btrfs: use extent_io_tree_panic() instead of BUG_ON() fdmanana
2026-03-16 16:14 ` [PATCH 06/11] btrfs: change last argument of add_extent_changeset() to boolean fdmanana
2026-03-16 16:14 ` [PATCH 07/11] btrfs: remove wake parameter from clear_state_bit() fdmanana
2026-03-16 16:14 ` [PATCH 08/11] btrfs: avoid unnecessary wake ups on io trees when there are no waiters fdmanana
2026-03-16 16:14 ` [PATCH 09/11] btrfs: free cached state outside critical section in wait_extent_bit() fdmanana
2026-03-16 16:14 ` [PATCH 10/11] btrfs: panic instead of warn when splitting extent state not in the tree fdmanana
2026-03-16 16:14 ` [PATCH 11/11] btrfs: optimize clearing all bits from first extent record in an io tree fdmanana
2026-03-18 11:02 ` [PATCH 00/11] btrfs: some optimizations and cleanups for io trees David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5dcbfac4fdd15ca6693668ca01c93b5d1121705f.1773676775.git.fdmanana@suse.com \
--to=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox