From: Joe Perches <joe@perches.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel <linux-fsdevel@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [trivial PATCH] vfs: fs_context: Deduplicate logging calls to reduce object size
Date: Sun, 23 May 2021 10:43:53 -0700 [thread overview]
Message-ID: <f7c77f29b5c281076230eb902e5f3cb680be585e.camel@perches.com> (raw)
Deduplicate the logging calls by using a temporary for KERN_<LEVEL>
with miscellaneous source code neatening of the output calls.
$ size fs/fs_context.o* #defconfig x86_64
text data bss dec hex filename
6727 192 0 6919 1b07 fs/fs_context.o.new
6802 192 0 6994 1b52 fs/fs_context.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
fs/fs_context.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/fs/fs_context.c b/fs/fs_context.c
index 2834d1afa6e80..2a6ff20da40f5 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -359,33 +359,40 @@ EXPORT_SYMBOL(vfs_dup_fs_context);
* @fc: The filesystem context to log to.
* @fmt: The format of the buffer.
*/
-void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...)
+void logfc(struct fc_log *log, const char *prefix, char level,
+ const char *fmt, ...)
{
va_list va;
struct va_format vaf = {.fmt = fmt, .va = &va};
va_start(va, fmt);
if (!log) {
+ const char *kern_level;
+
switch (level) {
case 'w':
- printk(KERN_WARNING "%s%s%pV\n", prefix ? prefix : "",
- prefix ? ": " : "", &vaf);
+ kern_level = KERN_WARNING;
break;
case 'e':
- printk(KERN_ERR "%s%s%pV\n", prefix ? prefix : "",
- prefix ? ": " : "", &vaf);
+ kern_level = KERN_ERR;
break;
default:
- printk(KERN_NOTICE "%s%s%pV\n", prefix ? prefix : "",
- prefix ? ": " : "", &vaf);
+ kern_level = KERN_NOTICE;
break;
}
+ printk("%s%s%s%pV\n",
+ kern_level,
+ prefix ? prefix : "",
+ prefix ? ": " : "",
+ &vaf);
} else {
unsigned int logsize = ARRAY_SIZE(log->buffer);
u8 index;
- char *q = kasprintf(GFP_KERNEL, "%c %s%s%pV\n", level,
- prefix ? prefix : "",
- prefix ? ": " : "", &vaf);
+ char *q = kasprintf(GFP_KERNEL, "%c %s%s%pV\n",
+ level,
+ prefix ? prefix : "",
+ prefix ? ": " : "",
+ &vaf);
index = log->head & (logsize - 1);
BUILD_BUG_ON(sizeof(log->head) != sizeof(u8) ||
reply other threads:[~2021-05-23 17:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=f7c77f29b5c281076230eb902e5f3cb680be585e.camel@perches.com \
--to=joe@perches.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®