syslog warning: was: Re: [PATCH v6 04/11] printk: Support toggling per-console loglevel via syslog() and cmdline
From: Petr Mladek
Date: Thu Nov 14 2024 - 12:14:46 EST
On Mon 2024-10-28 16:45:40, Chris Down wrote:
> A new module parameter (ignore_per_console_loglevel) is added, which can
> be set via the kernel command line or at runtime through
> /sys/module/printk/parameters/ignore_per_console_loglevel. When set, the
> per-console loglevels are ignored, and the global console loglevel
> (console_loglevel) is used for all consoles.
>
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1836,19 +1862,28 @@ int do_syslog(int type, char __user *buf, int len, int source)
> break;
> /* Disable logging to console */
> case SYSLOG_ACTION_CONSOLE_OFF:
> - if (saved_console_loglevel == LOGLEVEL_DEFAULT)
> + if (saved_console_loglevel == LOGLEVEL_DEFAULT) {
> saved_console_loglevel = console_loglevel;
> + saved_ignore_per_console_loglevel =
> + ignore_per_console_loglevel;
> + }
> console_loglevel = minimum_console_loglevel;
> + ignore_per_console_loglevel = true;
> break;
> /* Enable logging to console */
> case SYSLOG_ACTION_CONSOLE_ON:
> if (saved_console_loglevel != LOGLEVEL_DEFAULT) {
> console_loglevel = saved_console_loglevel;
> + ignore_per_console_loglevel =
> + saved_ignore_per_console_loglevel;
> saved_console_loglevel = LOGLEVEL_DEFAULT;
> }
> break;
> /* Set level of messages printed to console */
> case SYSLOG_ACTION_CONSOLE_LEVEL:
> + if (!ignore_per_console_loglevel)
> + pr_warn_once(
> + "SYSLOG_ACTION_CONSOLE_LEVEL is ignored by consoles with an explicitly set per-console loglevel, see Documentation/admin-guide/per-console-loglevel.rst\n");
I see this warning during every boot because rsyslogd() modifies the
global loglevel.
I am afraid that admins might not like it. I might live in dreams but
I guess that everyone would like to reach a clean boot without any
warning.
One the other hand, we should warn when it does not work as expected.
A compromise would be to warn only when there is a console with
the console specific loglevel set.
I am not sure if we have already discussed this in the past.
But I would prefer the compromise after all.
What do you think, please?
Best Regards,
Petr