Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Read-Copy Update mechanism for mutual exclusion |
| 3 | * |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 17 | * |
Paul E. McKenney | 01c1c66 | 2008-01-25 21:08:24 +0100 | [diff] [blame] | 18 | * Copyright IBM Corporation, 2001 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * |
| 20 | * Authors: Dipankar Sarma <dipankar@in.ibm.com> |
| 21 | * Manfred Spraul <manfred@colorfullife.com> |
Paul E. McKenney | a71fca5 | 2009-09-18 10:28:19 -0700 | [diff] [blame] | 22 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | * Based on the original work by Paul McKenney <paulmck@us.ibm.com> |
| 24 | * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen. |
| 25 | * Papers: |
| 26 | * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf |
| 27 | * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001) |
| 28 | * |
| 29 | * For detailed explanation of Read-Copy Update mechanism see - |
Paul E. McKenney | a71fca5 | 2009-09-18 10:28:19 -0700 | [diff] [blame] | 30 | * http://lse.sourceforge.net/locking/rcupdate.html |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | * |
| 32 | */ |
| 33 | #include <linux/types.h> |
| 34 | #include <linux/kernel.h> |
| 35 | #include <linux/init.h> |
| 36 | #include <linux/spinlock.h> |
| 37 | #include <linux/smp.h> |
| 38 | #include <linux/interrupt.h> |
| 39 | #include <linux/sched.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 40 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | #include <linux/bitops.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <linux/percpu.h> |
| 43 | #include <linux/notifier.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <linux/cpu.h> |
Ingo Molnar | 9331b31 | 2006-03-23 03:00:19 -0800 | [diff] [blame] | 45 | #include <linux/mutex.h> |
Paul Gortmaker | 9984de1 | 2011-05-23 14:51:41 -0400 | [diff] [blame] | 46 | #include <linux/export.h> |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 47 | #include <linux/hardirq.h> |
Paul E. McKenney | e3ebfb9 | 2012-07-02 14:42:01 -0700 | [diff] [blame] | 48 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Paul E. McKenney | 29c00b4 | 2011-06-17 15:53:19 -0700 | [diff] [blame] | 50 | #define CREATE_TRACE_POINTS |
| 51 | #include <trace/events/rcu.h> |
| 52 | |
| 53 | #include "rcu.h" |
| 54 | |
Paul E. McKenney | 9dd8fb1 | 2012-04-13 12:54:22 -0700 | [diff] [blame] | 55 | #ifdef CONFIG_PREEMPT_RCU |
| 56 | |
| 57 | /* |
Paul E. McKenney | 2a3fa84 | 2012-05-21 11:58:36 -0700 | [diff] [blame] | 58 | * Preemptible RCU implementation for rcu_read_lock(). |
| 59 | * Just increment ->rcu_read_lock_nesting, shared state will be updated |
| 60 | * if we block. |
| 61 | */ |
| 62 | void __rcu_read_lock(void) |
| 63 | { |
| 64 | current->rcu_read_lock_nesting++; |
| 65 | barrier(); /* critical section after entry code. */ |
| 66 | } |
| 67 | EXPORT_SYMBOL_GPL(__rcu_read_lock); |
| 68 | |
| 69 | /* |
| 70 | * Preemptible RCU implementation for rcu_read_unlock(). |
| 71 | * Decrement ->rcu_read_lock_nesting. If the result is zero (outermost |
| 72 | * rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then |
| 73 | * invoke rcu_read_unlock_special() to clean up after a context switch |
| 74 | * in an RCU read-side critical section and other special cases. |
| 75 | */ |
| 76 | void __rcu_read_unlock(void) |
| 77 | { |
| 78 | struct task_struct *t = current; |
| 79 | |
| 80 | if (t->rcu_read_lock_nesting != 1) { |
| 81 | --t->rcu_read_lock_nesting; |
| 82 | } else { |
| 83 | barrier(); /* critical section before exit code. */ |
| 84 | t->rcu_read_lock_nesting = INT_MIN; |
Paul E. McKenney | e3ebfb9 | 2012-07-02 14:42:01 -0700 | [diff] [blame] | 85 | #ifdef CONFIG_PROVE_RCU_DELAY |
| 86 | udelay(10); /* Make preemption more probable. */ |
| 87 | #endif /* #ifdef CONFIG_PROVE_RCU_DELAY */ |
Paul E. McKenney | 2a3fa84 | 2012-05-21 11:58:36 -0700 | [diff] [blame] | 88 | barrier(); /* assign before ->rcu_read_unlock_special load */ |
| 89 | if (unlikely(ACCESS_ONCE(t->rcu_read_unlock_special))) |
| 90 | rcu_read_unlock_special(t); |
| 91 | barrier(); /* ->rcu_read_unlock_special load before assign */ |
| 92 | t->rcu_read_lock_nesting = 0; |
| 93 | } |
| 94 | #ifdef CONFIG_PROVE_LOCKING |
| 95 | { |
| 96 | int rrln = ACCESS_ONCE(t->rcu_read_lock_nesting); |
| 97 | |
| 98 | WARN_ON_ONCE(rrln < 0 && rrln > INT_MIN / 2); |
| 99 | } |
| 100 | #endif /* #ifdef CONFIG_PROVE_LOCKING */ |
| 101 | } |
| 102 | EXPORT_SYMBOL_GPL(__rcu_read_unlock); |
| 103 | |
| 104 | /* |
Paul E. McKenney | 9dd8fb1 | 2012-04-13 12:54:22 -0700 | [diff] [blame] | 105 | * Check for a task exiting while in a preemptible-RCU read-side |
| 106 | * critical section, clean up if so. No need to issue warnings, |
| 107 | * as debug_check_no_locks_held() already does this if lockdep |
| 108 | * is enabled. |
| 109 | */ |
| 110 | void exit_rcu(void) |
| 111 | { |
| 112 | struct task_struct *t = current; |
| 113 | |
| 114 | if (likely(list_empty(¤t->rcu_node_entry))) |
| 115 | return; |
| 116 | t->rcu_read_lock_nesting = 1; |
| 117 | barrier(); |
| 118 | t->rcu_read_unlock_special = RCU_READ_UNLOCK_BLOCKED; |
| 119 | __rcu_read_unlock(); |
| 120 | } |
| 121 | |
| 122 | #else /* #ifdef CONFIG_PREEMPT_RCU */ |
| 123 | |
| 124 | void exit_rcu(void) |
| 125 | { |
| 126 | } |
| 127 | |
| 128 | #endif /* #else #ifdef CONFIG_PREEMPT_RCU */ |
| 129 | |
Paul E. McKenney | 162cc27 | 2009-09-23 16:18:13 -0700 | [diff] [blame] | 130 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 131 | static struct lock_class_key rcu_lock_key; |
| 132 | struct lockdep_map rcu_lock_map = |
| 133 | STATIC_LOCKDEP_MAP_INIT("rcu_read_lock", &rcu_lock_key); |
| 134 | EXPORT_SYMBOL_GPL(rcu_lock_map); |
Paul E. McKenney | 632ee20 | 2010-02-22 17:04:45 -0800 | [diff] [blame] | 135 | |
| 136 | static struct lock_class_key rcu_bh_lock_key; |
| 137 | struct lockdep_map rcu_bh_lock_map = |
| 138 | STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_bh", &rcu_bh_lock_key); |
| 139 | EXPORT_SYMBOL_GPL(rcu_bh_lock_map); |
| 140 | |
| 141 | static struct lock_class_key rcu_sched_lock_key; |
| 142 | struct lockdep_map rcu_sched_lock_map = |
| 143 | STATIC_LOCKDEP_MAP_INIT("rcu_read_lock_sched", &rcu_sched_lock_key); |
| 144 | EXPORT_SYMBOL_GPL(rcu_sched_lock_map); |
Paul E. McKenney | 162cc27 | 2009-09-23 16:18:13 -0700 | [diff] [blame] | 145 | #endif |
| 146 | |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 147 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 148 | |
Paul E. McKenney | bc293d6 | 2010-04-15 12:50:39 -0700 | [diff] [blame] | 149 | int debug_lockdep_rcu_enabled(void) |
| 150 | { |
| 151 | return rcu_scheduler_active && debug_locks && |
| 152 | current->lockdep_recursion == 0; |
| 153 | } |
| 154 | EXPORT_SYMBOL_GPL(debug_lockdep_rcu_enabled); |
| 155 | |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 156 | /** |
Paul E. McKenney | ca5ecdd | 2010-04-28 14:39:09 -0700 | [diff] [blame] | 157 | * rcu_read_lock_bh_held() - might we be in RCU-bh read-side critical section? |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 158 | * |
| 159 | * Check for bottom half being disabled, which covers both the |
| 160 | * CONFIG_PROVE_RCU and not cases. Note that if someone uses |
| 161 | * rcu_read_lock_bh(), but then later enables BH, lockdep (if enabled) |
Paul E. McKenney | ca5ecdd | 2010-04-28 14:39:09 -0700 | [diff] [blame] | 162 | * will show the situation. This is useful for debug checks in functions |
| 163 | * that require that they be called within an RCU read-side critical |
| 164 | * section. |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 165 | * |
| 166 | * Check debug_lockdep_rcu_enabled() to prevent false positives during boot. |
Paul E. McKenney | c0d6d01 | 2012-01-23 12:41:26 -0800 | [diff] [blame] | 167 | * |
| 168 | * Note that rcu_read_lock() is disallowed if the CPU is either idle or |
| 169 | * offline from an RCU perspective, so check for those as well. |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 170 | */ |
| 171 | int rcu_read_lock_bh_held(void) |
| 172 | { |
| 173 | if (!debug_lockdep_rcu_enabled()) |
| 174 | return 1; |
Frederic Weisbecker | e6b80a3 | 2011-10-07 16:25:18 -0700 | [diff] [blame] | 175 | if (rcu_is_cpu_idle()) |
| 176 | return 0; |
Paul E. McKenney | c0d6d01 | 2012-01-23 12:41:26 -0800 | [diff] [blame] | 177 | if (!rcu_lockdep_current_cpu_online()) |
| 178 | return 0; |
Paul E. McKenney | 773e3f9 | 2010-10-05 14:03:02 -0700 | [diff] [blame] | 179 | return in_softirq() || irqs_disabled(); |
Paul E. McKenney | e3818b8 | 2010-03-15 17:03:43 -0700 | [diff] [blame] | 180 | } |
| 181 | EXPORT_SYMBOL_GPL(rcu_read_lock_bh_held); |
| 182 | |
| 183 | #endif /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */ |
| 184 | |
Paul E. McKenney | 2c42818 | 2011-05-26 22:14:36 -0700 | [diff] [blame] | 185 | struct rcu_synchronize { |
| 186 | struct rcu_head head; |
| 187 | struct completion completion; |
| 188 | }; |
| 189 | |
Paul E. McKenney | d9f1bb6 | 2010-02-25 14:06:47 -0800 | [diff] [blame] | 190 | /* |
Paul E. McKenney | fbf6bfc | 2008-02-13 15:03:15 -0800 | [diff] [blame] | 191 | * Awaken the corresponding synchronize_rcu() instance now that a |
| 192 | * grace period has elapsed. |
| 193 | */ |
Paul E. McKenney | 2c42818 | 2011-05-26 22:14:36 -0700 | [diff] [blame] | 194 | static void wakeme_after_rcu(struct rcu_head *head) |
Dipankar Sarma | 21a1ea9 | 2006-03-07 21:55:33 -0800 | [diff] [blame] | 195 | { |
Paul E. McKenney | 01c1c66 | 2008-01-25 21:08:24 +0100 | [diff] [blame] | 196 | struct rcu_synchronize *rcu; |
| 197 | |
| 198 | rcu = container_of(head, struct rcu_synchronize, head); |
| 199 | complete(&rcu->completion); |
Dipankar Sarma | 21a1ea9 | 2006-03-07 21:55:33 -0800 | [diff] [blame] | 200 | } |
Paul E. McKenney | ee84b82 | 2010-05-06 09:28:41 -0700 | [diff] [blame] | 201 | |
Paul E. McKenney | 2c42818 | 2011-05-26 22:14:36 -0700 | [diff] [blame] | 202 | void wait_rcu_gp(call_rcu_func_t crf) |
| 203 | { |
| 204 | struct rcu_synchronize rcu; |
| 205 | |
| 206 | init_rcu_head_on_stack(&rcu.head); |
| 207 | init_completion(&rcu.completion); |
| 208 | /* Will wake me after RCU finished. */ |
| 209 | crf(&rcu.head, wakeme_after_rcu); |
| 210 | /* Wait for it. */ |
| 211 | wait_for_completion(&rcu.completion); |
| 212 | destroy_rcu_head_on_stack(&rcu.head); |
| 213 | } |
| 214 | EXPORT_SYMBOL_GPL(wait_rcu_gp); |
| 215 | |
Paul E. McKenney | ee84b82 | 2010-05-06 09:28:41 -0700 | [diff] [blame] | 216 | #ifdef CONFIG_PROVE_RCU |
| 217 | /* |
| 218 | * wrapper function to avoid #include problems. |
| 219 | */ |
| 220 | int rcu_my_thread_group_empty(void) |
| 221 | { |
| 222 | return thread_group_empty(current); |
| 223 | } |
| 224 | EXPORT_SYMBOL_GPL(rcu_my_thread_group_empty); |
| 225 | #endif /* #ifdef CONFIG_PROVE_RCU */ |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 226 | |
| 227 | #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD |
| 228 | static inline void debug_init_rcu_head(struct rcu_head *head) |
| 229 | { |
| 230 | debug_object_init(head, &rcuhead_debug_descr); |
| 231 | } |
| 232 | |
| 233 | static inline void debug_rcu_head_free(struct rcu_head *head) |
| 234 | { |
| 235 | debug_object_free(head, &rcuhead_debug_descr); |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * fixup_init is called when: |
| 240 | * - an active object is initialized |
| 241 | */ |
| 242 | static int rcuhead_fixup_init(void *addr, enum debug_obj_state state) |
| 243 | { |
| 244 | struct rcu_head *head = addr; |
| 245 | |
| 246 | switch (state) { |
| 247 | case ODEBUG_STATE_ACTIVE: |
| 248 | /* |
| 249 | * Ensure that queued callbacks are all executed. |
| 250 | * If we detect that we are nested in a RCU read-side critical |
| 251 | * section, we should simply fail, otherwise we would deadlock. |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 252 | * In !PREEMPT configurations, there is no way to tell if we are |
| 253 | * in a RCU read-side critical section or not, so we never |
| 254 | * attempt any fixup and just print a warning. |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 255 | */ |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 256 | #ifndef CONFIG_PREEMPT |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 257 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 258 | return 0; |
| 259 | #endif |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 260 | if (rcu_preempt_depth() != 0 || preempt_count() != 0 || |
| 261 | irqs_disabled()) { |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 262 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 263 | return 0; |
| 264 | } |
| 265 | rcu_barrier(); |
| 266 | rcu_barrier_sched(); |
| 267 | rcu_barrier_bh(); |
| 268 | debug_object_init(head, &rcuhead_debug_descr); |
| 269 | return 1; |
| 270 | default: |
| 271 | return 0; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | /* |
| 276 | * fixup_activate is called when: |
| 277 | * - an active object is activated |
| 278 | * - an unknown object is activated (might be a statically initialized object) |
| 279 | * Activation is performed internally by call_rcu(). |
| 280 | */ |
| 281 | static int rcuhead_fixup_activate(void *addr, enum debug_obj_state state) |
| 282 | { |
| 283 | struct rcu_head *head = addr; |
| 284 | |
| 285 | switch (state) { |
| 286 | |
| 287 | case ODEBUG_STATE_NOTAVAILABLE: |
| 288 | /* |
| 289 | * This is not really a fixup. We just make sure that it is |
| 290 | * tracked in the object tracker. |
| 291 | */ |
| 292 | debug_object_init(head, &rcuhead_debug_descr); |
| 293 | debug_object_activate(head, &rcuhead_debug_descr); |
| 294 | return 0; |
| 295 | |
| 296 | case ODEBUG_STATE_ACTIVE: |
| 297 | /* |
| 298 | * Ensure that queued callbacks are all executed. |
| 299 | * If we detect that we are nested in a RCU read-side critical |
| 300 | * section, we should simply fail, otherwise we would deadlock. |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 301 | * In !PREEMPT configurations, there is no way to tell if we are |
| 302 | * in a RCU read-side critical section or not, so we never |
| 303 | * attempt any fixup and just print a warning. |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 304 | */ |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 305 | #ifndef CONFIG_PREEMPT |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 306 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 307 | return 0; |
| 308 | #endif |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 309 | if (rcu_preempt_depth() != 0 || preempt_count() != 0 || |
| 310 | irqs_disabled()) { |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 311 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 312 | return 0; |
| 313 | } |
| 314 | rcu_barrier(); |
| 315 | rcu_barrier_sched(); |
| 316 | rcu_barrier_bh(); |
| 317 | debug_object_activate(head, &rcuhead_debug_descr); |
| 318 | return 1; |
| 319 | default: |
| 320 | return 0; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /* |
| 325 | * fixup_free is called when: |
| 326 | * - an active object is freed |
| 327 | */ |
| 328 | static int rcuhead_fixup_free(void *addr, enum debug_obj_state state) |
| 329 | { |
| 330 | struct rcu_head *head = addr; |
| 331 | |
| 332 | switch (state) { |
| 333 | case ODEBUG_STATE_ACTIVE: |
| 334 | /* |
| 335 | * Ensure that queued callbacks are all executed. |
| 336 | * If we detect that we are nested in a RCU read-side critical |
| 337 | * section, we should simply fail, otherwise we would deadlock. |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 338 | * In !PREEMPT configurations, there is no way to tell if we are |
| 339 | * in a RCU read-side critical section or not, so we never |
| 340 | * attempt any fixup and just print a warning. |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 341 | */ |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 342 | #ifndef CONFIG_PREEMPT |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 343 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | fc2ecf7 | 2011-02-23 09:42:14 -0800 | [diff] [blame] | 344 | return 0; |
| 345 | #endif |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 346 | if (rcu_preempt_depth() != 0 || preempt_count() != 0 || |
| 347 | irqs_disabled()) { |
Paul E. McKenney | 108aae2 | 2011-02-23 09:56:00 -0800 | [diff] [blame] | 348 | WARN_ON_ONCE(1); |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 349 | return 0; |
| 350 | } |
| 351 | rcu_barrier(); |
| 352 | rcu_barrier_sched(); |
| 353 | rcu_barrier_bh(); |
| 354 | debug_object_free(head, &rcuhead_debug_descr); |
| 355 | return 1; |
Mathieu Desnoyers | 551d55a | 2010-04-17 08:48:42 -0400 | [diff] [blame] | 356 | default: |
| 357 | return 0; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * init_rcu_head_on_stack() - initialize on-stack rcu_head for debugobjects |
| 363 | * @head: pointer to rcu_head structure to be initialized |
| 364 | * |
| 365 | * This function informs debugobjects of a new rcu_head structure that |
| 366 | * has been allocated as an auto variable on the stack. This function |
| 367 | * is not required for rcu_head structures that are statically defined or |
| 368 | * that are dynamically allocated on the heap. This function has no |
| 369 | * effect for !CONFIG_DEBUG_OBJECTS_RCU_HEAD kernel builds. |
| 370 | */ |
| 371 | void init_rcu_head_on_stack(struct rcu_head *head) |
| 372 | { |
| 373 | debug_object_init_on_stack(head, &rcuhead_debug_descr); |
| 374 | } |
| 375 | EXPORT_SYMBOL_GPL(init_rcu_head_on_stack); |
| 376 | |
| 377 | /** |
| 378 | * destroy_rcu_head_on_stack() - destroy on-stack rcu_head for debugobjects |
| 379 | * @head: pointer to rcu_head structure to be initialized |
| 380 | * |
| 381 | * This function informs debugobjects that an on-stack rcu_head structure |
| 382 | * is about to go out of scope. As with init_rcu_head_on_stack(), this |
| 383 | * function is not required for rcu_head structures that are statically |
| 384 | * defined or that are dynamically allocated on the heap. Also as with |
| 385 | * init_rcu_head_on_stack(), this function has no effect for |
| 386 | * !CONFIG_DEBUG_OBJECTS_RCU_HEAD kernel builds. |
| 387 | */ |
| 388 | void destroy_rcu_head_on_stack(struct rcu_head *head) |
| 389 | { |
| 390 | debug_object_free(head, &rcuhead_debug_descr); |
| 391 | } |
| 392 | EXPORT_SYMBOL_GPL(destroy_rcu_head_on_stack); |
| 393 | |
| 394 | struct debug_obj_descr rcuhead_debug_descr = { |
| 395 | .name = "rcu_head", |
| 396 | .fixup_init = rcuhead_fixup_init, |
| 397 | .fixup_activate = rcuhead_fixup_activate, |
| 398 | .fixup_free = rcuhead_fixup_free, |
| 399 | }; |
| 400 | EXPORT_SYMBOL_GPL(rcuhead_debug_descr); |
| 401 | #endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */ |
Paul E. McKenney | 91afaf3 | 2011-10-02 07:44:32 -0700 | [diff] [blame] | 402 | |
| 403 | #if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE) |
| 404 | void do_trace_rcu_torture_read(char *rcutorturename, struct rcu_head *rhp) |
| 405 | { |
| 406 | trace_rcu_torture_read(rcutorturename, rhp); |
| 407 | } |
| 408 | EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read); |
| 409 | #else |
| 410 | #define do_trace_rcu_torture_read(rcutorturename, rhp) do { } while (0) |
| 411 | #endif |