[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221107141638.3790965-9-john.ogness@linutronix.de>
Date: Mon, 7 Nov 2022 15:22:06 +0106
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org
Subject: [PATCH printk v3 08/40] printk: use console_is_enabled()
Replace (console->flags & CON_ENABLED) usage with console_is_enabled()
if it involves a data race. Otherwise add comments mentioning why the
wrapper is not used.
Note that this is a preparatory change for when console_lock no longer
provides synchronization for console->flags.
Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
kernel/printk/printk.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 79811984da34..f243bb56a3ba 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2660,7 +2660,7 @@ static bool abandon_console_lock_in_panic(void)
*/
static inline bool console_is_usable(struct console *con)
{
- if (!(con->flags & CON_ENABLED))
+ if (!console_is_enabled(con))
return false;
if (!con->write)
@@ -2946,7 +2946,7 @@ void console_unblank(void)
console_locked = 1;
console_may_schedule = 0;
for_each_console(c)
- if ((c->flags & CON_ENABLED) && c->unblank)
+ if (console_is_enabled(c) && c->unblank)
c->unblank();
console_unlock();
@@ -3104,8 +3104,11 @@ static int try_enable_preferred_console(struct console *newcon,
* Some consoles, such as pstore and netconsole, can be enabled even
* without matching. Accept the pre-enabled consoles only when match()
* and setup() had a chance to be called.
+ *
+ * Note that reading @flags is race-free because the console is not
+ * yet added to the console list.
*/
- if (newcon->flags & CON_ENABLED && c->user_specified == user_specified)
+ if ((newcon->flags & CON_ENABLED) && (c->user_specified == user_specified))
return 0;
return -ENOENT;
--
2.30.2
Powered by blists - more mailing lists