Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Joe Perches <joe@perches.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
	Baokun Li <libaokun@linux.alibaba.com>, Jan Kara <jack@suse.cz>,
	Ojaswin Mujoo <ojaswin@linux.ibm.com>,
	"Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
	Zhang Yi <yi.zhang@huawei.com>,
	linux-ext4@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ext4: Reduce object size of ext4_msg uses
Date: Mon, 27 Jul 2026 14:41:29 -0600	[thread overview]
Message-ID: <FD404D5A-AF59-4960-8CEF-D150198DCDB9@dilger.ca> (raw)
In-Reply-To: <7fbad87ae7e108571cafffa8fa0715ce4d2c5261.camel@perches.com>

On Jul 24, 2026, at 19:23, Joe Perches <joe@perches.com> wrote:
> 
> 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>

Reviewed-by: Andreas Dilger <adilger@dilger.ca <mailto:adilger@dilger.ca>>

> ---
> 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);
> }
> 


Cheers, Andreas






  reply	other threads:[~2026-07-27 20:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-25  1:23 [PATCH] ext4: Reduce object size of ext4_msg uses Joe Perches
2026-07-27 20:41 ` Andreas Dilger [this message]
2026-07-28 14:50 ` Jan Kara
2026-07-31 13:07 ` Ojaswin Mujoo

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=FD404D5A-AF59-4960-8CEF-D150198DCDB9@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=jack@suse.cz \
    --cc=joe@perches.com \
    --cc=libaokun@linux.alibaba.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yi.zhang@huawei.com \
    /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