linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Calvin Owens <calvinowens@fb.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org
Subject: Re: [PATCH 1/4] printk: Introduce per-console loglevel setting
Date: Fri, 8 Mar 2019 16:09:14 +0100	[thread overview]
Message-ID: <20190308150914.ifqp36en3pyd4ljy@pathway.suse.cz> (raw)
In-Reply-To: <06cd267ef5439a9391368423b608959f5f1b1a63.1551486732.git.calvinowens@fb.com>

On Fri 2019-03-01 16:48:17, Calvin Owens wrote:
> Not all consoles are created equal: depending on the actual hardware,
> the latency of a printk() call can vary dramatically. The worst examples
> are serial consoles, where it can spin for tens of milliseconds banging
> the UART to emit a message, which can cause application-level problems
> when the kernel spews onto the console.
> 
> At Facebook we use netconsole to monitor our fleet, but we still have
> serial consoles attached on each host for live debugging, and the latter
> has caused problems. An obvious solution is to disable the kernel
> console output to ttyS0, but this makes live debugging frustrating,
> since crashes become silent and opaque to the ttyS0 user. Enabling it on
> the fly when needed isn't feasible, since boxes you need to debug via
> serial are likely to be borked in ways that make this impossible.

I guess that many other people have similar problem.


> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index d3d170374ceb..6ead14f8c2bc 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1164,9 +1164,14 @@ module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR);
>  MODULE_PARM_DESC(ignore_loglevel,
>  		 "ignore loglevel setting (prints all kernel messages to the console)");
>  
> -static bool suppress_message_printing(int level)
> +static int effective_loglevel(struct console *con)
>  {
> -	return (level >= console_loglevel && !ignore_loglevel);
> +	return max(console_loglevel, con ? con->level : LOGLEVEL_EMERG);
> +}
> +
> +static bool suppress_message_printing(int level, struct console *con)
> +{
> +	return (level >= effective_loglevel(con) && !ignore_loglevel);

Hmm, the semantic is cleaner when the per-console level defines
the minimal loglevel. But it is still complicated. Also it is
very confusing that the per-console value is called "level"
or "loglevel" but it is actually minimal loglevel.

It might be even more straightforward when the per-console value
defines the effective console level. I mean the following semantic:

   + "console_loglevel" would define the default loglevel used
     by consoles at runtime.

   + the per-console loglevel could override the default
     console_loglevel.

   + We would need a custom handler for the sysctl "console_loglevel".
     It would write the given value to the global console_loglevel
     variable and for all already registered consoles (con->loglevel).

     The value will be used also for all newly registered consoles
     when they do not have any custom one.


   + The handler for "loglevel" early param should behave the same
     as the sysctl handler.


IMHO, there is no perfect solution. The advantage of the above
proposal is that you "see" and "use" exactly what you "set".


>  }
>  
>  #ifdef CONFIG_BOOT_PRINTK_DELAY
> @@ -1198,7 +1203,7 @@ static void boot_delay_msec(int level)
>  	unsigned long timeout;
>  
>  	if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
> -		|| suppress_message_printing(level)) {
> +		|| suppress_message_printing(level, NULL)) {

We should delay the message only when it will really reach the
console. The same check might be used also for formatting
the text as pointed out by Sergey in the other mail.

If the above proposal was accepted, we would have custom
handlers for sysctl. Then we could easily maintain a global
variable with maximal effective console loglevel.

Best Regards,
Petr

  parent reply	other threads:[~2019-03-08 15:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02  0:48 [RFC][PATCH 0/4] Per-console loglevel support, console device bus Calvin Owens
2019-03-02  0:48 ` [PATCH 1/4] printk: Introduce per-console loglevel setting Calvin Owens
2019-03-08  3:10   ` Sergey Senozhatsky
2019-03-12 21:00     ` Calvin Owens
2019-03-08 15:09   ` Petr Mladek [this message]
2019-03-14 14:12     ` Tetsuo Handa
2019-03-20 15:37       ` Petr Mladek
2019-03-02  0:48 ` [PATCH 2/4] printk: Add ability to set loglevel via "console=" cmdline Calvin Owens
2019-03-08 15:44   ` Petr Mladek
2019-03-02  0:48 ` [PATCH 3/4] printk: Add consoles to a virtual "console" bus Calvin Owens
2019-03-08  2:56   ` John Ogness
2019-03-08 15:58     ` Petr Mladek
2019-03-08 16:34       ` Greg Kroah-Hartman
2019-03-12 20:44         ` Calvin Owens
2019-03-08 15:53   ` Petr Mladek
2019-03-12 20:52     ` Calvin Owens
2019-03-11 13:33   ` Petr Mladek
2019-03-12 21:52     ` Calvin Owens
2019-03-13 10:08       ` Petr Mladek
2019-03-02  0:48 ` [PATCH 4/4] printk: Add a device attribute for the per-console loglevel Calvin Owens
2019-03-04  8:06   ` Sergey Senozhatsky
2019-03-04 19:10     ` Calvin Owens
2019-03-08  3:11       ` Sergey Senozhatsky

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=20190308150914.ifqp36en3pyd4ljy@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=calvinowens@fb.com \
    --cc=corbet@lwn.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).