Re: [PATCH printk v3 03/15] printk: add missing memory barrier to wake_up_klogd()

Petr Mladek
2022-04-20T12:34:59Z

On Wed 2022-04-20 01:52:25, John Ogness wrote:
> It is important that any new records are visible to preparing
> waiters before the waker checks if the wait queue is empty.
> Otherwise it is possible that:
>
> - there are new records available
> - the waker sees an empty wait queue and does not wake
> - the preparing waiter sees no new records and begins to wait
>
> This is exactly the problem that the function description of
> waitqueue_active() warns about.
>
> Use wq_has_sleeper() instead of waitqueue_active() because it
> includes the necessary full memory barrier.
>
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Great catch! Looks good to me.

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr