]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
printk: add missing memory barrier to wake_up_klogd()
authorJohn Ogness <john.ogness@linutronix.de>
Thu, 21 Apr 2022 21:22:38 +0000 (23:28 +0206)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:24:11 +0000 (09:24 +0200)
commite6380047eb519dced5396fc1a37da6e44afcb554
treec6109ec113a06a734c55826f88ac9ac1ce05190f
parenta4c0eb1c3b05af88c78cfe4010627a8c48cd9545
printk: add missing memory barrier to wake_up_klogd()

BugLink: https://bugs.launchpad.net/bugs/1981864
[ Upstream commit 1f5d783094cf28b4905f51cad846eb5d1db6673e ]

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>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220421212250.565456-4-john.ogness@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
kernel/printk/printk.c