]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
sched: Add test_and_clear_wake_up_bit() and atomic_dec_and_wake_up()
authorNeilBrown <neilb@suse.de>
Wed, 25 Sep 2024 05:31:41 +0000 (15:31 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:05:09 +0000 (12:05 +0200)
commitd7ec1be816b78278841840911f70dd4dffa509ae
treeb31ca3a97a882d34fbfb4d04b35726b175faa575
parent25e6b2222e3093d5e68e58365762f1d233bc0fe7
sched: Add test_and_clear_wake_up_bit() and atomic_dec_and_wake_up()

[ Upstream commit 52d633def56c10fe3e82a2c5d88c3ecb3f4e4852 ]

There are common patterns in the kernel of using test_and_clear_bit()
before wake_up_bit(), and atomic_dec_and_test() before wake_up_var().

These combinations don't need extra barriers but sometimes include them
unnecessarily.

To help avoid the unnecessary barriers and to help discourage the
general use of wake_up_bit/var (which is a fragile interface) introduce
two combined functions which implement these patterns.

Also add store_release_wake_up() which supports the task of simply
setting a non-atomic variable and sending a wakeup.  This pattern
requires barriers which are often omitted.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240925053405.3960701-5-neilb@suse.de
Stable-dep-of: 1db3a48e83bb ("NFS: Fix wakeup of __nfs_lookup_revalidate() in unblock_revalidate()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/wait_bit.h