Re: [PATCH printk v3 03/15] printk: add missing memory barrier to wake_up_klogd()
From: Petr Mladek
Date: Wed Apr 20 2022 - 08:34:59 EST
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@xxxxxxxxxxxxx>
Great catch! Looks good to me.
Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
Best Regards,
Petr