diff options
Diffstat (limited to 'include/linux/rcupdate.h')
-rw-r--r-- | include/linux/rcupdate.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index fe17d7d750c2..cc24a01df940 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/percpu.h> | 41 | #include <linux/percpu.h> |
42 | #include <linux/cpumask.h> | 42 | #include <linux/cpumask.h> |
43 | #include <linux/seqlock.h> | 43 | #include <linux/seqlock.h> |
44 | #include <linux/lockdep.h> | ||
44 | 45 | ||
45 | /** | 46 | /** |
46 | * struct rcu_head - callback structure for use with RCU | 47 | * struct rcu_head - callback structure for use with RCU |
@@ -133,6 +134,15 @@ static inline void rcu_bh_qsctr_inc(int cpu) | |||
133 | extern int rcu_pending(int cpu); | 134 | extern int rcu_pending(int cpu); |
134 | extern int rcu_needs_cpu(int cpu); | 135 | extern int rcu_needs_cpu(int cpu); |
135 | 136 | ||
137 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
138 | extern struct lockdep_map rcu_lock_map; | ||
139 | # define rcu_read_acquire() lock_acquire(&rcu_lock_map, 0, 0, 2, 1, _THIS_IP_) | ||
140 | # define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_) | ||
141 | #else | ||
142 | # define rcu_read_acquire() do { } while (0) | ||
143 | # define rcu_read_release() do { } while (0) | ||
144 | #endif | ||
145 | |||
136 | /** | 146 | /** |
137 | * rcu_read_lock - mark the beginning of an RCU read-side critical section. | 147 | * rcu_read_lock - mark the beginning of an RCU read-side critical section. |
138 | * | 148 | * |
@@ -166,6 +176,7 @@ extern int rcu_needs_cpu(int cpu); | |||
166 | do { \ | 176 | do { \ |
167 | preempt_disable(); \ | 177 | preempt_disable(); \ |
168 | __acquire(RCU); \ | 178 | __acquire(RCU); \ |
179 | rcu_read_acquire(); \ | ||
169 | } while(0) | 180 | } while(0) |
170 | 181 | ||
171 | /** | 182 | /** |
@@ -175,6 +186,7 @@ extern int rcu_needs_cpu(int cpu); | |||
175 | */ | 186 | */ |
176 | #define rcu_read_unlock() \ | 187 | #define rcu_read_unlock() \ |
177 | do { \ | 188 | do { \ |
189 | rcu_read_release(); \ | ||
178 | __release(RCU); \ | 190 | __release(RCU); \ |
179 | preempt_enable(); \ | 191 | preempt_enable(); \ |
180 | } while(0) | 192 | } while(0) |
@@ -204,6 +216,7 @@ extern int rcu_needs_cpu(int cpu); | |||
204 | do { \ | 216 | do { \ |
205 | local_bh_disable(); \ | 217 | local_bh_disable(); \ |
206 | __acquire(RCU_BH); \ | 218 | __acquire(RCU_BH); \ |
219 | rcu_read_acquire(); \ | ||
207 | } while(0) | 220 | } while(0) |
208 | 221 | ||
209 | /* | 222 | /* |
@@ -213,10 +226,23 @@ extern int rcu_needs_cpu(int cpu); | |||
213 | */ | 226 | */ |
214 | #define rcu_read_unlock_bh() \ | 227 | #define rcu_read_unlock_bh() \ |
215 | do { \ | 228 | do { \ |
229 | rcu_read_release(); \ | ||
216 | __release(RCU_BH); \ | 230 | __release(RCU_BH); \ |
217 | local_bh_enable(); \ | 231 | local_bh_enable(); \ |
218 | } while(0) | 232 | } while(0) |
219 | 233 | ||
234 | /* | ||
235 | * Prevent the compiler from merging or refetching accesses. The compiler | ||
236 | * is also forbidden from reordering successive instances of ACCESS_ONCE(), | ||
237 | * but only when the compiler is aware of some particular ordering. One way | ||
238 | * to make the compiler aware of ordering is to put the two invocations of | ||
239 | * ACCESS_ONCE() in different C statements. | ||
240 | * | ||
241 | * This macro does absolutely -nothing- to prevent the CPU from reordering, | ||
242 | * merging, or refetching absolutely anything at any time. | ||
243 | */ | ||
244 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) | ||
245 | |||
220 | /** | 246 | /** |
221 | * rcu_dereference - fetch an RCU-protected pointer in an | 247 | * rcu_dereference - fetch an RCU-protected pointer in an |
222 | * RCU read-side critical section. This pointer may later | 248 | * RCU read-side critical section. This pointer may later |
@@ -228,7 +254,7 @@ extern int rcu_needs_cpu(int cpu); | |||
228 | */ | 254 | */ |
229 | 255 | ||
230 | #define rcu_dereference(p) ({ \ | 256 | #define rcu_dereference(p) ({ \ |
231 | typeof(p) _________p1 = p; \ | 257 | typeof(p) _________p1 = ACCESS_ONCE(p); \ |
232 | smp_read_barrier_depends(); \ | 258 | smp_read_barrier_depends(); \ |
233 | (_________p1); \ | 259 | (_________p1); \ |
234 | }) | 260 | }) |