mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] printk: Avoid livelock with heavy printk during panic
Date: Tue, 25 Jan 2022 15:25:49 +0100	[thread overview]
Message-ID: <YfAIbRqfFMwqsrKV@alley> (raw)
In-Reply-To: <20220121190222.572694-4-stephen.s.brennan@oracle.com>

On Fri 2022-01-21 11:02:21, Stephen Brennan wrote:
> During a panic(), if another CPU is writing heavily the kernel log (e.g.
> via /dev/kmsg), then the panic CPU may livelock writing out its messages
> to the console. Note when too many messages are dropped during panic and
> suppress further printk, except from the panic CPU.

I would add something like:

"It might cause that some useful messages are lost. But messages are
being lost anyway and this at least avoids the possible livelock."

> ---
>  kernel/printk/printk.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 20b4b71a1a07..ca253ac07615 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2667,6 +2678,8 @@ void console_unlock(void)
>  		if (console_seq != r.info->seq) {
>  			console_dropped += r.info->seq - console_seq;
>  			console_seq = r.info->seq;
> +			if (panic_in_progress() && panic_console_dropped++ > 10)
> +				suppress_panic_printk = 1;

It would be great to let the user know, something like:

				pr_warn("Too many dropped messages. Supress messages on non-panic CPUs to prevent livelock.\n");



>  		}
>  
>  		if (suppress_message_printing(r.info->level)) {

Otherwise, it looks good to me.

Best Regards,
Petr

  reply	other threads:[~2022-01-25 14:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21 19:02 [PATCH 0/4] printk: reduce deadlocks " Stephen Brennan
2022-01-21 19:02 ` [PATCH 1/4] panic: Add panic_in_progress helper Stephen Brennan
2022-01-25 11:48   ` Petr Mladek
2022-01-26 17:37     ` Stephen Brennan
2022-01-21 19:02 ` [PATCH 2/4] printk: disable optimistic spin during panic Stephen Brennan
2022-01-25 12:42   ` Petr Mladek
2022-01-26  9:18   ` Sergey Senozhatsky
2022-01-26  9:45     ` John Ogness
2022-01-26 10:06       ` Sergey Senozhatsky
2022-01-26 18:15         ` Stephen Brennan
2022-01-27  7:11           ` Sergey Senozhatsky
2022-01-27  9:09             ` John Ogness
2022-01-27 11:38             ` Petr Mladek
2022-01-27 12:43               ` John Ogness
2022-01-27 14:25                 ` Petr Mladek
2022-01-21 19:02 ` [PATCH 3/4] printk: Avoid livelock with heavy printk " Stephen Brennan
2022-01-25 14:25   ` Petr Mladek [this message]
2022-01-21 19:02 ` [PATCH 4/4] printk: Drop console_sem " Stephen Brennan
2022-01-24 16:12   ` John Ogness
2022-01-24 16:26     ` John Ogness
2022-01-25 15:04     ` 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=YfAIbRqfFMwqsrKV@alley \
    --to=pmladek@suse.com \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=sergey.senozhatsky@gmail.com \
    --cc=stephen.s.brennan@oracle.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®