87d2128ea03f2410c08f62ae39fc1827eb2ac996
2 * Read-Copy Update mechanism for mutual exclusion
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * Copyright IBM Corporation, 2001
20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
22 * Based on the original work by Paul McKenney <paulmck@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
28 * For detailed explanation of Read-Copy Update mechanism see -
29 * http://lse.sourceforge.net/locking/rcupdate.html
33 #ifndef __LINUX_RCUPDATE_H
34 #define __LINUX_RCUPDATE_H
36 //ust// #include <linux/cache.h>
37 //ust// #include <linux/spinlock.h>
38 //ust// #include <linux/threads.h>
39 //ust// #include <linux/percpu.h>
40 //ust// #include <linux/cpumask.h>
41 //ust// #include <linux/seqlock.h>
42 //ust// #include <linux/lockdep.h>
43 //ust// #include <linux/completion.h>
46 * struct rcu_head - callback structure for use with RCU
47 * @next: next update requests in a list
48 * @func: actual update function to call after the grace period.
51 struct rcu_head
*next
;
52 void (*func
)(struct rcu_head
*head
);
55 //ust// #if defined(CONFIG_CLASSIC_RCU)
56 //ust// #include <linux/rcuclassic.h>
57 //ust// #elif defined(CONFIG_TREE_RCU)
58 //ust// #include <linux/rcutree.h>
59 //ust// #elif defined(CONFIG_PREEMPT_RCU)
60 //ust// #include <linux/rcupreempt.h>
62 //ust// #error "Unknown RCU implementation specified to kernel configuration"
63 //ust// #endif /* #else #if defined(CONFIG_CLASSIC_RCU) */
65 //ust// #define RCU_HEAD_INIT { .next = NULL, .func = NULL }
66 //ust// #define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
67 //ust// #define INIT_RCU_HEAD(ptr) do { \
68 //ust// (ptr)->next = NULL; (ptr)->func = NULL; \
72 //ust// * rcu_read_lock - mark the beginning of an RCU read-side critical section.
74 //ust// * When synchronize_rcu() is invoked on one CPU while other CPUs
75 //ust// * are within RCU read-side critical sections, then the
76 //ust// * synchronize_rcu() is guaranteed to block until after all the other
77 //ust// * CPUs exit their critical sections. Similarly, if call_rcu() is invoked
78 //ust// * on one CPU while other CPUs are within RCU read-side critical
79 //ust// * sections, invocation of the corresponding RCU callback is deferred
80 //ust// * until after the all the other CPUs exit their critical sections.
82 //ust// * Note, however, that RCU callbacks are permitted to run concurrently
83 //ust// * with RCU read-side critical sections. One way that this can happen
84 //ust// * is via the following sequence of events: (1) CPU 0 enters an RCU
85 //ust// * read-side critical section, (2) CPU 1 invokes call_rcu() to register
86 //ust// * an RCU callback, (3) CPU 0 exits the RCU read-side critical section,
87 //ust// * (4) CPU 2 enters a RCU read-side critical section, (5) the RCU
88 //ust// * callback is invoked. This is legal, because the RCU read-side critical
89 //ust// * section that was running concurrently with the call_rcu() (and which
90 //ust// * therefore might be referencing something that the corresponding RCU
91 //ust// * callback would free up) has completed before the corresponding
92 //ust// * RCU callback is invoked.
94 //ust// * RCU read-side critical sections may be nested. Any deferred actions
95 //ust// * will be deferred until the outermost RCU read-side critical section
98 //ust// * It is illegal to block while in an RCU read-side critical section.
100 //ust// #define rcu_read_lock() __rcu_read_lock()
103 //ust// * rcu_read_unlock - marks the end of an RCU read-side critical section.
105 //ust// * See rcu_read_lock() for more information.
109 //ust// * So where is rcu_write_lock()? It does not exist, as there is no
110 //ust// * way for writers to lock out RCU readers. This is a feature, not
111 //ust// * a bug -- this property is what provides RCU's performance benefits.
112 //ust// * Of course, writers must coordinate with each other. The normal
113 //ust// * spinlock primitives work well for this, but any other technique may be
114 //ust// * used as well. RCU does not care how the writers keep out of each
115 //ust// * others' way, as long as they do so.
117 //ust// #define rcu_read_unlock() __rcu_read_unlock()
120 //ust// * rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section
122 //ust// * This is equivalent of rcu_read_lock(), but to be used when updates
123 //ust// * are being done using call_rcu_bh(). Since call_rcu_bh() callbacks
124 //ust// * consider completion of a softirq handler to be a quiescent state,
125 //ust// * a process in RCU read-side critical section must be protected by
126 //ust// * disabling softirqs. Read-side critical sections in interrupt context
127 //ust// * can use just rcu_read_lock().
130 //ust// #define rcu_read_lock_bh() __rcu_read_lock_bh()
133 //ust// * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
135 //ust// * See rcu_read_lock_bh() for more information.
137 //ust// #define rcu_read_unlock_bh() __rcu_read_unlock_bh()
140 //ust// * rcu_read_lock_sched - mark the beginning of a RCU-classic critical section
142 //ust// * Should be used with either
143 //ust// * - synchronize_sched()
145 //ust// * - call_rcu_sched() and rcu_barrier_sched()
146 //ust// * on the write-side to insure proper synchronization.
148 //ust// #define rcu_read_lock_sched() preempt_disable()
149 //ust// #define rcu_read_lock_sched_notrace() preempt_disable_notrace()
152 //ust// * rcu_read_unlock_sched - marks the end of a RCU-classic critical section
154 //ust// * See rcu_read_lock_sched for more information.
156 //ust// #define rcu_read_unlock_sched() preempt_enable()
157 //ust// #define rcu_read_unlock_sched_notrace() preempt_enable_notrace()
162 //ust// * rcu_dereference - fetch an RCU-protected pointer in an
163 //ust// * RCU read-side critical section. This pointer may later
164 //ust// * be safely dereferenced.
166 //ust// * Inserts memory barriers on architectures that require them
167 //ust// * (currently only the Alpha), and, more importantly, documents
168 //ust// * exactly which pointers are protected by RCU.
171 //ust// #define rcu_dereference(p) ({ \
172 //ust// typeof(p) _________p1 = ACCESS_ONCE(p); \
173 //ust// smp_read_barrier_depends(); \
174 //ust// (_________p1); \
178 //ust// * rcu_assign_pointer - assign (publicize) a pointer to a newly
179 //ust// * initialized structure that will be dereferenced by RCU read-side
180 //ust// * critical sections. Returns the value assigned.
182 //ust// * Inserts memory barriers on architectures that require them
183 //ust// * (pretty much all of them other than x86), and also prevents
184 //ust// * the compiler from reordering the code that initializes the
185 //ust// * structure after the pointer assignment. More importantly, this
186 //ust// * call documents which pointers will be dereferenced by RCU read-side
190 //ust// #define rcu_assign_pointer(p, v) \
192 //ust// if (!__builtin_constant_p(v) || \
193 //ust// ((v) != NULL)) \
198 //ust// /* Infrastructure to implement the synchronize_() primitives. */
200 //ust// struct rcu_synchronize {
201 //ust// struct rcu_head head;
202 //ust// struct completion completion;
205 //ust// extern void wakeme_after_rcu(struct rcu_head *head);
208 //ust// * synchronize_sched - block until all CPUs have exited any non-preemptive
209 //ust// * kernel code sequences.
211 //ust// * This means that all preempt_disable code sequences, including NMI and
212 //ust// * hardware-interrupt handlers, in progress on entry will have completed
213 //ust// * before this primitive returns. However, this does not guarantee that
214 //ust// * softirq handlers will have completed, since in some kernels, these
215 //ust// * handlers can run in process context, and can block.
217 //ust// * This primitive provides the guarantees made by the (now removed)
218 //ust// * synchronize_kernel() API. In contrast, synchronize_rcu() only
219 //ust// * guarantees that rcu_read_lock() sections will have completed.
220 //ust// * In "classic RCU", these two guarantees happen to be one and
221 //ust// * the same, but can differ in realtime RCU implementations.
223 //ust// #define synchronize_sched() __synchronize_sched()
226 //ust// * call_rcu - Queue an RCU callback for invocation after a grace period.
227 //ust// * @head: structure to be used for queueing the RCU updates.
228 //ust// * @func: actual update function to be invoked after the grace period
230 //ust// * The update function will be invoked some time after a full grace
231 //ust// * period elapses, in other words after all currently executing RCU
232 //ust// * read-side critical sections have completed. RCU read-side critical
233 //ust// * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
234 //ust// * and may be nested.
236 //ust// extern void call_rcu(struct rcu_head *head,
237 //ust// void (*func)(struct rcu_head *head));
240 //ust// * call_rcu_bh - Queue an RCU for invocation after a quicker grace period.
241 //ust// * @head: structure to be used for queueing the RCU updates.
242 //ust// * @func: actual update function to be invoked after the grace period
244 //ust// * The update function will be invoked some time after a full grace
245 //ust// * period elapses, in other words after all currently executing RCU
246 //ust// * read-side critical sections have completed. call_rcu_bh() assumes
247 //ust// * that the read-side critical sections end on completion of a softirq
248 //ust// * handler. This means that read-side critical sections in process
249 //ust// * context must not be interrupted by softirqs. This interface is to be
250 //ust// * used when most of the read-side critical sections are in softirq context.
251 //ust// * RCU read-side critical sections are delimited by :
252 //ust// * - rcu_read_lock() and rcu_read_unlock(), if in interrupt context.
254 //ust// * - rcu_read_lock_bh() and rcu_read_unlock_bh(), if in process context.
255 //ust// * These may be nested.
257 //ust// extern void call_rcu_bh(struct rcu_head *head,
258 //ust// void (*func)(struct rcu_head *head));
260 //ust// /* Exported common interfaces */
261 //ust// extern void synchronize_rcu(void);
262 //ust// extern void rcu_barrier(void);
263 //ust// extern void rcu_barrier_bh(void);
264 //ust// extern void rcu_barrier_sched(void);
266 //ust// /* Internal to kernel */
267 //ust// extern void rcu_init(void);
268 //ust// extern int rcu_needs_cpu(int cpu);
270 #endif /* __LINUX_RCUPDATE_H */
This page took 0.036624 seconds and 3 git commands to generate.