From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAF9A1ACEDF for ; Fri, 12 Dec 2025 15:51:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765554714; cv=none; b=ZcfQmaahsDB33ZPHJCZW3n3UJ3Lij3q4aISi1cgd4rpcAfB6Rt1SllHfj9wVxaggZxMJL31DTjImnZ7AmQSwuIrBBxiqaa9BqXYeiieh1xgTcXM0xrdSavp55rU9UtMC6UwfVgYr6AmuVbbg26HiLEZw5uGrYGFufudM4GXrJAk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765554714; c=relaxed/simple; bh=kJfCf/K3O/DtB9S5i47sOhJSFc1ROZp2XsQf5djm4ok=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iZXJbbILKiib1fLuBW68g6Yauo5OZpqfLoXMA/QZ1JbiLPfvNAwgSPCx2VpaSvmGzLIh60HWiIXKLVCmAR5YsclYeoY8fVo+6b/CD0zpa7Bl58MlO/r+Jfu/WTI5SA7lBr1yQMiM/KOKfk26JJsrkFOSz6jw6FGygJxBoXVa6jw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Jl+VpEO8; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Jl+VpEO8" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-47774d3536dso13387115e9.0 for ; Fri, 12 Dec 2025 07:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1765554709; x=1766159509; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qWy/YZBwI92ScMwpgTK9ONHwyvgkMR/zl9CG2Ls7R6g=; b=Jl+VpEO8Xo5TKy4X9C+qWrwqFkO+FYv8NIDJr5tqtfuodfLFghdLBJfiP3aogiviV7 hoOn/o4hkWIRBKE5fUiRxtd6LIwo+fjAWcKaUrQnfS/CIZ7aQnre0SyBUeg/TbP7lHj7 4WNP8RpG9LjoIXWkDCTFP1P+Gi0WW0CIA74KJ3lbwp4pJiu8C4Raaan1KuqzL4BZ2BJ8 m7IjdMfrVWeo5rWthtmANJ/+q3ozcr87yyWWVn7WOAUM5KKn95BNeYe5uvB+jdw0ZBdl NqZHfzeXxbkP/o9eJ1Fz8imTkrjhL5bdJxluBmvDInSROBEAban5IyuiZBTeYNX6Xn/a 5t+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765554709; x=1766159509; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qWy/YZBwI92ScMwpgTK9ONHwyvgkMR/zl9CG2Ls7R6g=; b=UORJ2UWVVZPDPZ0GIYt8zXCJtm93AlUW+tg1Zv6IvZMEZzp+jgQdTcbovtFhMnRTAG E2YPAFO11j6DdsHxmj5k9hmLlyQDXVQKpOctBmn6wr5tCz/iZ8ogOx4ElO537yzSIjpp 1VD+bttjKmZKPSaV6AkQTjTalgjGW/74qYny3R+xm+mrXpAQlRQN+SrZGc5mPtTWiFff kcbgFYZRe3jvvUuUUKTxQgDuyIeVkl3KXQQXY506OrXtDQZPiNGjFDfHAr7uJrcjbuhb VVpgaI05azb4le8FVduGaBoY0NkR/EomKlNgQxbxpX/ADmUWmJVbcXuyyB5ret6ZO3dK vPQg== X-Gm-Message-State: AOJu0YzuMwubEJ6f9fnVmJgkkVZJJqKyjyN+SGFif3+YK2oONblrgKHB lzXS7zxN/CbcqhxCuNLdPIl/epq0I2ok5+Jt77q91Ko+cAwZOeM0LonHrGXwGQpTfeU= X-Gm-Gg: AY/fxX47jxeaXQ+vptWD1Czk1WhQXJ5EVyFMPqLcY9fPpabwByPf8vtImDsh0bu2YjG f+SrKExomPgllsYSSOKAwilL6VTKH/i3LhmpedNChi00e/rF+I4tDvSXFmtWVM6jJVNnc5oIKda Gdh5WTXug2uZUbrFuelipFENaok1Hpi6xO8we6J2VTvnOHTkMwqOGlpVud8nj49ewvZTr+MIHhG n3c0U07FG8itO2uL4XQV66w0w5TVnY/H4xXVs37EGqRnXEp6oMNRwqFrp9D7Pj4t/gRglNTax9x GVlN/XYZlb8cl6LqH/pJtg/exoujCK9N7jS3nwkb2VR7RoejocozvGsUrJ7Jxa3hUX0MI30ImvN P7wzvdnelFsA9YocKy+GysklTwaxbvYmnJScaHz2676LR68qbBdAf2o8DYTQNvef6trLYepGqUe Jwz1EDJ4VS4sTirw== X-Google-Smtp-Source: AGHT+IEaTaMKIN+n9G+YI1lB7O7oavpClHIRUyLFajWRv9Z++IZ3+MrQXDcZUAT9YK983bSclb1ZDw== X-Received: by 2002:a05:600c:1994:b0:471:5c0:94fc with SMTP id 5b1f17b1804b1-47a8f0a444emr29837805e9.6.1765554708996; Fri, 12 Dec 2025 07:51:48 -0800 (PST) Received: from pathway ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a8f6e58c1sm36216125e9.12.2025.12.12.07.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 07:51:48 -0800 (PST) Date: Fri, 12 Dec 2025 16:51:46 +0100 From: Petr Mladek To: Chris Down Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , Joel Granados , Tony Lindgren , kernel-team@fb.com Subject: Re: [PATCH v8 20/21] printk: Deprecate the kernel.printk sysctl interface Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > #include > #include > +#include > #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