aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/rcupdate.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 872a98e13d6a..8fe86609441f 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -209,13 +209,45 @@ static inline int rcu_read_lock_sched_held(void)
209 rcu_dereference_raw(p); \ 209 rcu_dereference_raw(p); \
210 }) 210 })
211 211
212/**
213 * rcu_dereference_protected - fetch RCU pointer when updates prevented
214 *
215 * Return the value of the specified RCU-protected pointer, but omit
216 * both the smp_read_barrier_depends() and the ACCESS_ONCE(). This
217 * is useful in cases where update-side locks prevent the value of the
218 * pointer from changing. Please note that this primitive does -not-
219 * prevent the compiler from repeating this reference or combining it
220 * with other references, so it should not be used without protection
221 * of appropriate locks.
222 */
223#define rcu_dereference_protected(p, c) \
224 ({ \
225 if (debug_lockdep_rcu_enabled() && !(c)) \
226 lockdep_rcu_dereference(__FILE__, __LINE__); \
227 (p); \
228 })
229
212#else /* #ifdef CONFIG_PROVE_RCU */ 230#else /* #ifdef CONFIG_PROVE_RCU */
213 231
214#define rcu_dereference_check(p, c) rcu_dereference_raw(p) 232#define rcu_dereference_check(p, c) rcu_dereference_raw(p)
233#define rcu_dereference_protected(p, c) (p)
215 234
216#endif /* #else #ifdef CONFIG_PROVE_RCU */ 235#endif /* #else #ifdef CONFIG_PROVE_RCU */
217 236
218/** 237/**
238 * rcu_access_pointer - fetch RCU pointer with no dereferencing
239 *
240 * Return the value of the specified RCU-protected pointer, but omit the
241 * smp_read_barrier_depends() and keep the ACCESS_ONCE(). This is useful
242 * when the value of this pointer is accessed, but the pointer is not
243 * dereferenced, for example, when testing an RCU-protected pointer against
244 * NULL. This may also be used in cases where update-side locks prevent
245 * the value of the pointer from changing, but rcu_dereference_protected()
246 * is a lighter-weight primitive for this use case.
247 */
248#define rcu_access_pointer(p) ACCESS_ONCE(p)
249
250/**
219 * rcu_read_lock - mark the beginning of an RCU read-side critical section. 251 * rcu_read_lock - mark the beginning of an RCU read-side critical section.
220 * 252 *
221 * When synchronize_rcu() is invoked on one CPU while other CPUs 253 * When synchronize_rcu() is invoked on one CPU while other CPUs