linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Safonov <dima@arista.com>
To: linux-kernel@vger.kernel.org
Cc: Dmitry Safonov <0x7f454c46@gmail.com>,
	Dmitry Safonov <dima@arista.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	John Ogness <john.ogness@linutronix.de>,
	Petr Mladek <pmladek@suse.com>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: [PATCH v2 2/2] printk: Add printk.console_verbose boot parameter
Date: Tue, 13 Jul 2021 02:15:11 +0100	[thread overview]
Message-ID: <20210713011511.215808-3-dima@arista.com> (raw)
In-Reply-To: <20210713011511.215808-1-dima@arista.com>

console_verbose() increases console loglevel to CONSOLE_LOGLEVEL_MOTORMOUTH,
which provides more information to debug a panic/oops.

Unfortunately, in Arista we maintain some DUTs (Device Under Test) that
are configured to have 9600 baud rate. While verbose console messages
have their value to post-analyze crashes, on such setup they:
- may prevent panic/oops messages being printed
- take too long to flush on console resulting in watchdog reboot

In all our setups we use kdump which saves dmesg buffer after panic,
so in reality those extra messages on console provide no additional value,
but rather add risk of not getting to __crash_kexec().

Provide printk.console_verbose boot parameter, which allows to switch off
printk being verbose on oops/panic/lockdep (making it boot parameter
instead of compile-option suggested-by Petr).

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 Documentation/admin-guide/kernel-parameters.txt | 9 +++++++++
 include/linux/printk.h                          | 4 +++-
 kernel/printk/printk.c                          | 6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index bdb22006f713..9fae19b1edd8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4167,6 +4167,15 @@
 			Format: <bool>  (1/Y/y=enable, 0/N/n=disable)
 			default: disabled
 
+	printk.console_verbose=
+			Raise console loglevel to highest on oops, panic or
+			lockdep-detected issues (only if lock debug is on).
+			With an exception to setups with low baudrate on
+			serial console, keeping this enabled is a good choice
+			in order to provide more debug information.
+			Format: <bool>  (1/Y/y=enable, 0/N/n=disable)
+			default: enabled
+
 	printk.devkmsg={on,off,ratelimit}
 			Control writing to /dev/kmsg.
 			on - unlimited logging to /dev/kmsg from userspace
diff --git a/include/linux/printk.h b/include/linux/printk.h
index a63f468a8239..9d0b8133a03c 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -70,9 +70,11 @@ extern int console_printk[];
 #define minimum_console_loglevel (console_printk[2])
 #define default_console_loglevel (console_printk[3])
 
+extern bool printk_console_verbose;
+
 static inline void console_verbose(void)
 {
-	if (console_loglevel)
+	if (console_loglevel && printk_console_verbose)
 		console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
 }
 
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 142a58d124d9..e321ee78855d 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2404,6 +2404,12 @@ module_param_named(console_suspend, console_suspend_enabled,
 MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
 	" and hibernate operations");
 
+bool printk_console_verbose = true;
+EXPORT_SYMBOL(printk_console_verbose);
+
+module_param_named(console_verbose, printk_console_verbose, bool, 0644);
+MODULE_PARM_DESC(console_verbose, "Raise console loglevel to highest on oops/panic/etc");
+
 /**
  * suspend_console - suspend the console subsystem
  *
-- 
2.32.0


  parent reply	other threads:[~2021-07-13  1:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  1:15 [PATCH v2 0/2] printk: Add printk.console_verbose boot param Dmitry Safonov
2021-07-13  1:15 ` [PATCH v2 1/2] printk: Remove console_silent() Dmitry Safonov
2021-07-21 14:15   ` Petr Mladek
2021-07-13  1:15 ` Dmitry Safonov [this message]
2021-07-21 14:46   ` [PATCH v2 2/2] printk: Add printk.console_verbose boot parameter Petr Mladek
2021-07-26 13:37     ` Dmitry Safonov
2021-07-30 11:00   ` Petr Mladek
2021-07-30 11:01 ` [PATCH v2 0/2] printk: Add printk.console_verbose boot param 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=20210713011511.215808-3-dima@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 \
    --subject='Re: [PATCH v2 2/2] printk: Add printk.console_verbose boot parameter' \
    /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

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).