public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Chris Down <chris@chrisdown.name>
Cc: linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Joel Granados <joel.granados@kernel.org>,
	Tony Lindgren <tony.lindgren@linux.intel.com>,
	kernel-team@fb.com
Subject: Re: [PATCH v8 20/21] printk: Deprecate the kernel.printk sysctl interface
Date: Fri, 12 Dec 2025 16:51:46 +0100	[thread overview]
Message-ID: <aTw6EpA5nJXhsrhi@pathway> (raw)
In-Reply-To: <f89faed3592dc0d8bcf87d892104a57d674be705.1764272407.git.chris@chrisdown.name>

Added Joel into Cc for the sysrq API changes.

On Fri 2025-11-28 03:44:33, Chris Down wrote:
> The kernel.printk sysctl interface is deprecated in favour of more
> granular and clearer sysctl interfaces for controlling loglevels, namely
> kernel.console_loglevel and kernel.default_message_loglevel.
> 
> kernel.printk has a number of fairly significant usability problems:
> 
> - It takes four values in a specific order, which is not intuitive.
>   Speaking from personal experience, even people working on printk
>   sometimes need to look up the order of these values, which doesn't
>   suggest much in the way of perspicuity.
> - There is no validation on the input values, so users can set them to
>   invalid or nonsensical values without receiving any errors or
>   warnings. This can lead to unpredictable behaviour.
> - One of the four values, default_console_loglevel, is not used in the
>   kernel (see below), making it redundant and potentially confusing.
> - Overall, the interface is complex, hard to understand, and combines
>   multiple controls into a single sysctl, which is not ideal. It should
>   be separated into distinct controls for clarity.
> 
> Setting kernel.printk now calls printk_sysctl_deprecated, which emits a
> pr_warn. The warning informs users about the deprecation and suggests
> using the new sysctl interfaces instead.
> 
> By deprecating kernel.printk, we aim to:
> 
> - Encourage users to adopt the new, dedicated sysctl interfaces
>   (kernel.console_loglevel and kernel.default_message_loglevel), which
>   are more straightforward and easier to understand.
> - Improve input validation and error handling, ensuring that users
>   receive appropriate feedback when setting invalid values.
> - Simplify the configuration of loglevels by exposing only the controls
>   that are necessary and relevant.
> 
> --- a/kernel/printk/sysctl.c
> +++ b/kernel/printk/sysctl.c
> @@ -7,6 +7,7 @@
>  #include <linux/printk.h>
>  #include <linux/capability.h>
>  #include <linux/ratelimit.h>
> +#include <linux/console.h>
>  #include "internal.h"
>  
>  static const int ten_thousand = 10000;
> @@ -67,13 +68,24 @@ static int proc_dointvec_console_loglevel(const struct ctl_table *table,
>  			       do_proc_dointvec_console_loglevel, NULL);
>  }
>  
> +static int proc_dointvec_printk_deprecated(const struct ctl_table *table, int write,
> +					   void *buffer, size_t *lenp, loff_t *ppos)
> +{
> +	int res = proc_dointvec(table, write, buffer, lenp, ppos);
> +
> +	if (write)
> +		pr_warn_once("printk: The kernel.printk sysctl is deprecated. Consider using kernel.console_loglevel or kernel.default_message_loglevel instead.\n");
> +
> +	return res;
> +}
> +
>  static const struct ctl_table printk_sysctls[] = {
>  	{
>  		.procname	= "printk",
>  		.data		= &console_loglevel,
>  		.maxlen		= 4*sizeof(int),
>  		.mode		= 0644,
> -		.proc_handler	= proc_dointvec,
> +		.proc_handler	= proc_dointvec_printk_deprecated,
>  	},
>  	{
>  		.procname	= "printk_ratelimit",

These changes work because the sysctl API changes were backward
compatible. But it would be nice to follow the new parameter names,
...

I propose to do:

   + renamed @write to @dir
   + use SYSCTL_USER_TO_KERN(dir) macro

I mean to do the following changes on top of this patch:

--- a/kernel/printk/sysctl.c
+++ b/kernel/printk/sysctl.c
@@ -73,12 +73,12 @@ static int proc_dointvec_console_loglevel(const struct ctl_table *table,
 			       do_proc_dointvec_console_loglevel);
 }
 
-static int proc_dointvec_printk_deprecated(const struct ctl_table *table, int write,
+static int proc_dointvec_printk_deprecated(const struct ctl_table *table, int dir,
 					   void *buffer, size_t *lenp, loff_t *ppos)
 {
-	int res = proc_dointvec(table, write, buffer, lenp, ppos);
+	int res = proc_dointvec(table, dir, buffer, lenp, ppos);
 
-	if (write)
+	if (SYSCTL_USER_TO_KERN(dir))
 		pr_warn_once("printk: The kernel.printk sysctl is deprecated. Consider using kernel.console_loglevel or kernel.default_message_loglevel instead.\n");
 
 	return res;


Best Regards,
Petr

  reply	other threads:[~2025-12-12 15:51 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 19:43 [PATCH v8 00/21] printk: console: Per-console loglevels Chris Down
2025-11-27 19:43 ` [PATCH v8 01/21] printk: Fully resolve loglevel before deciding printk delay suppression Chris Down
2025-12-09 16:40   ` Petr Mladek
2025-12-11 14:49     ` Petr Mladek
2025-12-11 15:28       ` Petr Mladek
2025-11-27 19:43 ` [PATCH v8 02/21] printk: Avoid spuriously delaying messages not solicited by any console Chris Down
2025-11-27 19:43 ` [PATCH v8 03/21] printk: Prioritise user-specified configuration over SPCR/DT Chris Down
2025-12-10 14:38   ` Petr Mladek
2025-11-27 19:43 ` [PATCH v8 04/21] printk: Use effective loglevel for suppression and extended console state Chris Down
2025-11-27 19:43 ` [PATCH v8 05/21] printk: console: Add per-console loglevel support to struct console Chris Down
2025-11-27 19:43 ` [PATCH v8 06/21] printk: nbcon: Synchronise console unregistration against atomic flushers Chris Down
2025-12-10 15:12   ` Petr Mladek
2025-11-27 19:43 ` [PATCH v8 07/21] printk: Introduce per-console loglevel support Chris Down
2025-11-27 19:43 ` [PATCH v8 08/21] printk: Iterate registered consoles for delay suppression decisions Chris Down
2025-11-27 19:43 ` [PATCH v8 09/21] printk: Optimise printk_delay() to avoid walking consoles under SRCU Chris Down
2025-12-11 14:37   ` Petr Mladek
2025-11-27 19:43 ` [PATCH v8 10/21] printk: Add synchronisation for concurrent console state changes Chris Down
2025-11-27 19:43 ` [PATCH v8 11/21] printk: Add ignore_per_console_loglevel module parameter Chris Down
2025-11-27 19:43 ` [PATCH v8 12/21] printk: Ensure sysrq output bypasses per-console filtering Chris Down
2025-11-27 19:44 ` [PATCH v8 13/21] printk: Toggle ignore_per_console_loglevel via syslog Chris Down
2025-11-27 19:44 ` [PATCH v8 14/21] printk: console: Introduce sysfs interface for per-console loglevels Chris Down
2025-12-12 14:04   ` Petr Mladek
2025-11-27 19:44 ` [PATCH v8 15/21] printk: sysrq: Clamp console loglevel to valid range Chris Down
2025-12-12 14:10   ` Petr Mladek
2025-11-27 19:44 ` [PATCH v8 16/21] printk: Constrain hardware-addressed console checks to name position Chris Down
2025-11-27 19:44 ` [PATCH v8 17/21] printk: Support setting initial console loglevel via console= on cmdline Chris Down
2025-11-27 19:44 ` [PATCH v8 18/21] printk: Deconstruct kernel.printk into discrete sysctl controls Chris Down
2025-12-12 15:24   ` Petr Mladek
2025-12-15 10:08     ` Joel Granados
2025-12-15 16:09       ` Petr Mladek
2025-11-27 19:44 ` [PATCH v8 19/21] printk: docs: Add comprehensive guidance for per-console loglevels Chris Down
2025-12-12 15:32   ` Petr Mladek
2025-11-27 19:44 ` [PATCH v8 20/21] printk: Deprecate the kernel.printk sysctl interface Chris Down
2025-12-12 15:51   ` Petr Mladek [this message]
2025-12-15  9:52     ` Joel Granados
2025-12-15 16:06       ` Petr Mladek
2025-12-17 11:47         ` Joel Granados
2025-12-17 14:33           ` Geert Uytterhoeven
2025-12-17 16:04             ` Steven Rostedt
2025-12-17 20:23               ` Joel Granados
2025-11-27 19:44 ` [PATCH v8 21/21] printk: Purge default_console_loglevel Chris Down
2025-12-12 16:11 ` [PATCH v8 00/21] printk: console: Per-console loglevels 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=aTw6EpA5nJXhsrhi@pathway \
    --to=pmladek@suse.com \
    --cc=chris@chrisdown.name \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joel.granados@kernel.org \
    --cc=john.ogness@linutronix.de \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tony.lindgren@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox