Re: [PATCH v2] printk: defer_console_output: use atomic update

From: Petr Mladek
Date: Thu Feb 10 2022 - 10:47:49 EST


On Mon 2022-02-07 10:52:20, John Ogness wrote:
> The per-cpu @printk_pending variable can be updated from
> sleepable contexts, such as:
>
> get_random_bytes()
> warn_unseeded_randomness()
> printk_deferred()
> defer_console_output()
>
> and can be updated from interrupt contexts, such as:
>
> handle_irq_event_percpu()
> __irq_wake_thread()
> wake_up_process()
> try_to_wake_up()
> select_task_rq()
> select_fallback_rq()
> printk_deferred()
> defer_console_output()
>
> and can be updated from NMI contexts, such as:
>
> vprintk()
> if (in_nmi()) defer_console_output()
>
> Therefore this_cpu_or(), the atomic variant of __this_cpu_or(),
> should be used to update the variable.
>
> Reported-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> Reviewed-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
> Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>

Makes sense.

The patch has been committed into printk/linux.git, branch for-5.18.

Best Regards,
Petr