public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: sink RCU protection to _btrfs_printk()
@ 2026-02-05 11:45 David Sterba
  2026-02-09  9:39 ` Filipe Manana
  2026-02-13  2:08 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: David Sterba @ 2026-02-05 11:45 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-02-13  2:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-05 11:45 [PATCH] btrfs: sink RCU protection to _btrfs_printk() David Sterba
2026-02-09  9:39 ` Filipe Manana
2026-02-09 13:22   ` David Sterba
2026-02-13  2:08 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox