aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/RCU/lockdep.txt
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@linux.vnet.ibm.com>2010-02-22 20:04:57 -0500
committerIngo Molnar <mingo@elte.hu>2010-02-25 04:34:53 -0500
commitc598a070bc581aea8a518b460dae8c0cf8e74344 (patch)
treea74f0323a7432ff836901ca301ca11870d73f940 /Documentation/RCU/lockdep.txt
parente7b0a61b7929632d36cf052d9e2820ef0a9c1bfe (diff)
rcu: Documentation update for CONFIG_PROVE_RCU
Adds a lockdep.txt file and updates checklist.txt and whatisRCU.txt to reflect the new lockdep-enabled capabilities of RCU. 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: dhowells@redhat.com LKML-Reference: <1266887105-1528-13-git-send-email-paulmck@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/RCU/lockdep.txt')
-rw-r--r--Documentation/RCU/lockdep.txt67
1 files changed, 67 insertions, 0 deletions
diff --git a/Documentation/RCU/lockdep.txt b/Documentation/RCU/lockdep.txt
new file mode 100644
index 000000000000..fe24b58627bd
--- /dev/null
+++ b/Documentation/RCU/lockdep.txt
@@ -0,0 +1,67 @@
1RCU and lockdep checking
2
3All flavors of RCU have lockdep checking available, so that lockdep is
4aware of when each task enters and leaves any flavor of RCU read-side
5critical section. Each flavor of RCU is tracked separately (but note
6that this is not the case in 2.6.32 and earlier). This allows lockdep's
7tracking to include RCU state, which can sometimes help when debugging
8deadlocks and the like.
9
10In addition, RCU provides the following primitives that check lockdep's
11state:
12
13 rcu_read_lock_held() for normal RCU.
14 rcu_read_lock_bh_held() for RCU-bh.
15 rcu_read_lock_sched_held() for RCU-sched.
16 srcu_read_lock_held() for SRCU.
17
18These functions are conservative, and will therefore return 1 if they
19aren't certain (for example, if CONFIG_DEBUG_LOCK_ALLOC is not set).
20This prevents things like WARN_ON(!rcu_read_lock_held()) from giving false
21positives when lockdep is disabled.
22
23In addition, a separate kernel config parameter CONFIG_PROVE_RCU enables
24checking of rcu_dereference() primitives:
25
26 rcu_dereference(p):
27 Check for RCU read-side critical section.
28 rcu_dereference_bh(p):
29 Check for RCU-bh read-side critical section.
30 rcu_dereference_sched(p):
31 Check for RCU-sched read-side critical section.
32 srcu_dereference(p, sp):
33 Check for SRCU read-side critical section.
34 rcu_dereference_check(p, c):
35 Use explicit check expression "c".
36 rcu_dereference_raw(p)
37 Don't check. (Use sparingly, if at all.)
38
39The rcu_dereference_check() check expression can be any boolean
40expression, but would normally include one of the rcu_read_lock_held()
41family of functions and a lockdep expression. However, any boolean
42expression can be used. For a moderately ornate example, consider
43the following:
44
45 file = rcu_dereference_check(fdt->fd[fd],
46 rcu_read_lock_held() ||
47 lockdep_is_held(&files->file_lock) ||
48 atomic_read(&files->count) == 1);
49
50This expression picks up the pointer "fdt->fd[fd]" in an RCU-safe manner,
51and, if CONFIG_PROVE_RCU is configured, verifies that this expression
52is used in:
53
541. An RCU read-side critical section, or
552. with files->file_lock held, or
563. on an unshared files_struct.
57
58In case (1), the pointer is picked up in an RCU-safe manner for vanilla
59RCU read-side critical sections, in case (2) the ->file_lock prevents
60any change from taking place, and finally, in case (3) the current task
61is the only task accessing the file_struct, again preventing any change
62from taking place.
63
64There are currently only "universal" versions of the rcu_assign_pointer()
65and RCU list-/tree-traversal primitives, which do not (yet) check for
66being in an RCU read-side critical section. In the future, separate
67versions of these primitives might be created.