From nobody Mon Dec 1 22:03:19 2025 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 5BB79305077 for ; Thu, 27 Nov 2025 19:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764272678; cv=none; b=PtkuD9YyQC7RrGNiTPoZgAxe3k3gRyfwH4MCkzsUTlxb6LHPUZSt9Rd5NW75SSY6nKiotE2XpeUnXODlVCohx0yEdmZCwdD8XaxJ3/7JP/1qKGVCvLVlYJxyGC7Bv2Ip/Y40YVXMYq299AlR+EF5l8P6Q/cSKLF7BQjpfCMTi+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764272678; c=relaxed/simple; bh=zdC68WOA66DE9rpVM6GSKTzp5cALsAAhohaJoK9A3y0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=iu4DeD+RcaCzqhQMu2gdPSrr8vLWIT3EwTIXQSKuvQ5ekSYfLDKmq8MhlGCs8NleZNE+n5Y1ElZIEdaNY+MnBfEtPYmDU3f/pV/q3ExlgNhxpldAbIF/MX9ErpeoXEBAD6Y9l797CBuh012FGxVIBGp1CiPdcoU4+LYlJpHs25w= 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=TlLjQukV; arc=none smtp.client-ip=209.85.214.182 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="TlLjQukV" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2955623e6faso12739405ad.1 for ; Thu, 27 Nov 2025 11:44:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1764272675; x=1764877475; 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=rX3QS3ePLJgGYiXNUELypUIwT2nnrt+ElbWph9AtCWk=; b=TlLjQukVmrXCdLyZ2kjJkj5XI0lcOT+C2+XKWdXRgx/o/511PMWbFFjINC2lbEdR9H 0yL/fUfVuhjYx9dlnV6yHoor4HhXDYMfpNL12dLTk478xE3IolN16FCzStxyWKkaHMY9 LOzaVsSAybockMEEA0+Rk3Z/QvlS9IDXQkmik= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764272675; x=1764877475; 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=rX3QS3ePLJgGYiXNUELypUIwT2nnrt+ElbWph9AtCWk=; b=N4IMAWRD/o+wwxV6z9LmsyfdUBjmZRp6WtT8Mhwv80muh07H/ZjQKXDCxymH8REKcL w6ctGg+/Ua2QC2iUvKt21SieJI/rRo6LGR6ImHn3DilNqSqzAiixoaSsw8yk5lnhlNMG fXgFYD4vG8wR1f4x7+nEwrcqQJGVfwdhHysWlhU9cccmMu5E8f0FS0H9rYzaImrOjRr+ YIHSmiDL59io81ZI99qOQDFe5A9KcVQcMsxafklsJDrnLZgbL1hGexwchJZx3nPvQQ4Y I7iMRtIlklwUjw066S0zqoZZhqUvv/3kZq5rJkgAGvx1uzZbWx9x67ZPVSjcMPmBT2rM +pmg== X-Gm-Message-State: AOJu0Yy9e59R9pfjDA0ncXAL43Q3cQ7yAX/ysVAh4IFW4JMKQpdi5Aqo 2rSktx8Asc5MUO1ePULxAK+BltuxNE7Q1KQf78HwfhTDF90cA1jDbv+HJjAn/Fjy+Q4= X-Gm-Gg: ASbGncvyoSUPWUVmFbJ2UqWUDphPUcLe669/jaknGhWS4ofHRzWG30Xe0tdOK8Ssthr 4Tl02WsCeihoXUd9izHd7muSj86DnsBtBzOCboJHZiPafZkEqYyiUWTP9LXQh3M4dR6lj9hBDtT 0uMVt/Rab/x63x5icLKGbq03JfCa+hAKssHVxLiRuCNAJW8JhMCclXqBjKACiWUhMKXsHnmQDQ+ xagwU8eJA9Ats9YgAxYx48EB5q7ftDblGMeIt+Y9zwNdL5h7Pk0llKOrmMrTkgTvrNAe2imQqX1 PJyF8Y1mZXij4GwguBQ07a7RXyCSR+2SO+NzuHT0PNCpnOrwJuzXHq83lBEul6oDW5tUsdoYR3t lCinQDmOyskaTpM8Mgfc6KibrvLwpz3AUHW+oMrUVgHQjb2v392v5/INSkF+8OvhLTD5TF9i37W foHc7p5x5j X-Google-Smtp-Source: AGHT+IEemJXSowmHHMIEKpbVkEGv2O3YPNMxfadw6ep9mgMYOrFcOVKlW3sFUYj4IWxGHbs8GYVtTw== X-Received: by 2002:a17:903:3a8b:b0:295:426a:77a6 with SMTP id d9443c01a7336-29bab169dc9mr120613065ad.32.1764272675388; Thu, 27 Nov 2025 11:44:35 -0800 (PST) Received: from localhost ([116.86.198.140]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-be4fbb003a1sm2682375a12.8.2025.11.27.11.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Nov 2025 11:44:35 -0800 (PST) Date: Fri, 28 Nov 2025 03:44:33 +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 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-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 034739939a61..8df4500bf3ff 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; @@ -67,13 +68,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