All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Safonov <dima@arista.com>
To: Petr Mladek <pmladek@suse.com>
Cc: linux-kernel@vger.kernel.org,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] printk: Add CONFIG_CONSOLE_LOGLEVEL_PANIC
Date: Fri, 25 Jun 2021 13:17:43 +0100	[thread overview]
Message-ID: <8e7dae6f-e67c-b961-4986-883e1db0c566@arista.com> (raw)
In-Reply-To: <YNWeIks8NC1i2w96@alley>

Hi Petr, thanks for looking into this,

On 6/25/21 10:13 AM, Petr Mladek wrote:
> On Tue 2021-06-22 15:33:50, Dmitry Safonov wrote:
[..]
>> @@ -76,8 +76,8 @@ static inline void console_silent(void)
>>  
>>  static inline void console_verbose(void)
>>  {
>> -	if (console_loglevel)
>> -		console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
>> +	if (console_loglevel && (CONFIG_CONSOLE_LOGLEVEL_PANIC > 0))
>> +		console_loglevel = CONFIG_CONSOLE_LOGLEVEL_PANIC;
> 
> console_verbose() is called also in some other situations.
> For example, check_hung_task(), oops_begin(), debug_locks_ff().
> These do not always lead to panic.>
> At minimum, the name is misleading. It should be something
> like CONFIG_CONSOLE_LOGLEVEL_VERBOSE.
>
> But the question is whether we really want to limit the loglevel
> also in the non-panic scenarios. IMHO, it is a bad idea.
>
> A better solution would be to introduce console_verbose_panic()
> and use it only when it is really going to panic. The function
> should also use the lower value only when crash dump is really
> successfully enabled.

Hmm, check_hung_task() calls it only if it's going to panic().
debug_locks_off() AFAICS is called only when there is something bad with
either lockdep itself or locks: they may get freed
[print_freed_lock_bug()] or lock is held on return to userspace
[lockdep_sys_exit()] and so on - when lockdep has to turn off. Arguably,
the situations are somewhat close to panic.
MCE calls it also just before panic.

So, the only left is oops_begin().
I'm not sure what to do about it.
What do you think, should console_verbose() be called only under
panic_on_oops? Or should there be console_unverbose() to return the
loglevel in oops_end()? [that seems quite a bit ugly, considering that
there're already places that temporary save loglevel and adding another
one is ugh]

Renaming console_verbose() to console_verbose_on_panic() or something
sounds good to me - I didn't do it only to keep the patch short.

>> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
>> index 678c13967580..0c12cafd9d8b 100644
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -61,6 +61,19 @@ config CONSOLE_LOGLEVEL_QUIET
>>  	  will be used as the loglevel. IOW passing "quiet" will be the
>>  	  equivalent of passing "loglevel=<CONSOLE_LOGLEVEL_QUIET>"
>>  
>> +config CONSOLE_LOGLEVEL_PANIC
>> +	int "panic console loglevel (1-15)"
> 
> The range is 1-15 here.
> 
>> +	range 0 15
> 
> But it is 0-15 here. If you use "range 1 15" you should not need the
> check (CONFIG_CONSOLE_LOGLEVEL_PANIC > 0) in the code.
> 
>> +	default "15"
>> +	help
>> +	  loglevel to use in kernel panic or oopses.
>> +
>> +	  Usually in order to provide more debug information on console upon
>> +	  panic, one wants to see everything being printed (loglevel = 15).
>> +	  With an exception to setups with low baudrate on serial console,
>> +	  keeping this value high is a good choice.
>> +	  0 value is to keep the loglevel during panic/oops unchanged.
> 
> The trick with 0 value just makes things more complicated. The default
> "15" does the same job and should be good enough. The hard-coded
> default is good enough for the other CONSOLE_LOGLEVEL_* settings.

Well, "0" is kinda reverse to "15" - it doesn't change loglevel at all.
Actually, the origin purpose of the patch is to have "0" :-)
I thought 0-15 would be better than just off or on to MOTORMOUTH.

Now, looking at it again, I think what may be even better:

: if (console_loglevel && (CONFIG_CONSOLE_LOGLEVEL_PANIC >
console_loglevel))
:       console_loglevel = CONFIG_CONSOLE_LOGLEVEL_PANIC;

that way I can get rid of "0".
What do you think?

Thanks,
          Dmitry

  reply	other threads:[~2021-06-25 12:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 14:33 [PATCH] printk: Add CONFIG_CONSOLE_LOGLEVEL_PANIC Dmitry Safonov
2021-06-25  9:13 ` Petr Mladek
2021-06-25 12:17   ` Dmitry Safonov [this message]
2021-06-28 12:43     ` Petr Mladek
2021-06-28 17:26       ` Dmitry Safonov

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=8e7dae6f-e67c-b961-4986-883e1db0c566@arista.com \
    --to=dima@arista.com \
    --cc=0x7f454c46@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.