um: kmsg_dumper: use srcu console list iterator
Rather than using the console_lock to guarantee safe console list traversal, use srcu console list iteration. 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-14-john.ogness@linutronix.de
This commit is contained in:
parent
100bdef2c1
commit
12335446e0
|
@ -16,29 +16,26 @@ static void kmsg_dumper_stdout(struct kmsg_dumper *dumper,
|
||||||
struct console *con;
|
struct console *con;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
int cookie;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If no consoles are available to output crash information, dump
|
* If no consoles are available to output crash information, dump
|
||||||
* the kmsg buffer to stdout.
|
* the kmsg buffer to stdout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!console_trylock())
|
cookie = console_srcu_read_lock();
|
||||||
return;
|
for_each_console_srcu(con) {
|
||||||
|
|
||||||
for_each_console(con) {
|
|
||||||
/*
|
/*
|
||||||
* The ttynull console and disabled consoles are ignored
|
* The ttynull console and disabled consoles are ignored
|
||||||
* since they cannot output. All other consoles are
|
* since they cannot output. All other consoles are
|
||||||
* expected to output the crash information.
|
* expected to output the crash information.
|
||||||
*/
|
*/
|
||||||
if (strcmp(con->name, "ttynull") != 0 &&
|
if (strcmp(con->name, "ttynull") != 0 &&
|
||||||
(con->flags & CON_ENABLED)) {
|
(console_srcu_read_flags(con) & CON_ENABLED)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console_srcu_read_unlock(cookie);
|
||||||
console_unlock();
|
|
||||||
|
|
||||||
if (con)
|
if (con)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue