rcu: Add srcu_down_read() and srcu_up_read()
authorPaul E. McKenney <paulmck@kernel.org>
Wed, 23 Nov 2022 23:49:55 +0000 (15:49 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 4 Jan 2023 01:49:22 +0000 (17:49 -0800)
commit0b1182bde303dc476ea9712c2c816be2e4f0cf81
treea02440ff1c4da06ec46f45b3505c8bb4de3e2366
parent50be0c0439fc1d8bda733ff26f6526e49970857a
rcu: Add srcu_down_read() and srcu_up_read()

A pair of matching srcu_read_lock() and srcu_read_unlock() invocations
must take place within the same context, for example, within the same
task.  Otherwise, lockdep complains, as is the right thing to do for
most use cases.

However, there are use cases involving asynchronous I/O where the
SRCU reader needs to begin on one task and end on another.  This commit
therefore supplies the semaphore-like srcu_down_read() and srcu_up_read(),
which act like srcu_read_lock() and srcu_read_unlock(), but permitting
srcu_up_read() to be invoked in a different context than was the matching
srcu_down_read().

Neither srcu_down_read() nor srcu_up_read() may be invoked from an
NMI handler.

Reported-by: Jan Kara <jack@suse.cz>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Tested-by: Amir Goldstein <amir73il@gmail.com>
include/linux/srcu.h