RFC 2/2] printk: Restore and document obsolete ways to disable console output

From: Petr Mladek
Date: Thu Oct 22 2020 - 07:42:58 EST


The commit 48021f98130880dd7 ("printk: handle blank console arguments
passed in.") prevented crash caused by empty console= parameter value.

Unfortunately, this value is widely used on Chromebooks to disable
the console output. The above commit caused performance regression
because the messages were pushed on slow console even though nobody
was watching it.

"mute_console" kernel parameter has been introduced as a proper and
official was to disable console output. It avoids the performance
problem by suppressing all kernel messages. Also avoids the crash
by registering the default console.

Make console="" behave the same as "mute_console" to avoid
the performance regression on existing Chromebooks.

Do the same also for console=null which seem to be another widely
suggested and non-official way to disable the console output.

Suggested-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>
---
Documentation/admin-guide/kernel-parameters.txt | 5 +++++
kernel/printk/printk.c | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 52b9e7f5468d..14472f674a89 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -670,11 +670,16 @@
hvc<n> Use the hypervisor console device <n>. This is for
both Xen and PowerPC hypervisors.

+ null
+ "" Obsolete way to disable console output. Please,
+ use "mute_console" instead.
+
If the device connected to the port is not a TTY but a braille
device, prepend "brl," before the device type, for instance
console=brl,ttyS0
For now, only VisioBraille is supported.

+
console_msg_format=
[KNL] Change console messages format
default
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 63fb96630767..08c50d8ba110 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2208,8 +2208,15 @@ static int __init console_setup(char *str)
char *s, *options, *brl_options = NULL;
int idx;

- if (str[0] == 0)
+ /*
+ * console="" or console=null have been suggested as a way to
+ * disable console output. It worked just by chance and was not
+ * reliable. It has been obsoleted by "mute_console" parameter.
+ */
+ if (str[0] == 0 || strcmp(str, "null") == 0) {
+ mute_console = true;
return 1;
+ }

if (_braille_console_setup(&str, &brl_options))
return 1;
--
2.26.2