From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Petr Mladek <pmladek@suse.com>
Cc: John Ogness <john.ogness@linutronix.de>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Joe Perches <joe@perches.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC] printk: More consistent loglevel for continuous lines
Date: Thu, 25 Nov 2021 09:53:49 +0900 [thread overview]
Message-ID: <YZ7enboRQprct49o@google.com> (raw)
In-Reply-To: <20211124154838.5415-1-pmladek@suse.com>
On (21/11/24 16:48), Petr Mladek wrote:
>
> Anyway, it looks a bit non-practical to update all existing pr_cont()
> callers:
>
> $> git grep "pr_cont" | wc -l
> 2054
Another question is how many pr_cont()-s are getting compiled with
the "average" production kernel config. A number of pr_cont() is in
debugging code - lockdep, kasan, etc. - which is not compiled for prod.
[..]
> +static void printk_write_loglevel_ctx(int loglevel)
> +{
> + u8 *loglevel_var = printk_loglevel_ctx_var();
> +
> + if (!loglevel_var)
> + return;
> +
> + /*
> + * Remember only the really used loglevels that can be stored
> + * within 3 bytes in struct printk_info.
> + */
> + if (WARN_ON_ONCE(loglevel != LOG_LEVEL(loglevel)))
> + return;
> +
> + *loglevel_var = loglevel;
> +}
> +
> +static u8 printk_read_loglevel_ctx(void)
> +{
> + u8 *loglevel_var = printk_loglevel_ctx_var();
> +
> + if (!loglevel_var)
> + return LOGLEVEL_DEFAULT;
> +
> + return *loglevel_var;
> +}
> +
> /**
> * printk_parse_prefix - Parse level and control flags.
> *
> @@ -2066,6 +2122,21 @@ u16 printk_parse_prefix(const char *text, int *level,
> return prefix_len;
> }
>
> +static int printk_sanitize_loglevel(int loglevel, enum printk_info_flags flags)
> +{
> + /* For continuous lines, fallback to the previously used loglevel. */
> + if (flags & LOG_CONT && loglevel == LOGLEVEL_DEFAULT)
> + loglevel = printk_read_loglevel_ctx();
> +
> + if (loglevel == LOGLEVEL_DEFAULT)
> + loglevel = default_message_loglevel;
> +
> + /* Remember the really used loglevel for this context. */
> + printk_write_loglevel_ctx(loglevel);
> +
> + return loglevel;
> +}
Let's assume something like this
foo()
{
char *s;
pr_cont("Blah ");
s = arch_foo();
pr_cont("%s \n", s);
}
Suppose that arch_foo() errs and pr_warn()-s. Are we going to use WARN
level for trailing pr_cont()?
pr_cont("Blah ") -> printk_write_loglevel_ctx(default)
pr_warn() -> printk_write_loglevel_ctx(warn)
pr_cont("%s \n"") <- printk_read_loglevel_ctx(warn)
p.s. I'm still reading amazingly detailed commit messages from your console
registration patch set.
next prev parent reply other threads:[~2021-11-25 1:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 15:48 Petr Mladek
2021-11-25 0:53 ` Sergey Senozhatsky [this message]
2021-11-25 1:45 ` Joe Perches
2021-12-06 16:19 ` Petr Mladek
2021-12-06 17:34 ` Petr Mladek
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=YZ7enboRQprct49o@google.com \
--to=senozhatsky@chromium.org \
--cc=joe@perches.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=torvalds@linux-foundation.org \
/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®