Skip to contentSkip to conversation

printk: Add printk.no_console_auto_verbose boot param

PATCH In review Dmitry Safonov 2 participants 5 messages Jul 27, 2021 – Jul 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v3 cover printk: Add printk.no_console_auto_verbose boot param

v2 to v3 Changes:
- Renamed printk.console_verbose to printk.console_no_auto_verbose (as suggested by Petr)
- Moved console_verbose() to printk.c and exported it instead (Petr)
- Added Reviewed-by and also Suggested-by Petr

v1 to v2 Changes:
- Add printk.console_verbose boot parameter instead of compile-time CONFIG_CONSOLE_LOGLEVEL_PANIC (see v1 discussion with Petr)
- I didn't rename console_verbose() to console_verbose_panic() as I need it to be always disabled regardless oops/panic/lockdep.
- I noticed console_silent() which is unused for long time, remove it.

v1: https://lore.kernel.org/lkml/[email protected]/
v2: https://lore.kernel.org/lkml/[email protected]/

Cc Andrew Morton <[email protected]>
Cc John Ogness <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Steven Rostedt <[email protected]>

Dmitry Safonov (2):
printk: Remove console_silent()
printk: Add printk.console_no_auto_verbose boot parameter

 Documentation/admin-guide/kernel-parameters.txt |  9 +++++++++
 include/linux/printk.h                          | 11 +----------
 kernel/printk/printk.c                          | 12 ++++++++++++
 3 files changed, 22 insertions(+), 10 deletions(-)

base-commit: e73f0f0ee7541171d89f2e2491130c7771ba58d3

Signature · 1 line
2.32.0
#1 lore raw

PATCH v3 1/2 printk: Remove console_silent()

It' unused since removal of mn10300:
commit 739d875dd698 ("mn10300: Remove the architecture") x86 stopped using it in v2.6.12 (see history git):
commit 7574828b3dbb ("[PATCH] x86_64: add nmi button support")

Let's clean it up from the header.

---
 include/linux/printk.h | 5 -----
 1 file changed, 5 deletions(-)
include/linux/printk.h +0 -5
index e834d78f0478..a63f468a8239 100644
@@ -70,11 +70,6 @@ extern int console_printk[];
 #define minimum_console_loglevel (console_printk[2])
 #define default_console_loglevel (console_printk[3])
 
-static inline void console_silent(void)
-{
-	console_loglevel = CONSOLE_LOGLEVEL_SILENT;
-}
-
 static inline void console_verbose(void)
 {
 	if (console_loglevel)
Signature · 1 line
2.32.0
reviewer Reviewed-by on v3 1/2
#2 lore raw

Re: [PATCH v3 1/2] printk: Remove console_silent()

Quoted 6 lines · Dmitry Safonov

It' unused since removal of mn10300:
commit 739d875dd698 ("mn10300: Remove the architecture") x86 stopped using it in v2.6.12 (see history git):
commit 7574828b3dbb ("[PATCH] x86_64: add nmi button support")

Let's clean it up from the header.

Nice.

Quoted 2 lines
#3 lore raw

PATCH v3 2/2 printk: Add printk.console_no_auto_verbose boot parameter

In reply to Dmitry Safonov

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_no_auto_verbose boot parameter, which allows to switch off printk being verbose on oops/panic/lockdep.

Cc Andrew Morton <[email protected]>
Cc John Ogness <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 Documentation/admin-guide/kernel-parameters.txt |  9 +++++++++
 include/linux/printk.h                          |  6 +-----
 kernel/printk/printk.c                          | 12 ++++++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +9 -0
index bdb22006f713..a4dd5814a83a 100644
@@ -4167,6 +4167,15 @@
 			Format: <bool>  (1/Y/y=enable, 0/N/n=disable)
 			default: disabled
 
+	printk.console_no_auto_verbose=
+			Disable console loglevel raise 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 0 is a good choice
+			in order to provide more debug information.
+			Format: <bool>
+			default: 0 (auto_verbose is enabled)
+
 	printk.devkmsg={on,off,ratelimit}
 			Control writing to /dev/kmsg.
 			on - unlimited logging to /dev/kmsg from userspace
include/linux/printk.h +1 -5
index a63f468a8239..0484274158d2 100644
@@ -70,11 +70,7 @@ extern int console_printk[];
 #define minimum_console_loglevel (console_printk[2])
 #define default_console_loglevel (console_printk[3])
 
-static inline void console_verbose(void)
-{
-	if (console_loglevel)
-		console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
-}
+extern void console_verbose(void);
 
 /* strlen("ratelimit") + 1 */
 #define DEVKMSG_STR_MAX_SIZE 10
kernel/printk/printk.c +12 -0
index 142a58d124d9..a6b94c3c5ac5 100644
@@ -2404,6 +2404,18 @@ module_param_named(console_suspend, console_suspend_enabled,
 MODULE_PARM_DESC(console_suspend, "suspend console during suspend"
 	" and hibernate operations");
 
+static bool printk_console_no_auto_verbose;
+
+void console_verbose(void)
+{
+	if (console_loglevel && !printk_console_no_auto_verbose)
+		console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
+}
+EXPORT_SYMBOL_GPL(console_verbose);
+
+module_param_named(console_no_auto_verbose, printk_console_no_auto_verbose, bool, 0644);
+MODULE_PARM_DESC(console_no_auto_verbose, "Disable console loglevel raise to highest on oops/panic/etc");
+
 /**
  * suspend_console - suspend the console subsystem
  *
Signature · 1 line
2.32.0
reviewer Reviewed-by on v3 2/2
#4 lore raw

Re: [PATCH v3 2/2] printk: Add printk.console_no_auto_verbose boot parameter

Quoted 16 lines · Dmitry Safonov

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_no_auto_verbose boot parameter, which allows to switch off printk being verbose on oops/panic/lockdep.

Quoted 7 lines
Cc Andrew Morton <[email protected]>
Cc John Ogness <[email protected]>
Cc Petr Mladek <[email protected]>
Cc Sergey Senozhatsky <[email protected]>
Cc Steven Rostedt <[email protected]>