From nobody Tue Dec 2 02:41:47 2025 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 0A69535CB99 for ; Tue, 18 Nov 2025 19:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763492900; cv=none; b=PlOfZqD4us4lX6qHsjWtlNW949MsrCKBw2YzKfm+3BK6DKwKwPuV8yw0ITNwp3SExkpt/Y/E7jo4N/pYXXcpEzjVbOhyr0T2BjatRsRsvKn+aqg3Zs71PpYWHOf15fN1vkACNx0f8DihEsr6N2Cf0LsUnfJFPUsxJenpQLAr6T8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763492900; c=relaxed/simple; bh=eisP/xbphN7/7oRjxa7967qgHcZFsrBxk8CE9k49X8s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NvF1B6ib7xIG5e3uqI+HPNbOtBjIqr3SAqh4zluC4S4KNpARAYENCiEG6EfOJ1p6Oi4s94YSjp3UpUUnrAQ4I/mQzCHc4uqns0PaifKnqmjYXagpk1NmTsJ4WI3flEkx6MZ3Y6lq/r6O3T/zhuYPzp7TBHMYMieCnCZ1pT9CZd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b=VyzXr4Dy; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="VyzXr4Dy" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29568d93e87so53347515ad.2 for ; Tue, 18 Nov 2025 11:08:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1763492898; x=1764097698; darn=vger.kernel.org; h=user-agent: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=07GsZTKRZUMw2kqRQJtb66HAz52UrWx2fVcU/BAMqSs=; b=VyzXr4DyIE8fQJ3Dt6VHM9+Zd1WLAPiHPs1rbef4DIzXxckvTDMqdPIqWy5W7UNKAp NIteK8Ih0VUBa6kJPK8UmxtlBk/SZRansG6lmeuvsqZSOVZvUaWKKuIyzA9+K5o0Wroh BfyM6PyKpV2Y+G9QyC1H3/z43OumQ/T3Fp57Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763492898; x=1764097698; h=user-agent: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=07GsZTKRZUMw2kqRQJtb66HAz52UrWx2fVcU/BAMqSs=; b=eps7MnJmffjvJmIiXKRLFcprTBuIVf1SoDyF7pGbzRDt05hPu9vNiNXq+oEUwaC0MG GheWgDjvdIy8/WUBCZCCteZ9HIpvBkzUqaotkJUtG2MLnzeHBbiY2yfTxykoTRf3pe3a SjExTozuv8x0fKj1EhvpJOgA7YjWzUtQ0qT++HhszR6s8DqMqRDYqaNhMqeGHd77f2PB O+s1PEy+PGhOVxeacN+97isN3p7z/KfBaiLBZeaxHcTKW6vLr8Bg6lgG74iAOSEjVrnA 7NkV0Ga5O/oiobhos322sav0DDbCyk2/pakOzf7c3eA22AfTpcOelcKdij8OWAHs1QiA 8F+Q== X-Gm-Message-State: AOJu0Yw1Xltf0ZSyTyjCsVhN4Iu52EvSakLB1z0mzo+3RjFH5MHcqVmf wZkpKiTYGXMtuY3KFCy/1TQ7JR1M/MHcSng46db2hBwDRhUBzswRIt2YZu9eSSvm3yY= X-Gm-Gg: ASbGncsywwH6o8o73Xnd8oyNmd9qs7vt3GbLHITssdfO08Gj8whC+jlgp/cD87kBSWC 40DjThqXm+fuSELdCvAuHfoOIZl52ja+yqXmrUllqHHz0vzKRaAmRFUi7L7ObR9UySRN9qb7QnB MOLMSpg23RXf2XPiJMT01yaiOYqCLmqw+8PSonLZtrpvragDwahn31rctki0CyYuf4kMmANv8l2 JH5kDk1njqo4z1m4iEdKGTl1NT4uqJFQeNECbSyJqgeRFPn7STXscVgNNrhQuQSr2RdnL5+xTb2 9JTcQqmsButUrege0i8fRwKdQHq8vfWWIyVTGw0RCUcYoKCc1N7gtuMlKhyjf4g2yz9FVXc9Rsn zeG4VRCp3hvzhFmOK9lXCqS+A5PNmmo9Xmuko5XL1bTLWqITD6XN39VR9u3/4sGoL2JNHIuKKPR fJTSiVV+pH X-Google-Smtp-Source: AGHT+IEFo+7eXnooMW0Z1Ea6JAkJqrG7YPrB0Mih4OlHMK0o3Bixh26L7C7G8ZJgl3dPENXU4psFeg== X-Received: by 2002:a17:903:252:b0:246:e1b6:f9b0 with SMTP id d9443c01a7336-2986a6cfd38mr213014835ad.18.1763492898215; Tue, 18 Nov 2025 11:08:18 -0800 (PST) Received: from localhost ([116.86.198.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2985ce19a20sm178233345ad.84.2025.11.18.11.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Nov 2025 11:08:17 -0800 (PST) Date: Wed, 19 Nov 2025 03:08:16 +0800 From: Chris Down To: Petr Mladek Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Sergey Senozhatsky , Steven Rostedt , John Ogness , Geert Uytterhoeven , Tony Lindgren , kernel-team@fb.com Subject: [PATCH v7 12/13] printk: Deprecate the kernel.printk sysctl interface Message-ID: <42d7254ffdfa30fc0bd3f1aa7cac354891e95231.1763492585.git.chris@chrisdown.name> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.15 (2b349c5e) (2025-10-02) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Petr Mladek Signed-off-by: Chris Down --- Documentation/admin-guide/sysctl/kernel.rst | 3 +++ kernel/printk/sysctl.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/ad= min-guide/sysctl/kernel.rst index 043d5f663b7d..5ac6db03c2fb 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -1096,6 +1096,9 @@ Messages without an explicit priority will be printed= with this priority. printk =3D=3D=3D=3D=3D=3D =20 +This sysctl is deprecated and will be removed in future. Please consider u= sing +``kernel.console_loglevel`` or ``kernel.default_message_loglevel`` instead. + The four values in printk denote: ``console_loglevel``, ``default_message_loglevel``, ``minimum_console_loglevel`` and ``default_console_loglevel`` respectively. diff --git a/kernel/printk/sysctl.c b/kernel/printk/sysctl.c index feec6cf939af..921e0f80ee8f 100644 --- a/kernel/printk/sysctl.c +++ b/kernel/printk/sysctl.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "internal.h" =20 static const int ten_thousand =3D 10000; @@ -56,13 +57,24 @@ static int proc_dointvec_console_loglevel(const struct = ctl_table *table, do_proc_dointvec_console_loglevel, NULL); } =20 +static int proc_dointvec_printk_deprecated(const struct ctl_table *table, = int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + int res =3D proc_dointvec(table, write, buffer, lenp, ppos); + + if (write) + pr_warn_once("printk: The kernel.printk sysctl is deprecated. Consider u= sing kernel.console_loglevel or kernel.default_message_loglevel instead.\n"= ); + + return res; +} + static const struct ctl_table printk_sysctls[] =3D { { .procname =3D "printk", .data =3D &console_loglevel, .maxlen =3D 4*sizeof(int), .mode =3D 0644, - .proc_handler =3D proc_dointvec, + .proc_handler =3D proc_dointvec_printk_deprecated, }, { .procname =3D "printk_ratelimit", --=20 2.51.2