From: tip-bot for David Howells <dhowells@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com,
hpa@zytor.com, mingo@redhat.com, dhowells@redhat.com,
tglx@linutronix.de, mingo@elte.hu
Subject: [tip:core/urgent] rcu: Better explain the condition parameter of rcu_dereference_check()
Date: Wed, 14 Apr 2010 15:01:14 GMT [thread overview]
Message-ID: <tip-c08c68dd76bd6b776bc0eb45a5e8f354ed772cdf@git.kernel.org> (raw)
In-Reply-To: <1270852752-25278-2-git-send-email-paulmck@linux.vnet.ibm.com>
Commit-ID: c08c68dd76bd6b776bc0eb45a5e8f354ed772cdf
Gitweb: http://git.kernel.org/tip/c08c68dd76bd6b776bc0eb45a5e8f354ed772cdf
Author: David Howells <dhowells@redhat.com>
AuthorDate: Fri, 9 Apr 2010 15:39:11 -0700
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 14 Apr 2010 12:20:04 +0200
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>
---
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 8fe8660..9f1ddfe 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -195,12 +195,30 @@ static inline int rcu_read_lock_sched_held(void)
/**
* 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.
- * For example, rcu_dereference_check(gp, rcu_read_lock_held()) to
- * ensure that the rcu_dereference_check() executes within an RCU
- * read-side critical section. It is also possible to check for
- * locks being held, for example, by using lockdep_is_held().
+ * Do an rcu_dereference(), but check that the conditions under which the
+ * dereference will take place are correct. Typically the conditions indicate
+ * the various locking conditions that should be held at that point. The check
+ * should return true if the conditions are satisfied.
+ *
+ * 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) \
({ \
next prev parent reply other threads:[~2010-04-14 15:01 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-09 5:47 [PATCH tip/core/urgent] rcu: updates for RCU lockdep Paul E. McKenney
2010-04-09 5:47 ` [PATCH tip/core/urgent 1/4] rcu: add rcu_access_pointer and rcu_dereference_protected Paul E. McKenney
2010-04-09 9:10 ` David Howells
2010-04-09 9:24 ` Eric Dumazet
2010-04-09 16:57 ` Paul E. McKenney
2010-04-12 19:24 ` Josh Triplett
2010-04-12 20:30 ` Arnd Bergmann
2010-04-12 20:52 ` Paul E. McKenney
2010-04-09 16:56 ` Paul E. McKenney
2010-04-09 5:47 ` [PATCH tip/core/urgent 2/4] RCU: Better explain the condition parameter of rcu_dereference_check() Paul E. McKenney
2010-04-09 9:11 ` David Howells
2010-04-09 5:47 ` [PATCH tip/core/urgent 3/4] rcu: Update docs for rcu_access_pointer and rcu_dereference_protected Paul E. McKenney
2010-04-09 9:16 ` David Howells
2010-04-09 5:47 ` [PATCH tip/core/urgent 4/4] rcu: fix syntax error in rcu_dereference_check() example in comment Paul E. McKenney
2010-04-09 9:17 ` David Howells
2010-04-09 16:59 ` Paul E. McKenney
2010-04-09 8:59 ` [PATCH tip/core/urgent] rcu: updates for RCU lockdep Lai Jiangshan
2010-04-09 22:38 ` [PATCH tip/core/urgent] v2 " Paul E. McKenney
2010-04-09 22:39 ` [PATCH tip/core/urgent 1/3] rcu: add rcu_access_pointer and rcu_dereference_protected Paul E. McKenney
2010-04-10 6:03 ` Eric Dumazet
2010-04-10 8:13 ` David Howells
2010-04-14 15:00 ` [tip:core/urgent] rcu: Add " tip-bot for Paul E. McKenney
2010-04-09 22:39 ` [PATCH tip/core/urgent 2/3] RCU: Better explain the condition parameter of rcu_dereference_check() Paul E. McKenney
2010-04-14 15:01 ` tip-bot for David Howells [this message]
2010-04-09 22:39 ` [PATCH tip/core/urgent 3/3] rcu: Update docs for rcu_access_pointer and rcu_dereference_protected Paul E. McKenney
2010-04-14 15:01 ` [tip:core/urgent] " tip-bot for Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-c08c68dd76bd6b776bc0eb45a5e8f354ed772cdf@git.kernel.org \
--to=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox