From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: Petr Mladek <pmladek@suse.com>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [RFC PATCH] printk: Make functions of pr_<level> macros
Date: Thu, 2 Mar 2017 14:35:09 +0900 [thread overview]
Message-ID: <20170302053509.GA398@jagdpanzerIV.localdomain> (raw)
In-Reply-To: <f75a04ab9b2abdb25278a71342377d8359166938.1488337468.git.joe@perches.com>
Hello Joe,
On (02/28/17 19:17), Joe Perches wrote:
> Can save the space that the KERN_<LEVEL> headers require.
>
> The biggest negative here is the %pV use which needs
> recursion and adds stack depth.
>
> $ size vmlinux.o* (defconfig, x86-64)
> text data bss dec hex filename
> 12586135 1909841 777528 15273504 e90e20 vmlinux.o.new
> 12590348 1909841 777528 15277717 e91e95 vmlinux.o.old
interesting. 4K.
[..]
> +#define define_pr_func(func, level) \
> +asmlinkage __visible int func(const char *fmt, ...) \
> +{ \
> + va_list args; \
> + int r; \
> + struct va_format vaf; \
> + \
> + va_start(args, fmt); \
> + vaf.fmt = fmt; \
> + vaf.va = &args; \
> + \
> + r = printk(level "%pV", &vaf); \
> + \
> + va_end(args); \
> + \
> + return r; \
> +} \
hm. that's really hacky (which is a compliment) and a bit complicated.
my quick thought was to tweak vprintk_emit() for 'facility != 0' so it
could get loglevel (and adjust lflags) from the passed level, not from
the text, and then do something like this
#define define_pr_func(func, level) asmlinkage __visible int func(const char *fmt, ...)
{
va_start(args, fmt);
r = vprintk_emit(level[0], level[1], NULL, 0, fmt, args);
va_end();
}
but this won't do the trick. because func()->vprintk_emit() shortcut
disables the printk-safe mechanism:
func()->printk()->vprintk_func()->this_cpu(printk_context)::print()
this *probably* and *may be* works for dev_printk() /* assuming that
dev_printk() is never called fomr under sched/sempahore/etc locks */,
but for printk() in general it's a huge no-no-no.
so I see that you did the very same thing in 99bcf217183e02ebae for
dev_printk(), which is, once again, probably ok for dev_print(). and
now the question is do we want to add %pV recursion to non-dev
printk-s, and I'm, frankly, don't have any answers at the moment.
sorry.
there are already %pV pr_foo() calls in the kernel. and we even have %pV in
OOM path. now those calls are going to be %pV->%pV = recursion depth 2.
for example I can easily do this thing:
[ 38.006766] WARNING: CPU: 2 PID: 368 at lib/vsprintf.c:1901 format_decode+0x226/0x2fd
[ 38.006766] Please remove unsupported %] in format string
[..]
[ 38.006783] Call Trace:
[ 38.006783] dump_stack+0x68/0x92
[ 38.006784] __warn+0xc2/0xdd
[ 38.006784] warn_slowpath_fmt+0x4b/0x53
[ 38.006785] ? __lock_acquire+0x2ac/0x1501
[ 38.006785] format_decode+0x226/0x2fd
[ 38.006786] vsnprintf+0x89/0x3b7
[ 38.006786] pointer+0x1c3/0x378
[ 38.006787] vsnprintf+0x22d/0x3b7
[ 38.006787] pointer+0x1c3/0x378
[ 38.006788] vsnprintf+0x22d/0x3b7
[ 38.006788] vscnprintf+0xd/0x26
[ 38.006788] vprintk_emit+0x81/0x294
[ 38.006789] ? 0xffffffffa0096000
[ 38.006789] vprintk_default+0x1d/0x1f
[ 38.006790] vprintk_func+0x6c/0x73
[ 38.006790] ? 0xffffffffa0096000
[ 38.006791] printk+0x43/0x4b
[ 38.006791] pr_cont+0x56/0x5e
I wonder if it can get any worse than that. I sort of suspect
it can. in trivial case, dump_stack() can add at least one more
level of recursion by using pr_{err, etc.} instead of corresponding
printk(KERN_{ERR, etc}.
can it be even worse? um... NMI?
any thoughts?
dunno, at the moment I'm not really comfortable with %pV recursion
for every pr_foo() call.
-ss
next prev parent reply other threads:[~2017-03-02 5:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-01 3:17 Joe Perches
2017-03-02 5:35 ` Sergey Senozhatsky [this message]
2017-03-02 5:58 ` Joe Perches
2017-04-27 15:11 ` Petr Mladek
2017-04-27 16:08 ` Joe Perches
2017-04-27 16:28 ` Steven Rostedt
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=20170302053509.GA398@jagdpanzerIV.localdomain \
--to=sergey.senozhatsky.work@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.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
all inboxes | Powered by JetHome®