Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1752889ybh; Sun, 15 Mar 2020 10:10:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vshrg6879hWOQrDD8ygKv9DU6lnLyrc7K+3qGSUuiXb63EVY7Usdyqjp6Cl5yD0CavvFvj+ X-Received: by 2002:a05:6830:18e1:: with SMTP id d1mr17856237otf.8.1584292235716; Sun, 15 Mar 2020 10:10:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584292235; cv=none; d=google.com; s=arc-20160816; b=F+DYQN+mhLYnUqnVXxv4wgMKSxxosZ8UhVFmxyQ/Wv7NoKqwhBtJNFR0Sy0Gf2XpIG MB7cPO87T4MuG6iKuWzcSOiirNxm2T4Vz5EZNnC6KCAeP4+fQ6BW3T2QQ8fr9Xjh90Ia OuraSQEBHfJUZxF22JPEIUpRlS9JSgWwKF/uA/WHfHijd9+FWYuM2bDW3+8F69bxKw/y XHdWdVvHDnOfW7sSBemeEfQBxdG/xF79xeXvSZZ/SPx8l8cVvL10pPUeQkyt949CJsLW ii5uhUBieNtEWmg11IBIoeqU7zlRGKatdRHmz9vmnItNyyeJb03Y3spLf0Tmx6RhDgcV AP4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V44A2I37Drhfg/qPIvr3ypiS3ycesuCf9thvM+4L9ms=; b=HD2rxeRq8HvYSgSrFED1UrXZKGaDWmL5K2wjszglPzs9e1K6IbNRI8zN6FGIOagUio jPuPwJwxHItc3L/kiGOP80zxxC1yyDC1SWy4XbC+Xg5S/gBi9f55BVllcljsoHKldsub 7s2fo+1xlkAyynXUZM+SxQsY4XIL3rJfIAKPVf0Qr5K4ochwe3bd+sb2LPlEB9VHikXU 0mKN/Upo4Ct9wKicr5GoJytyhnuFXg7Q6yG4nppuyZ+8fN4Kz8UTHaveXZ+qGGJMwB0h MJ00eqTHqiMI32bhvYkXBVYpOycYiNDOQeBLdCviapoV+6KIQivWeCuqwJUTTnnnOsj1 K9JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="vh68/Vu7"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si7341360oti.106.2020.03.15.10.10.23; Sun, 15 Mar 2020 10:10:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="vh68/Vu7"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728977AbgCORJo (ORCPT + 99 others); Sun, 15 Mar 2020 13:09:44 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36417 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728915AbgCORJo (ORCPT ); Sun, 15 Mar 2020 13:09:44 -0400 Received: by mail-wr1-f66.google.com with SMTP id s5so18339062wrg.3 for ; Sun, 15 Mar 2020 10:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V44A2I37Drhfg/qPIvr3ypiS3ycesuCf9thvM+4L9ms=; b=vh68/Vu7YuC3asq+YRBLjvxbYWvRSiMivpCnhv/UWPWPRN5ixYdzX5iGTyJvHFBaKJ Po1mifghFJqN0FHCcfMlDCOCmPENkWOxSj09Zht0xltPw6LagEVjWlS2xYKHnr/HvZ97 QQ2i0jgXoMxpd5wz61UI+kbvC+fb0JchUgiKGJ4c2x7HbI58i3l4opnJsUAncw3dabF+ qIyaz/OS/5cpTDd9/ZgkcEJzYkV+ApCXnQPsg5ISKsdqcJIxTn22UGsho5BLjxGX3M3P 14KiaCmyI6eZjSj+IjAvRVhIZkVQRU77izWfEPJdDArepnKyNV+rP5Ey8PClFX8S1trj Pvxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V44A2I37Drhfg/qPIvr3ypiS3ycesuCf9thvM+4L9ms=; b=dMfFG1c1MlT31fdBZpprP1nnqInoEQEcUZ9XVGWqcJbL/dyd8KTSnnh0pqSVi7hws7 wW4PLfM9TYs4G5W5fakJpZurrSWMoTuSYT+cEVrKfamn9IYys6tlBGBH+qhfbBAvhoP6 PG2ZSFYozrIy02uPZu79nwSFHT+bj2+U6me1pm1Bs0L+gqcTQYSUmhP4jXzkrZut73m+ 3Vw2VS0/iFHDGfA7kbGrNuemAFGGVP8yZ3nRvlWBEfk9sIUzUekDRxcaC3OzNZVDpFUF ZbG2x6dicjBzOOauXC8afwXzrEN9bK1cbFsiavmY7dfdNNDAGA+wl7QxYmbK8m268BEv N5Gw== X-Gm-Message-State: ANhLgQ2kIetyM3BePgJ6KnB390eWF3oulLPrDxDCfvia1kFnfv/uoCV9 WLvmlAbTN0P+p/tEadW5LQnrEavcZksbij0l X-Received: by 2002:adf:cf08:: with SMTP id o8mr29256448wrj.192.1584292182444; Sun, 15 Mar 2020 10:09:42 -0700 (PDT) Received: from localhost.localdomain (ipb218f56a.dynamic.kabel-deutschland.de. [178.24.245.106]) by smtp.gmail.com with ESMTPSA id u25sm25874774wml.17.2020.03.15.10.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Mar 2020 10:09:41 -0700 (PDT) From: Eugeniu Rosca X-Google-Original-From: Eugeniu Rosca To: linux-kernel@vger.kernel.org Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Jisheng Zhang , Valdis Kletnieks , Sebastian Andrzej Siewior , Andrew Gabbasov , Dirk Behme , Eugeniu Rosca Subject: [RFC PATCH 1/3] printk: convert ignore_loglevel to atomic_t Date: Sun, 15 Mar 2020 18:09:01 +0100 Message-Id: <20200315170903.17393-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200315170903.17393-1-erosca@de.adit-jv.com> References: <20200315170903.17393-1-erosca@de.adit-jv.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prepare for using the 'ignore_loglevel' variable as a lockless and SMP safe vehicle to turn console verbosity on and off in error paths which usually (but not necessarily) end up with panic (configurable via user-selectable knobs). No functional change intended. Tested on R-Car H3ULCB. Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: Ingo Molnar Signed-off-by: Eugeniu Rosca --- kernel/printk/printk.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index fada22dc4ab6..d2c75955a0d7 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1181,24 +1181,46 @@ void __init setup_log_buf(int early) free, (free * 100) / __LOG_BUF_LEN); } -static bool __read_mostly ignore_loglevel; +atomic_t __read_mostly ignore_loglevel = ATOMIC_INIT(0); static int __init ignore_loglevel_setup(char *str) { - ignore_loglevel = true; + atomic_set(&ignore_loglevel, 1); pr_info("debug: ignoring loglevel setting.\n"); return 0; } +static int kparam_set_atomic(const char *val, const struct kernel_param *kp) +{ + if (param_set_bool(val, kp)) + return -EINVAL; + + atomic_set(&ignore_loglevel, *(bool *)kp->arg ? 1 : 0); + + return 0; +} + +static int kparam_get_atomic(char *val, const struct kernel_param *kp) +{ + return sprintf(val, "%c\n", atomic_read(&ignore_loglevel) ? 'Y' : 'N'); +} + +static const struct kernel_param_ops kparam_ops = { + .set = kparam_set_atomic, + .get = kparam_get_atomic, +}; + +static int kparam_buf; + early_param("ignore_loglevel", ignore_loglevel_setup); -module_param(ignore_loglevel, bool, S_IRUGO | S_IWUSR); +module_param_cb(ignore_loglevel, &kparam_ops, &kparam_buf, 0644); MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting (prints all kernel messages to the console)"); static bool suppress_message_printing(int level) { - return (level >= console_loglevel && !ignore_loglevel); + return (level >= console_loglevel && !atomic_read(&ignore_loglevel)); } #ifdef CONFIG_BOOT_PRINTK_DELAY -- 2.25.0