console: introduce wrappers to read/write console flags
authorJohn Ogness <john.ogness@linutronix.de>
Wed, 16 Nov 2022 16:21:24 +0000 (17:27 +0106)
committerPetr Mladek <pmladek@suse.com>
Fri, 2 Dec 2022 10:25:00 +0000 (11:25 +0100)
commit100bdef2c198b8dc64df011dc4a2152db913c8ba
tree49aa89134c32a85a46b6fb7d38015a12bbb37b38
parent4dc64682ad37abb02c54ca598430ac27de60c21a
console: introduce wrappers to read/write console flags

After switching to SRCU for console list iteration, some readers
will begin readings console->flags as a data race. Locklessly
reading console->flags provides a consistent value because there
is at most one CPU modifying console->flags and that CPU is
using only read-modify-write operations.

Introduce a wrapper for SRCU iterators to read console flags.
Introduce a matching wrapper to write to flags of registered
consoles. Writing to flags of registered consoles is synchronized
by the console_list_lock.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20221116162152.193147-13-john.ogness@linutronix.de
include/linux/console.h
kernel/printk/printk.c