[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200315170903.17393-2-erosca@de.adit-jv.com>
Date: Sun, 15 Mar 2020 18:09:01 +0100
From: Eugeniu Rosca <roscaeugeniu@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Jisheng Zhang <Jisheng.Zhang@...aptics.com>,
Valdis Kletnieks <valdis.kletnieks@...edu>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Andrew Gabbasov <andrew_gabbasov@...tor.com>,
Dirk Behme <dirk.behme@...bosch.com>,
Eugeniu Rosca <erosca@...adit-jv.com>
Subject: [RFC PATCH 1/3] printk: convert ignore_loglevel to atomic_t
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 <pmladek@...e.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@...il.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Ingo Molnar <mingo@...nel.org>
Signed-off-by: Eugeniu Rosca <erosca@...adit-jv.com>
---
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
Powered by blists - more mailing lists