Skip to content

Commit 12f1da5

Browse files
jognesspmladek
authored andcommitted
printk: console_is_usable: use console_srcu_read_flags
All users of console_is_usable() are SRCU iterators. Use the appropriate wrapper function to locklessly read the flags. 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-18-john.ogness@linutronix.de
1 parent eb7f1ed commit 12f1da5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

kernel/printk/printk.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,11 +2709,13 @@ static bool abandon_console_lock_in_panic(void)
27092709
* Check if the given console is currently capable and allowed to print
27102710
* records.
27112711
*
2712-
* Requires the console_lock.
2712+
* Requires the console_srcu_read_lock.
27132713
*/
27142714
static inline bool console_is_usable(struct console *con)
27152715
{
2716-
if (!(con->flags & CON_ENABLED))
2716+
short flags = console_srcu_read_flags(con);
2717+
2718+
if (!(flags & CON_ENABLED))
27172719
return false;
27182720

27192721
if (!con->write)
@@ -2724,8 +2726,7 @@ static inline bool console_is_usable(struct console *con)
27242726
* allocated. So unless they're explicitly marked as being able to
27252727
* cope (CON_ANYTIME) don't call them until this CPU is officially up.
27262728
*/
2727-
if (!cpu_online(raw_smp_processor_id()) &&
2728-
!(con->flags & CON_ANYTIME))
2729+
if (!cpu_online(raw_smp_processor_id()) && !(flags & CON_ANYTIME))
27292730
return false;
27302731

27312732
return true;

0 commit comments

Comments
 (0)