• Madhuparna Bhowmik's avatar
    rculist: Introduce list/hlist_for_each_entry_srcu() macros · ae2212a7
    Madhuparna Bhowmik authored
    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: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Tested-by: default avatarSuraj Upadhyay <usuraj35@gmail.com>
    Tested-by: default avatarNaresh Kamboju <naresh.kamboju@linaro.org>
    [ paulmck: Add "true" per kbuild test robot feedback. ]
    Signed-off-by: default avatarMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
    Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
    ae2212a7
rculist.h 28.5 KB