mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ext4: Reduce object size of ext4_msg uses
@ 2026-07-25  1:23 Joe Perches
  2026-07-27 20:41 ` Andreas Dilger
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joe Perches @ 2026-07-25  1:23 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Andreas Dilger, Baokun Li, Jan Kara, Ojaswin Mujoo,
	Ritesh Harjani (IBM),
	Zhang Yi, linux-ext4, LKML

Reduce the object size of ext4 ~2KB (~.5%) by combining the KERN_<LEVEL>
and format uses of ext4_msg.

Separate them in __ext4_msg using printk_get_level and printk_skip_level
and emitting the appropriate level.

x86 object sizes before and after:

defconfig size before:
$ size -t fs/ext4/built-in.a | tail -1
 579013	 121634	    316	 700963	  ab223	(TOTALS)

defconfig size after:
$ size -t fs/ext4/built-in.a | tail -1
 577196	 121650	    316	 699162	  aab1a	(TOTALS)

defconfig size before with CONFIG_EXPERT=y and CONFIG_PRINTK=n:
$ size -t fs/ext4/built-in.a | tail -1
 537999	 121432	    316	 659747	  a1123	(TOTALS)

defconfig size after with CONFIG_EXPERT=y and CONFIG_PRINTK=n:
$ size -t fs/ext4/built-in.a | tail -1
 536837	 121424	    316	 658577	  a0c91	(TOTALS)

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/ext4/ext4.h  | 12 ++++++------
 fs/ext4/super.c | 14 +++++++++-----
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index b37c136ea3ab..981918f32067 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3309,8 +3309,8 @@ void __ext4_warning(struct super_block *, const char *, unsigned int,
 extern __printf(4, 5)
 void __ext4_warning_inode(const struct inode *inode, const char *function,
 			  unsigned int line, const char *fmt, ...);
-extern __printf(3, 4)
-void __ext4_msg(struct super_block *, const char *, const char *, ...);
+extern __printf(2, 3)
+void __ext4_msg(struct super_block *, const char *fmt, ...);
 extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp,
 			   const char *, unsigned int, const char *);
 extern __printf(7, 8)
@@ -3354,8 +3354,8 @@ void __ext4_grp_locked_error(const char *, unsigned int,
 	__ext4_warning(sb, __func__, __LINE__, fmt, ##__VA_ARGS__)
 #define ext4_warning_inode(inode, fmt, ...)				\
 	__ext4_warning_inode(inode, __func__, __LINE__, fmt, ##__VA_ARGS__)
-#define ext4_msg(sb, level, fmt, ...)				\
-	__ext4_msg(sb, level, fmt, ##__VA_ARGS__)
+#define ext4_msg(sb, level, fmt, ...)					\
+	__ext4_msg(sb, level fmt, ##__VA_ARGS__)
 #define dump_mmp_msg(sb, mmp, msg)					\
 	__dump_mmp_msg(sb, mmp, __func__, __LINE__, msg)
 #define ext4_grp_locked_error(sb, grp, ino, block, fmt, ...)		\
@@ -3401,8 +3401,8 @@ do {									\
 } while (0)
 #define ext4_msg(sb, level, fmt, ...)					\
 do {									\
-	no_printk(fmt, ##__VA_ARGS__);					\
-	__ext4_msg(sb, "", " ");					\
+	no_printk(level fmt, ##__VA_ARGS__);				\
+	__ext4_msg(sb, "" " ");						\
 } while (0)
 #define dump_mmp_msg(sb, mmp, msg)					\
 	__dump_mmp_msg(sb, mmp, "", 0, "")
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 245f67d10ded..72d6f6353a27 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -981,11 +981,11 @@ void __ext4_std_error(struct super_block *sb, const char *function,
 	ext4_handle_error(sb, false, -errno, 0, 0, function, line);
 }
 
-void __ext4_msg(struct super_block *sb,
-		const char *prefix, const char *fmt, ...)
+void __ext4_msg(struct super_block *sb, const char *fmt, ...)
 {
 	struct va_format vaf;
 	va_list args;
+	int level;
 
 	if (sb) {
 		atomic_inc(&EXT4_SB(sb)->s_msg_count);
@@ -995,12 +995,16 @@ void __ext4_msg(struct super_block *sb,
 	}
 
 	va_start(args, fmt);
-	vaf.fmt = fmt;
+
+	level = printk_get_level(fmt);
+	vaf.fmt = printk_skip_level(fmt);
 	vaf.va = &args;
 	if (sb)
-		printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
+		printk("%c%cEXT4-fs (%s): %pV\n",
+		       KERN_SOH_ASCII, level, sb->s_id, &vaf);
 	else
-		printk("%sEXT4-fs: %pV\n", prefix, &vaf);
+		printk("%c%cEXT4-fs: %pV\n",
+		       KERN_SOH_ASCII, level, &vaf);
 	va_end(args);
 }
 

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-25  1:23 [PATCH] ext4: Reduce object size of ext4_msg uses Joe Perches
2026-07-27 20:41 ` Andreas Dilger
2026-07-28 14:50 ` Jan Kara
2026-07-31 13:07 ` Ojaswin Mujoo

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

all inboxes | Powered by JetHome®