[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZ7enboRQprct49o@google.com>
Date: Thu, 25 Nov 2021 09:53:49 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Petr Mladek <pmladek@...e.com>
Cc: John Ogness <john.ogness@...utronix.de>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Joe Perches <joe@...ches.com>, linux-kernel@...r.kernel.org
Subject: Re: [RFC] printk: More consistent loglevel for continuous lines
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.
Powered by blists - more mailing lists