Skip to content

Commit d792db6

Browse files
jognesspmladek
authored andcommitted
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
1 parent 12f1da5 commit d792db6

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

kernel/printk/printk.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3000,10 +3000,14 @@ EXPORT_SYMBOL(console_conditional_schedule);
30003000
void console_unblank(void)
30013001
{
30023002
struct console *c;
3003+
int cookie;
30033004

30043005
/*
3005-
* console_unblank can no longer be called in interrupt context unless
3006-
* oops_in_progress is set to 1..
3006+
* Stop console printing because the unblank() callback may
3007+
* assume the console is not within its write() callback.
3008+
*
3009+
* If @oops_in_progress is set, this may be an atomic context.
3010+
* In that case, attempt a trylock as best-effort.
30073011
*/
30083012
if (oops_in_progress) {
30093013
if (down_trylock_console_sem() != 0)
@@ -3013,9 +3017,14 @@ void console_unblank(void)
30133017

30143018
console_locked = 1;
30153019
console_may_schedule = 0;
3016-
for_each_console(c)
3017-
if ((c->flags & CON_ENABLED) && c->unblank)
3020+
3021+
cookie = console_srcu_read_lock();
3022+
for_each_console_srcu(c) {
3023+
if ((console_srcu_read_flags(c) & CON_ENABLED) && c->unblank)
30183024
c->unblank();
3025+
}
3026+
console_srcu_read_unlock(cookie);
3027+
30193028
console_unlock();
30203029

30213030
if (!oops_in_progress)

0 commit comments

Comments
 (0)