Blame view

Documentation/RCU/rcu.txt 3.95 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  RCU Concepts
  
  
  The basic idea behind RCU (read-copy update) is to split destructive
  operations into two parts, one that prevents anyone from seeing the data
  item being destroyed, and one that actually carries out the destruction.
  A "grace period" must elapse between the two parts, and this grace period
  must be long enough that any readers accessing the item being deleted have
  since dropped their references.  For example, an RCU-protected deletion
  from a linked list would first remove the item from the list, wait for
  a grace period to elapse, then free the element.  See the listRCU.txt
  file for more information on using RCU with linked lists.
  
  
  Frequently Asked Questions
  
  o	Why would anyone want to use RCU?
  
  	The advantage of RCU's two-part approach is that RCU readers need
  	not acquire any locks, perform any atomic instructions, write to
  	shared memory, or (on CPUs other than Alpha) execute any memory
  	barriers.  The fact that these operations are quite expensive
  	on modern CPUs is what gives RCU its performance advantages
  	in read-mostly situations.  The fact that RCU readers need not
  	acquire locks can also greatly simplify deadlock-avoidance code.
  
  o	How can the updater tell when a grace period has completed
  	if the RCU readers give no indication when they are done?
  
  	Just as with spinlocks, RCU readers are not permitted to
  	block, switch to user-mode execution, or enter the idle loop.
  	Therefore, as soon as a CPU is seen passing through any of these
  	three states, we know that that CPU has exited any previous RCU
  	read-side critical sections.  So, if we remove an item from a
  	linked list, and then wait until all CPUs have switched context,
  	executed in user mode, or executed in the idle loop, we can
  	safely free up that item.
6b3ef48ad   Paul E. McKenney   rcu: Remove CONFI...
38
  	Preemptible variants of RCU (CONFIG_TREE_PREEMPT_RCU) get the
f85d6c716   Paul E. McKenney   Preempt-RCU: upda...
39
  	same effect, but require that the readers manipulate CPU-local
9ceae0e24   Paul E. McKenney   rcu: Add document...
40
41
42
43
44
  	counters.  These counters allow limited types of blocking within
  	RCU read-side critical sections.  SRCU also uses CPU-local
  	counters, and permits general blocking within RCU read-side
  	critical sections.  These variants of RCU detect grace periods
  	by sampling these counters.
f85d6c716   Paul E. McKenney   Preempt-RCU: upda...
45

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
46
47
48
49
50
51
  o	If I am running on a uniprocessor kernel, which can only do one
  	thing at a time, why should I wait for a grace period?
  
  	See the UP.txt file in this directory.
  
  o	How can I see where RCU is currently used in the Linux kernel?
a83f1fe27   Paul E. McKenney   [PATCH] Update RC...
52
53
  	Search for "rcu_read_lock", "rcu_read_unlock", "call_rcu",
  	"rcu_read_lock_bh", "rcu_read_unlock_bh", "call_rcu_bh",
621934ee7   Paul E. McKenney   [PATCH] srcu-3: R...
54
  	"srcu_read_lock", "srcu_read_unlock", "synchronize_rcu",
f85d6c716   Paul E. McKenney   Preempt-RCU: upda...
55
56
57
58
  	"synchronize_net", "synchronize_srcu", and the other RCU
  	primitives.  Or grab one of the cscope databases from:
  
  	http://www.rdrop.com/users/paulmck/RCU/linuxusage/rculocktab.html
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  
  o	What guidelines should I follow when writing code that uses RCU?
  
  	See the checklist.txt file in this directory.
  
  o	Why the name "RCU"?
  
  	"RCU" stands for "read-copy update".  The file listRCU.txt has
  	more information on where this name came from, search for
  	"read-copy update" to find it.
  
  o	I hear that RCU is patented?  What is with that?
  
  	Yes, it is.  There are several known patents related to RCU,
  	search for the string "Patent" in RTFP.txt to find them.
  	Of these, one was allowed to lapse by the assignee, and the
  	others have been contributed to the Linux kernel under GPL.
4c54005ca   Paul E. McKenney   rcu: 1Q2010 updat...
76
77
  	There are now also LGPL implementations of user-level RCU
  	available (http://lttng.org/?q=node/18).
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78

dd81eca83   Paul E. McKenney   [PATCH] Yet anoth...
79
  o	I hear that RCU needs work in order to support realtime kernels?
f85d6c716   Paul E. McKenney   Preempt-RCU: upda...
80
  	This work is largely completed.  Realtime-friendly RCU can be
6b3ef48ad   Paul E. McKenney   rcu: Remove CONFI...
81
82
83
84
  	enabled via the CONFIG_TREE_PREEMPT_RCU kernel configuration
  	parameter.  However, work is in progress for enabling priority
  	boosting of preempted RCU read-side critical sections.	This is
  	needed if you have CPU-bound realtime threads.
dd81eca83   Paul E. McKenney   [PATCH] Yet anoth...
85

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
88
  o	Where can I find more information on RCU?
  
  	See the RTFP.txt file in this directory.
dd81eca83   Paul E. McKenney   [PATCH] Yet anoth...
89
90
91
  	Or point your browser at http://www.rdrop.com/users/paulmck/RCU/.
  
  o	What are all these files in this directory?
4c54005ca   Paul E. McKenney   rcu: 1Q2010 updat...
92
  	See 00-INDEX for the list.