Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

doc: Update list_for_each_entry_rcu() documentation

This commit updates the documentation with information about
usage of lockdep with list_for_each_entry_rcu().

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
[ paulmck: Wordsmithing. ]
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

authored by

Joel Fernandes (Google) and committed by
Paul E. McKenney
45271064 71cb46ae

+23 -5
+14 -4
Documentation/RCU/lockdep.txt
··· 96 96 to use rcu_dereference_protected() if either the RCU-protected pointer 97 97 or the RCU-protected data that it points to can change concurrently. 98 98 99 - There are currently only "universal" versions of the rcu_assign_pointer() 100 - and RCU list-/tree-traversal primitives, which do not (yet) check for 101 - being in an RCU read-side critical section. In the future, separate 102 - versions of these primitives might be created. 99 + Like rcu_dereference(), when lockdep is enabled, RCU list and hlist 100 + traversal primitives check for being called from within an RCU read-side 101 + critical section. However, a lockdep expression can be passed to them 102 + as a additional optional argument. With this lockdep expression, these 103 + traversal primitives will complain only if the lockdep expression is 104 + false and they are called from outside any RCU read-side critical section. 105 + 106 + For example, the workqueue for_each_pwq() macro is intended to be used 107 + either within an RCU read-side critical section or with wq->mutex held. 108 + It is thus implemented as follows: 109 + 110 + #define for_each_pwq(pwq, wq) 111 + list_for_each_entry_rcu((pwq), &(wq)->pwqs, pwqs_node, 112 + lock_is_held(&(wq->mutex).dep_map))
+9 -1
Documentation/RCU/whatisRCU.txt
··· 290 290 at any time, including immediately after the rcu_dereference(). 291 291 And, again like rcu_assign_pointer(), rcu_dereference() is 292 292 typically used indirectly, via the _rcu list-manipulation 293 - primitives, such as list_for_each_entry_rcu(). 293 + primitives, such as list_for_each_entry_rcu() [2]. 294 294 295 295 [1] The variant rcu_dereference_protected() can be used outside 296 296 of an RCU read-side critical section as long as the usage is ··· 304 304 by the caller. If the indicated protection is not provided, 305 305 a lockdep splat is emitted. See Documentation/RCU/Design/Requirements/Requirements.rst 306 306 and the API's code comments for more details and example usage. 307 + 308 + [2] If the list_for_each_entry_rcu() instance might be used by 309 + update-side code as well as by RCU readers, then an additional 310 + lockdep expression can be added to its list of arguments. 311 + For example, given an additional "lock_is_held(&mylock)" argument, 312 + the RCU lockdep code would complain only if this instance was 313 + invoked outside of an RCU read-side critical section and without 314 + the protection of mylock. 307 315 308 316 The following diagram shows how each API communicates among the 309 317 reader, updater, and reclaimer.