From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH] btrfs: sink RCU protection to _btrfs_printk()
Date: Thu, 5 Feb 2026 12:45:46 +0100 [thread overview]
Message-ID: <20260205114546.210418-1-dsterba@suse.com> (raw)
Since commit 0e26727a731adf ("btrfs: switch all message helpers to be
RCU safe") the RCU protection is applied to all printk helpers,
explicitly in the wrapping macros. This inlines the code around each
message call but this is in no way a hot path so the RCU protection can
be sunk further to _btrfs_printk().
This change saves about 10K of btrfs.ko size on x86_64 release config:
text data bss dec hex filename
1722927 148328 15560 1886815 1cca5f pre/btrfs.ko
1712221 148760 15560 1876541 1ca23d post/btrfs.ko
DELTA: -10706
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/messages.c | 4 ++++
fs/btrfs/messages.h | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/messages.c b/fs/btrfs/messages.c
index 6190777924bff5..49774980bab6c9 100644
--- a/fs/btrfs/messages.c
+++ b/fs/btrfs/messages.c
@@ -219,6 +219,8 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, unsigned int level, cons
const char *type = logtypes[level];
struct ratelimit_state *ratelimit = &printk_limits[level];
+ rcu_read_lock();
+
#ifdef CONFIG_PRINTK_INDEX
printk_index_subsys_emit("%sBTRFS %s (device %s): ", NULL, fmt);
#endif
@@ -241,6 +243,8 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, unsigned int level, cons
}
va_end(args);
+
+ rcu_read_unlock();
}
#endif
diff --git a/fs/btrfs/messages.h b/fs/btrfs/messages.h
index 943e53980945ea..73a44f464664c5 100644
--- a/fs/btrfs/messages.h
+++ b/fs/btrfs/messages.h
@@ -85,9 +85,7 @@ void _btrfs_printk(const struct btrfs_fs_info *fs_info, unsigned int level, cons
#define btrfs_printk_in_rcu(fs_info, level, fmt, args...) \
do { \
- rcu_read_lock(); \
_btrfs_printk(fs_info, level, fmt, ##args); \
- rcu_read_unlock(); \
} while (0)
#define btrfs_printk_rl_in_rcu(fs_info, level, fmt, args...) \
@@ -96,10 +94,8 @@ do { \
DEFAULT_RATELIMIT_INTERVAL, \
DEFAULT_RATELIMIT_BURST); \
\
- rcu_read_lock(); \
if (__ratelimit(&_rs)) \
_btrfs_printk(fs_info, level, fmt, ##args); \
- rcu_read_unlock(); \
} while (0)
#endif
--
2.51.1
next reply other threads:[~2026-02-05 11:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 11:45 David Sterba [this message]
2026-02-09 9:39 ` [PATCH] btrfs: sink RCU protection to _btrfs_printk() Filipe Manana
2026-02-09 13:22 ` David Sterba
2026-02-13 2:08 ` kernel test robot
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=20260205114546.210418-1-dsterba@suse.com \
--to=dsterba@suse.com \
--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