diff options
author | John Ogness <john.ogness@linutronix.de> | 2022-11-16 17:21:30 +0100 |
---|---|---|
committer | Petr Mladek <pmladek@suse.com> | 2022-12-02 11:25:00 +0100 |
commit | d792db6f6b902dad6b751dc2ef226fb4463efe62 (patch) | |
tree | cf34c7e720054ef2114e2fd82b83f0540e59c549 /kernel/printk | |
parent | printk: console_is_usable: use console_srcu_read_flags (diff) | |
download | linux-d792db6f6b902dad6b751dc2ef226fb4463efe62.tar.xz linux-d792db6f6b902dad6b751dc2ef226fb4463efe62.zip |
printk: console_unblank: use srcu console list iterator
Use srcu console list iteration for console list traversal.
Document why the console_lock is still necessary. Note that this
is a preparatory change for when console_lock no longer provides
synchronization for the console list.
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-19-john.ogness@linutronix.de
Diffstat (limited to 'kernel/printk')
-rw-r--r-- | kernel/printk/printk.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 853a86c94ee0..8e37a35764f2 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -3000,10 +3000,14 @@ EXPORT_SYMBOL(console_conditional_schedule); void console_unblank(void) { struct console *c; + int cookie; /* - * console_unblank can no longer be called in interrupt context unless - * oops_in_progress is set to 1.. + * Stop console printing because the unblank() callback may + * assume the console is not within its write() callback. + * + * If @oops_in_progress is set, this may be an atomic context. + * In that case, attempt a trylock as best-effort. */ if (oops_in_progress) { if (down_trylock_console_sem() != 0) @@ -3013,9 +3017,14 @@ void console_unblank(void) console_locked = 1; console_may_schedule = 0; - for_each_console(c) - if ((c->flags & CON_ENABLED) && c->unblank) + + cookie = console_srcu_read_lock(); + for_each_console_srcu(c) { + if ((console_srcu_read_flags(c) & CON_ENABLED) && c->unblank) c->unblank(); + } + console_srcu_read_unlock(cookie); + console_unlock(); if (!oops_in_progress) |