rculist: Introduce list/hlist_for_each_entry_srcu() macros
authorMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Sun, 12 Jul 2020 13:10:02 +0000 (18:40 +0530)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 25 Aug 2020 01:36:09 +0000 (18:36 -0700)
commitae2212a7216b674633bdc3bd2e24947a0665efb8
tree23dceea5d4ca94c09628cec9434fd365873b405d
parent000601bb62330f18dc8f5d2d0b82e9aec3e207c4
rculist: Introduce list/hlist_for_each_entry_srcu() macros

list/hlist_for_each_entry_rcu() provides an optional cond argument
to specify the lock held in the updater side.
However for SRCU read side, not providing the cond argument results
into false positive as whether srcu_read_lock is held or not is not
checked implicitly. Therefore, on read side the lockdep expression
srcu_read_lock_held(srcu struct) can solve this issue.

However, the function still fails to check the cases where srcu
protected list is traversed with rcu_read_lock() instead of
srcu_read_lock(). Therefore, to remove the false negative,
this patch introduces two new list traversal primitives :
list_for_each_entry_srcu() and hlist_for_each_entry_srcu().

Both of the functions have non-optional cond argument
as it is required for both read and update side, and simply checks
if the cond is true. For regular read side the lockdep expression
srcu_read_lock_head() can be passed as the cond argument to
list/hlist_for_each_entry_srcu().

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Tested-by: Suraj Upadhyay <usuraj35@gmail.com>
Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org>
[ paulmck: Add "true" per kbuild test robot feedback. ]
Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
include/linux/rculist.h