Commit c08c68dd authored by David Howells's avatar David Howells Committed by Ingo Molnar

rcu: Better explain the condition parameter of rcu_dereference_check()

Better explain the condition parameter of
rcu_dereference_check() that describes the conditions under
which the dereference is permitted to take place (and
incorporate Yong Zhang's suggestion).  This condition is only
checked under lockdep proving.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: laijs@cn.fujitsu.com
Cc: dipankar@in.ibm.com
Cc: mathieu.desnoyers@polymtl.ca
Cc: josh@joshtriplett.org
Cc: dvhltc@us.ibm.com
Cc: niv@us.ibm.com
Cc: peterz@infradead.org
Cc: rostedt@goodmis.org
Cc: Valdis.Kletnieks@vt.edu
Cc: eric.dumazet@gmail.com
LKML-Reference: <1270852752-25278-2-git-send-email-paulmck@linux.vnet.ibm.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b62730ba
...@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void) ...@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)
/** /**
* rcu_dereference_check - rcu_dereference with debug checking * rcu_dereference_check - rcu_dereference with debug checking
* @p: The pointer to read, prior to dereferencing
* @c: The conditions under which the dereference will take place
* *
* Do an rcu_dereference(), but check that the context is correct. * Do an rcu_dereference(), but check that the conditions under which the
* For example, rcu_dereference_check(gp, rcu_read_lock_held()) to * dereference will take place are correct. Typically the conditions indicate
* ensure that the rcu_dereference_check() executes within an RCU * the various locking conditions that should be held at that point. The check
* read-side critical section. It is also possible to check for * should return true if the conditions are satisfied.
* locks being held, for example, by using lockdep_is_held(). *
* For example:
*
* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() ||
* lockdep_is_held(&foo->lock));
*
* could be used to indicate to lockdep that foo->bar may only be dereferenced
* if either the RCU read lock is held, or that the lock required to replace
* the bar struct at foo->bar is held.
*
* Note that the list of conditions may also include indications of when a lock
* need not be held, for example during initialisation or destruction of the
* target struct:
*
* bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() ||
* lockdep_is_held(&foo->lock) ||
* atomic_read(&foo->usage) == 0);
*/ */
#define rcu_dereference_check(p, c) \ #define rcu_dereference_check(p, c) \
({ \ ({ \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment