diff options
author | David Howells <dhowells@redhat.com> | 2010-04-09 18:39:11 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-04-14 06:20:04 -0400 |
commit | c08c68dd76bd6b776bc0eb45a5e8f354ed772cdf (patch) | |
tree | 5324c73474b1e73631392de814e8ecebd5956d5b /include/linux/rcupdate.h | |
parent | b62730baea32f86fe91a7930e4b7ee8d82778b79 (diff) |
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: David Howells <dhowells@redhat.com>
Signed-off-by: Paul 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: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/rcupdate.h')
-rw-r--r-- | include/linux/rcupdate.h | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 8fe86609441f..9f1ddfef84b5 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void) | |||
195 | 195 | ||
196 | /** | 196 | /** |
197 | * rcu_dereference_check - rcu_dereference with debug checking | 197 | * rcu_dereference_check - rcu_dereference with debug checking |
198 | * @p: The pointer to read, prior to dereferencing | ||
199 | * @c: The conditions under which the dereference will take place | ||
198 | * | 200 | * |
199 | * Do an rcu_dereference(), but check that the context is correct. | 201 | * Do an rcu_dereference(), but check that the conditions under which the |
200 | * For example, rcu_dereference_check(gp, rcu_read_lock_held()) to | 202 | * dereference will take place are correct. Typically the conditions indicate |
201 | * ensure that the rcu_dereference_check() executes within an RCU | 203 | * the various locking conditions that should be held at that point. The check |
202 | * read-side critical section. It is also possible to check for | 204 | * should return true if the conditions are satisfied. |
203 | * locks being held, for example, by using lockdep_is_held(). | 205 | * |
206 | * For example: | ||
207 | * | ||
208 | * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || | ||
209 | * lockdep_is_held(&foo->lock)); | ||
210 | * | ||
211 | * could be used to indicate to lockdep that foo->bar may only be dereferenced | ||
212 | * if either the RCU read lock is held, or that the lock required to replace | ||
213 | * the bar struct at foo->bar is held. | ||
214 | * | ||
215 | * Note that the list of conditions may also include indications of when a lock | ||
216 | * need not be held, for example during initialisation or destruction of the | ||
217 | * target struct: | ||
218 | * | ||
219 | * bar = rcu_dereference_check(foo->bar, rcu_read_lock_held() || | ||
220 | * lockdep_is_held(&foo->lock) || | ||
221 | * atomic_read(&foo->usage) == 0); | ||
204 | */ | 222 | */ |
205 | #define rcu_dereference_check(p, c) \ | 223 | #define rcu_dereference_check(p, c) \ |
206 | ({ \ | 224 | ({ \ |