aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/RCU/00-INDEX2
-rw-r--r--Documentation/RCU/checklist.txt34
-rw-r--r--Documentation/RCU/lockdep.txt67
-rw-r--r--Documentation/RCU/whatisRCU.txt13
4 files changed, 97 insertions, 19 deletions
diff --git a/Documentation/RCU/00-INDEX b/Documentation/RCU/00-INDEX
index 0a27ea9621fa..71b6f500ddb9 100644
--- a/Documentation/RCU/00-INDEX
+++ b/Documentation/RCU/00-INDEX
@@ -6,6 +6,8 @@ checklist.txt
6 - Review Checklist for RCU Patches 6 - Review Checklist for RCU Patches
7listRCU.txt 7listRCU.txt
8 - Using RCU to Protect Read-Mostly Linked Lists 8 - Using RCU to Protect Read-Mostly Linked Lists
9lockdep.txt
10 - RCU and lockdep checking
9NMI-RCU.txt 11NMI-RCU.txt
10 - Using RCU to Protect Dynamic NMI Handlers 12 - Using RCU to Protect Dynamic NMI Handlers
11rcubarrier.txt 13rcubarrier.txt
diff --git a/Documentation/RCU/checklist.txt b/Documentation/RCU/checklist.txt
index 767cf06a4276..cbc180f90194 100644
--- a/Documentation/RCU/checklist.txt
+++ b/Documentation/RCU/checklist.txt
@@ -127,10 +127,14 @@ over a rather long period of time, but improvements are always welcome!
127 perfectly legal (if redundant) for update-side code to 127 perfectly legal (if redundant) for update-side code to
128 use rcu_dereference() and the "_rcu()" list-traversal 128 use rcu_dereference() and the "_rcu()" list-traversal
129 primitives. This is particularly useful in code that 129 primitives. This is particularly useful in code that
130 is common to readers and updaters. However, neither 130 is common to readers and updaters. However, lockdep
131 rcu_dereference() nor the "_rcu()" list-traversal 131 will complain if you access rcu_dereference() outside
132 primitives can substitute for a good concurrency design 132 of an RCU read-side critical section. See lockdep.txt
133 coordinating among multiple updaters. 133 to learn what to do about this.
134
135 Of course, neither rcu_dereference() nor the "_rcu()"
136 list-traversal primitives can substitute for a good
137 concurrency design coordinating among multiple updaters.
134 138
135 b. If the list macros are being used, the list_add_tail_rcu() 139 b. If the list macros are being used, the list_add_tail_rcu()
136 and list_add_rcu() primitives must be used in order 140 and list_add_rcu() primitives must be used in order
@@ -249,7 +253,9 @@ over a rather long period of time, but improvements are always welcome!
249 must be protected by appropriate update-side locks. RCU 253 must be protected by appropriate update-side locks. RCU
250 read-side critical sections are delimited by rcu_read_lock() 254 read-side critical sections are delimited by rcu_read_lock()
251 and rcu_read_unlock(), or by similar primitives such as 255 and rcu_read_unlock(), or by similar primitives such as
252 rcu_read_lock_bh() and rcu_read_unlock_bh(). 256 rcu_read_lock_bh() and rcu_read_unlock_bh(), in which case
257 the matching rcu_dereference() primitive must be used in order
258 to keep lockdep happy, in this case, rcu_dereference_bh().
253 259
254 The reason that it is permissible to use RCU list-traversal 260 The reason that it is permissible to use RCU list-traversal
255 primitives when the update-side lock is held is that doing so 261 primitives when the update-side lock is held is that doing so
@@ -302,15 +308,15 @@ over a rather long period of time, but improvements are always welcome!
302 not the case, a self-spawning RCU callback would prevent the 308 not the case, a self-spawning RCU callback would prevent the
303 victim CPU from ever going offline.) 309 victim CPU from ever going offline.)
304 310
30514. SRCU (srcu_read_lock(), srcu_read_unlock(), synchronize_srcu(), 31114. SRCU (srcu_read_lock(), srcu_read_unlock(), srcu_dereference(),
306 and synchronize_srcu_expedited()) may only be invoked from 312 synchronize_srcu(), and synchronize_srcu_expedited()) may only
307 process context. Unlike other forms of RCU, it -is- permissible 313 be invoked from process context. Unlike other forms of RCU, it
308 to block in an SRCU read-side critical section (demarked by 314 -is- permissible to block in an SRCU read-side critical section
309 srcu_read_lock() and srcu_read_unlock()), hence the "SRCU": 315 (demarked by srcu_read_lock() and srcu_read_unlock()), hence the
310 "sleepable RCU". Please note that if you don't need to sleep 316 "SRCU": "sleepable RCU". Please note that if you don't need
311 in read-side critical sections, you should be using RCU rather 317 to sleep in read-side critical sections, you should be using
312 than SRCU, because RCU is almost always faster and easier to 318 RCU rather than SRCU, because RCU is almost always faster and
313 use than is SRCU. 319 easier to use than is SRCU.
314 320
315 Also unlike other forms of RCU, explicit initialization 321 Also unlike other forms of RCU, explicit initialization
316 and cleanup is required via init_srcu_struct() and 322 and cleanup is required via init_srcu_struct() and
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.
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index 469a58b2e67e..1dc00ee97163 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -323,15 +323,17 @@ used as follows:
323 Defer Protect 323 Defer Protect
324 324
325a. synchronize_rcu() rcu_read_lock() / rcu_read_unlock() 325a. synchronize_rcu() rcu_read_lock() / rcu_read_unlock()
326 call_rcu() 326 call_rcu() rcu_dereference()
327 327
328b. call_rcu_bh() rcu_read_lock_bh() / rcu_read_unlock_bh() 328b. call_rcu_bh() rcu_read_lock_bh() / rcu_read_unlock_bh()
329 rcu_dereference_bh()
329 330
330c. synchronize_sched() rcu_read_lock_sched() / rcu_read_unlock_sched() 331c. synchronize_sched() rcu_read_lock_sched() / rcu_read_unlock_sched()
331 preempt_disable() / preempt_enable() 332 preempt_disable() / preempt_enable()
332 local_irq_save() / local_irq_restore() 333 local_irq_save() / local_irq_restore()
333 hardirq enter / hardirq exit 334 hardirq enter / hardirq exit
334 NMI enter / NMI exit 335 NMI enter / NMI exit
336 rcu_dereference_sched()
335 337
336These three mechanisms are used as follows: 338These three mechanisms are used as follows:
337 339
@@ -781,9 +783,8 @@ Linux-kernel source code, but it helps to have a full list of the
781APIs, since there does not appear to be a way to categorize them 783APIs, since there does not appear to be a way to categorize them
782in docbook. Here is the list, by category. 784in docbook. Here is the list, by category.
783 785
784RCU pointer/list traversal: 786RCU list traversal:
785 787
786 rcu_dereference
787 list_for_each_entry_rcu 788 list_for_each_entry_rcu
788 hlist_for_each_entry_rcu 789 hlist_for_each_entry_rcu
789 hlist_nulls_for_each_entry_rcu 790 hlist_nulls_for_each_entry_rcu
@@ -809,7 +810,7 @@ RCU: Critical sections Grace period Barrier
809 810
810 rcu_read_lock synchronize_net rcu_barrier 811 rcu_read_lock synchronize_net rcu_barrier
811 rcu_read_unlock synchronize_rcu 812 rcu_read_unlock synchronize_rcu
812 synchronize_rcu_expedited 813 rcu_dereference synchronize_rcu_expedited
813 call_rcu 814 call_rcu
814 815
815 816
@@ -817,7 +818,7 @@ bh: Critical sections Grace period Barrier
817 818
818 rcu_read_lock_bh call_rcu_bh rcu_barrier_bh 819 rcu_read_lock_bh call_rcu_bh rcu_barrier_bh
819 rcu_read_unlock_bh synchronize_rcu_bh 820 rcu_read_unlock_bh synchronize_rcu_bh
820 synchronize_rcu_bh_expedited 821 rcu_dereference_bh synchronize_rcu_bh_expedited
821 822
822 823
823sched: Critical sections Grace period Barrier 824sched: Critical sections Grace period Barrier
@@ -826,12 +827,14 @@ sched: Critical sections Grace period Barrier
826 rcu_read_unlock_sched call_rcu_sched 827 rcu_read_unlock_sched call_rcu_sched
827 [preempt_disable] synchronize_sched_expedited 828 [preempt_disable] synchronize_sched_expedited
828 [and friends] 829 [and friends]
830 rcu_dereference_sched
829 831
830 832
831SRCU: Critical sections Grace period Barrier 833SRCU: Critical sections Grace period Barrier
832 834
833 srcu_read_lock synchronize_srcu N/A 835 srcu_read_lock synchronize_srcu N/A
834 srcu_read_unlock synchronize_srcu_expedited 836 srcu_read_unlock synchronize_srcu_expedited
837 srcu_dereference
835 838
836SRCU: Initialization/cleanup 839SRCU: Initialization/cleanup
837 init_srcu_struct 840 init_srcu_struct