Commit eb7f1ed2 authored by John Ogness's avatar John Ogness Committed by Petr Mladek

printk: __pr_flush: 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: default avatarJohn Ogness <john.ogness@linutronix.de>
Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20221116162152.193147-17-john.ogness@linutronix.de
parent fc956ae0
...@@ -3561,6 +3561,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre ...@@ -3561,6 +3561,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
struct console *c; struct console *c;
u64 last_diff = 0; u64 last_diff = 0;
u64 printk_seq; u64 printk_seq;
int cookie;
u64 diff; u64 diff;
u64 seq; u64 seq;
...@@ -3571,9 +3572,15 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre ...@@ -3571,9 +3572,15 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
for (;;) { for (;;) {
diff = 0; diff = 0;
/*
* Hold the console_lock to guarantee safe access to
* console->seq and to prevent changes to @console_suspended
* until all consoles have been processed.
*/
console_lock(); console_lock();
for_each_console(c) { cookie = console_srcu_read_lock();
for_each_console_srcu(c) {
if (con && con != c) if (con && con != c)
continue; continue;
if (!console_is_usable(c)) if (!console_is_usable(c))
...@@ -3582,6 +3589,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre ...@@ -3582,6 +3589,7 @@ static bool __pr_flush(struct console *con, int timeout_ms, bool reset_on_progre
if (printk_seq < seq) if (printk_seq < seq)
diff += seq - printk_seq; diff += seq - printk_seq;
} }
console_srcu_read_unlock(cookie);
/* /*
* If consoles are suspended, it cannot be expected that they * If consoles are suspended, it cannot be expected that they
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment