Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Read-Copy Update mechanism for mutual exclusion (tree-based version) |
| 3 | * Internal non-public definitions that provide either classic |
| 4 | * or preemptable semantics. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | * |
| 20 | * Copyright Red Hat, 2009 |
| 21 | * Copyright IBM Corporation, 2009 |
| 22 | * |
| 23 | * Author: Ingo Molnar <mingo@elte.hu> |
| 24 | * Paul E. McKenney <paulmck@linux.vnet.ibm.com> |
| 25 | */ |
| 26 | |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 27 | #include <linux/delay.h> |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 28 | |
| 29 | #ifdef CONFIG_TREE_PREEMPT_RCU |
| 30 | |
| 31 | struct rcu_state rcu_preempt_state = RCU_STATE_INITIALIZER(rcu_preempt_state); |
| 32 | DEFINE_PER_CPU(struct rcu_data, rcu_preempt_data); |
| 33 | |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 34 | static int rcu_preempted_readers_exp(struct rcu_node *rnp); |
| 35 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 36 | /* |
| 37 | * Tell them what RCU they are running. |
| 38 | */ |
Paul E. McKenney | 0e0fc1c | 2009-11-11 11:28:06 -0800 | [diff] [blame] | 39 | static void __init rcu_bootup_announce(void) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 40 | { |
| 41 | printk(KERN_INFO |
| 42 | "Experimental preemptable hierarchical RCU implementation.\n"); |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | * Return the number of RCU-preempt batches processed thus far |
| 47 | * for debug and statistics. |
| 48 | */ |
| 49 | long rcu_batches_completed_preempt(void) |
| 50 | { |
| 51 | return rcu_preempt_state.completed; |
| 52 | } |
| 53 | EXPORT_SYMBOL_GPL(rcu_batches_completed_preempt); |
| 54 | |
| 55 | /* |
| 56 | * Return the number of RCU batches processed thus far for debug & stats. |
| 57 | */ |
| 58 | long rcu_batches_completed(void) |
| 59 | { |
| 60 | return rcu_batches_completed_preempt(); |
| 61 | } |
| 62 | EXPORT_SYMBOL_GPL(rcu_batches_completed); |
| 63 | |
| 64 | /* |
Paul E. McKenney | bf66f18 | 2010-01-04 15:09:10 -0800 | [diff] [blame] | 65 | * Force a quiescent state for preemptible RCU. |
| 66 | */ |
| 67 | void rcu_force_quiescent_state(void) |
| 68 | { |
| 69 | force_quiescent_state(&rcu_preempt_state, 0); |
| 70 | } |
| 71 | EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); |
| 72 | |
| 73 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 74 | * Record a preemptable-RCU quiescent state for the specified CPU. Note |
| 75 | * that this just means that the task currently running on the CPU is |
| 76 | * not in a quiescent state. There might be any number of tasks blocked |
| 77 | * while in an RCU read-side critical section. |
Paul E. McKenney | 25502a6 | 2010-04-01 17:37:01 -0700 | [diff] [blame^] | 78 | * |
| 79 | * Unlike the other rcu_*_qs() functions, callers to this function |
| 80 | * must disable irqs in order to protect the assignment to |
| 81 | * ->rcu_read_unlock_special. |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 82 | */ |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 83 | static void rcu_preempt_qs(int cpu) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 84 | { |
| 85 | struct rcu_data *rdp = &per_cpu(rcu_preempt_data, cpu); |
Paul E. McKenney | 25502a6 | 2010-04-01 17:37:01 -0700 | [diff] [blame^] | 86 | |
Paul E. McKenney | c64ac3c | 2009-11-10 13:37:22 -0800 | [diff] [blame] | 87 | rdp->passed_quiesc_completed = rdp->gpnum - 1; |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 88 | barrier(); |
| 89 | rdp->passed_quiesc = 1; |
Paul E. McKenney | 25502a6 | 2010-04-01 17:37:01 -0700 | [diff] [blame^] | 90 | current->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_NEED_QS; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | /* |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 94 | * We have entered the scheduler, and the current task might soon be |
| 95 | * context-switched away from. If this task is in an RCU read-side |
| 96 | * critical section, we will no longer be able to rely on the CPU to |
| 97 | * record that fact, so we enqueue the task on the appropriate entry |
| 98 | * of the blocked_tasks[] array. The task will dequeue itself when |
| 99 | * it exits the outermost enclosing RCU read-side critical section. |
| 100 | * Therefore, the current grace period cannot be permitted to complete |
| 101 | * until the blocked_tasks[] entry indexed by the low-order bit of |
| 102 | * rnp->gpnum empties. |
| 103 | * |
| 104 | * Caller must disable preemption. |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 105 | */ |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 106 | static void rcu_preempt_note_context_switch(int cpu) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 107 | { |
| 108 | struct task_struct *t = current; |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 109 | unsigned long flags; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 110 | int phase; |
| 111 | struct rcu_data *rdp; |
| 112 | struct rcu_node *rnp; |
| 113 | |
| 114 | if (t->rcu_read_lock_nesting && |
| 115 | (t->rcu_read_unlock_special & RCU_READ_UNLOCK_BLOCKED) == 0) { |
| 116 | |
| 117 | /* Possibly blocking in an RCU read-side critical section. */ |
| 118 | rdp = rcu_preempt_state.rda[cpu]; |
| 119 | rnp = rdp->mynode; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 120 | raw_spin_lock_irqsave(&rnp->lock, flags); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 121 | t->rcu_read_unlock_special |= RCU_READ_UNLOCK_BLOCKED; |
Paul E. McKenney | 8684896 | 2009-08-27 15:00:12 -0700 | [diff] [blame] | 122 | t->rcu_blocked_node = rnp; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 123 | |
| 124 | /* |
| 125 | * If this CPU has already checked in, then this task |
| 126 | * will hold up the next grace period rather than the |
| 127 | * current grace period. Queue the task accordingly. |
| 128 | * If the task is queued for the current grace period |
| 129 | * (i.e., this CPU has not yet passed through a quiescent |
| 130 | * state for the current grace period), then as long |
| 131 | * as that task remains queued, the current grace period |
| 132 | * cannot end. |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 133 | * |
| 134 | * But first, note that the current CPU must still be |
| 135 | * on line! |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 136 | */ |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 137 | WARN_ON_ONCE((rdp->grpmask & rnp->qsmaskinit) == 0); |
Paul E. McKenney | e7d8842 | 2009-09-18 09:50:18 -0700 | [diff] [blame] | 138 | WARN_ON_ONCE(!list_empty(&t->rcu_node_entry)); |
| 139 | phase = (rnp->gpnum + !(rnp->qsmask & rdp->grpmask)) & 0x1; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 140 | list_add(&t->rcu_node_entry, &rnp->blocked_tasks[phase]); |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 141 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Either we were not in an RCU read-side critical section to |
| 146 | * begin with, or we have now recorded that critical section |
| 147 | * globally. Either way, we can now note a quiescent state |
| 148 | * for this CPU. Again, if we were in an RCU read-side critical |
| 149 | * section, and if that critical section was blocking the current |
| 150 | * grace period, then the fact that the task has been enqueued |
| 151 | * means that we continue to block the current grace period. |
| 152 | */ |
Paul E. McKenney | e7d8842 | 2009-09-18 09:50:18 -0700 | [diff] [blame] | 153 | local_irq_save(flags); |
Paul E. McKenney | 25502a6 | 2010-04-01 17:37:01 -0700 | [diff] [blame^] | 154 | rcu_preempt_qs(cpu); |
Paul E. McKenney | e7d8842 | 2009-09-18 09:50:18 -0700 | [diff] [blame] | 155 | local_irq_restore(flags); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /* |
| 159 | * Tree-preemptable RCU implementation for rcu_read_lock(). |
| 160 | * Just increment ->rcu_read_lock_nesting, shared state will be updated |
| 161 | * if we block. |
| 162 | */ |
| 163 | void __rcu_read_lock(void) |
| 164 | { |
| 165 | ACCESS_ONCE(current->rcu_read_lock_nesting)++; |
| 166 | barrier(); /* needed if we ever invoke rcu_read_lock in rcutree.c */ |
| 167 | } |
| 168 | EXPORT_SYMBOL_GPL(__rcu_read_lock); |
| 169 | |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 170 | /* |
| 171 | * Check for preempted RCU readers blocking the current grace period |
| 172 | * for the specified rcu_node structure. If the caller needs a reliable |
| 173 | * answer, it must hold the rcu_node's ->lock. |
| 174 | */ |
| 175 | static int rcu_preempted_readers(struct rcu_node *rnp) |
| 176 | { |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 177 | int phase = rnp->gpnum & 0x1; |
| 178 | |
| 179 | return !list_empty(&rnp->blocked_tasks[phase]) || |
| 180 | !list_empty(&rnp->blocked_tasks[phase + 2]); |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 183 | /* |
| 184 | * Record a quiescent state for all tasks that were previously queued |
| 185 | * on the specified rcu_node structure and that were blocking the current |
| 186 | * RCU grace period. The caller must hold the specified rnp->lock with |
| 187 | * irqs disabled, and this lock is released upon return, but irqs remain |
| 188 | * disabled. |
| 189 | */ |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 190 | static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags) |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 191 | __releases(rnp->lock) |
| 192 | { |
| 193 | unsigned long mask; |
| 194 | struct rcu_node *rnp_p; |
| 195 | |
| 196 | if (rnp->qsmask != 0 || rcu_preempted_readers(rnp)) { |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 197 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 198 | return; /* Still need more quiescent states! */ |
| 199 | } |
| 200 | |
| 201 | rnp_p = rnp->parent; |
| 202 | if (rnp_p == NULL) { |
| 203 | /* |
| 204 | * Either there is only one rcu_node in the tree, |
| 205 | * or tasks were kicked up to root rcu_node due to |
| 206 | * CPUs going offline. |
| 207 | */ |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 208 | rcu_report_qs_rsp(&rcu_preempt_state, flags); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 209 | return; |
| 210 | } |
| 211 | |
| 212 | /* Report up the rest of the hierarchy. */ |
| 213 | mask = rnp->grpmask; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 214 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
| 215 | raw_spin_lock(&rnp_p->lock); /* irqs already disabled. */ |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 216 | rcu_report_qs_rnp(mask, &rcu_preempt_state, rnp_p, flags); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | /* |
| 220 | * Handle special cases during rcu_read_unlock(), such as needing to |
| 221 | * notify RCU core processing or task having blocked during the RCU |
| 222 | * read-side critical section. |
| 223 | */ |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 224 | static void rcu_read_unlock_special(struct task_struct *t) |
| 225 | { |
| 226 | int empty; |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 227 | int empty_exp; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 228 | unsigned long flags; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 229 | struct rcu_node *rnp; |
| 230 | int special; |
| 231 | |
| 232 | /* NMI handlers cannot block and cannot safely manipulate state. */ |
| 233 | if (in_nmi()) |
| 234 | return; |
| 235 | |
| 236 | local_irq_save(flags); |
| 237 | |
| 238 | /* |
| 239 | * If RCU core is waiting for this CPU to exit critical section, |
| 240 | * let it know that we have done so. |
| 241 | */ |
| 242 | special = t->rcu_read_unlock_special; |
| 243 | if (special & RCU_READ_UNLOCK_NEED_QS) { |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 244 | rcu_preempt_qs(smp_processor_id()); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | /* Hardware IRQ handlers cannot block. */ |
| 248 | if (in_irq()) { |
| 249 | local_irq_restore(flags); |
| 250 | return; |
| 251 | } |
| 252 | |
| 253 | /* Clean up if blocked during RCU read-side critical section. */ |
| 254 | if (special & RCU_READ_UNLOCK_BLOCKED) { |
| 255 | t->rcu_read_unlock_special &= ~RCU_READ_UNLOCK_BLOCKED; |
| 256 | |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 257 | /* |
| 258 | * Remove this task from the list it blocked on. The |
| 259 | * task can migrate while we acquire the lock, but at |
| 260 | * most one time. So at most two passes through loop. |
| 261 | */ |
| 262 | for (;;) { |
Paul E. McKenney | 8684896 | 2009-08-27 15:00:12 -0700 | [diff] [blame] | 263 | rnp = t->rcu_blocked_node; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 264 | raw_spin_lock(&rnp->lock); /* irqs already disabled. */ |
Paul E. McKenney | 8684896 | 2009-08-27 15:00:12 -0700 | [diff] [blame] | 265 | if (rnp == t->rcu_blocked_node) |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 266 | break; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 267 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 268 | } |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 269 | empty = !rcu_preempted_readers(rnp); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 270 | empty_exp = !rcu_preempted_readers_exp(rnp); |
| 271 | smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 272 | list_del_init(&t->rcu_node_entry); |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 273 | t->rcu_blocked_node = NULL; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 274 | |
| 275 | /* |
| 276 | * If this was the last task on the current list, and if |
| 277 | * we aren't waiting on any CPUs, report the quiescent state. |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 278 | * Note that rcu_report_unblock_qs_rnp() releases rnp->lock. |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 279 | */ |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 280 | if (empty) |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 281 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 282 | else |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 283 | rcu_report_unblock_qs_rnp(rnp, flags); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 284 | |
| 285 | /* |
| 286 | * If this was the last task on the expedited lists, |
| 287 | * then we need to report up the rcu_node hierarchy. |
| 288 | */ |
| 289 | if (!empty_exp && !rcu_preempted_readers_exp(rnp)) |
| 290 | rcu_report_exp_rnp(&rcu_preempt_state, rnp); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 291 | } else { |
| 292 | local_irq_restore(flags); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 293 | } |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /* |
| 297 | * Tree-preemptable RCU implementation for rcu_read_unlock(). |
| 298 | * Decrement ->rcu_read_lock_nesting. If the result is zero (outermost |
| 299 | * rcu_read_unlock()) and ->rcu_read_unlock_special is non-zero, then |
| 300 | * invoke rcu_read_unlock_special() to clean up after a context switch |
| 301 | * in an RCU read-side critical section and other special cases. |
| 302 | */ |
| 303 | void __rcu_read_unlock(void) |
| 304 | { |
| 305 | struct task_struct *t = current; |
| 306 | |
| 307 | barrier(); /* needed if we ever invoke rcu_read_unlock in rcutree.c */ |
| 308 | if (--ACCESS_ONCE(t->rcu_read_lock_nesting) == 0 && |
| 309 | unlikely(ACCESS_ONCE(t->rcu_read_unlock_special))) |
| 310 | rcu_read_unlock_special(t); |
Paul E. McKenney | cba8244 | 2010-01-04 16:04:01 -0800 | [diff] [blame] | 311 | #ifdef CONFIG_PROVE_LOCKING |
| 312 | WARN_ON_ONCE(ACCESS_ONCE(t->rcu_read_lock_nesting) < 0); |
| 313 | #endif /* #ifdef CONFIG_PROVE_LOCKING */ |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 314 | } |
| 315 | EXPORT_SYMBOL_GPL(__rcu_read_unlock); |
| 316 | |
| 317 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
| 318 | |
Paul E. McKenney | 1ed509a | 2010-02-22 17:05:05 -0800 | [diff] [blame] | 319 | #ifdef CONFIG_RCU_CPU_STALL_VERBOSE |
| 320 | |
| 321 | /* |
| 322 | * Dump detailed information for all tasks blocking the current RCU |
| 323 | * grace period on the specified rcu_node structure. |
| 324 | */ |
| 325 | static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp) |
| 326 | { |
| 327 | unsigned long flags; |
| 328 | struct list_head *lp; |
| 329 | int phase; |
| 330 | struct task_struct *t; |
| 331 | |
| 332 | if (rcu_preempted_readers(rnp)) { |
| 333 | raw_spin_lock_irqsave(&rnp->lock, flags); |
| 334 | phase = rnp->gpnum & 0x1; |
| 335 | lp = &rnp->blocked_tasks[phase]; |
| 336 | list_for_each_entry(t, lp, rcu_node_entry) |
| 337 | sched_show_task(t); |
| 338 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | /* |
| 343 | * Dump detailed information for all tasks blocking the current RCU |
| 344 | * grace period. |
| 345 | */ |
| 346 | static void rcu_print_detail_task_stall(struct rcu_state *rsp) |
| 347 | { |
| 348 | struct rcu_node *rnp = rcu_get_root(rsp); |
| 349 | |
| 350 | rcu_print_detail_task_stall_rnp(rnp); |
| 351 | rcu_for_each_leaf_node(rsp, rnp) |
| 352 | rcu_print_detail_task_stall_rnp(rnp); |
| 353 | } |
| 354 | |
| 355 | #else /* #ifdef CONFIG_RCU_CPU_STALL_VERBOSE */ |
| 356 | |
| 357 | static void rcu_print_detail_task_stall(struct rcu_state *rsp) |
| 358 | { |
| 359 | } |
| 360 | |
| 361 | #endif /* #else #ifdef CONFIG_RCU_CPU_STALL_VERBOSE */ |
| 362 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 363 | /* |
| 364 | * Scan the current list of tasks blocked within RCU read-side critical |
| 365 | * sections, printing out the tid of each. |
| 366 | */ |
| 367 | static void rcu_print_task_stall(struct rcu_node *rnp) |
| 368 | { |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 369 | struct list_head *lp; |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 370 | int phase; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 371 | struct task_struct *t; |
| 372 | |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 373 | if (rcu_preempted_readers(rnp)) { |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 374 | phase = rnp->gpnum & 0x1; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 375 | lp = &rnp->blocked_tasks[phase]; |
| 376 | list_for_each_entry(t, lp, rcu_node_entry) |
| 377 | printk(" P%d", t->pid); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 378 | } |
| 379 | } |
| 380 | |
| 381 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
| 382 | |
| 383 | /* |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 384 | * Check that the list of blocked tasks for the newly completed grace |
| 385 | * period is in fact empty. It is a serious bug to complete a grace |
| 386 | * period that still has RCU readers blocked! This function must be |
| 387 | * invoked -before- updating this rnp's ->gpnum, and the rnp's ->lock |
| 388 | * must be held by the caller. |
| 389 | */ |
| 390 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
| 391 | { |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 392 | WARN_ON_ONCE(rcu_preempted_readers(rnp)); |
Paul E. McKenney | 28ecd58 | 2009-09-18 09:50:17 -0700 | [diff] [blame] | 393 | WARN_ON_ONCE(rnp->qsmask); |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 394 | } |
| 395 | |
Paul E. McKenney | 33f7614 | 2009-08-24 09:42:01 -0700 | [diff] [blame] | 396 | #ifdef CONFIG_HOTPLUG_CPU |
| 397 | |
| 398 | /* |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 399 | * Handle tasklist migration for case in which all CPUs covered by the |
| 400 | * specified rcu_node have gone offline. Move them up to the root |
| 401 | * rcu_node. The reason for not just moving them to the immediate |
| 402 | * parent is to remove the need for rcu_read_unlock_special() to |
| 403 | * make more than two attempts to acquire the target rcu_node's lock. |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 404 | * Returns true if there were tasks blocking the current RCU grace |
| 405 | * period. |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 406 | * |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 407 | * Returns 1 if there was previously a task blocking the current grace |
| 408 | * period on the specified rcu_node structure. |
| 409 | * |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 410 | * The caller must hold rnp->lock with irqs disabled. |
| 411 | */ |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 412 | static int rcu_preempt_offline_tasks(struct rcu_state *rsp, |
| 413 | struct rcu_node *rnp, |
| 414 | struct rcu_data *rdp) |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 415 | { |
| 416 | int i; |
| 417 | struct list_head *lp; |
| 418 | struct list_head *lp_root; |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 419 | int retval = 0; |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 420 | struct rcu_node *rnp_root = rcu_get_root(rsp); |
| 421 | struct task_struct *tp; |
| 422 | |
Paul E. McKenney | 8684896 | 2009-08-27 15:00:12 -0700 | [diff] [blame] | 423 | if (rnp == rnp_root) { |
| 424 | WARN_ONCE(1, "Last CPU thought to be offlined?"); |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 425 | return 0; /* Shouldn't happen: at least one CPU online. */ |
Paul E. McKenney | 8684896 | 2009-08-27 15:00:12 -0700 | [diff] [blame] | 426 | } |
Paul E. McKenney | 28ecd58 | 2009-09-18 09:50:17 -0700 | [diff] [blame] | 427 | WARN_ON_ONCE(rnp != rdp->mynode && |
| 428 | (!list_empty(&rnp->blocked_tasks[0]) || |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 429 | !list_empty(&rnp->blocked_tasks[1]) || |
| 430 | !list_empty(&rnp->blocked_tasks[2]) || |
| 431 | !list_empty(&rnp->blocked_tasks[3]))); |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 432 | |
| 433 | /* |
| 434 | * Move tasks up to root rcu_node. Rely on the fact that the |
| 435 | * root rcu_node can be at most one ahead of the rest of the |
| 436 | * rcu_nodes in terms of gp_num value. This fact allows us to |
| 437 | * move the blocked_tasks[] array directly, element by element. |
| 438 | */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 439 | if (rcu_preempted_readers(rnp)) |
| 440 | retval |= RCU_OFL_TASKS_NORM_GP; |
| 441 | if (rcu_preempted_readers_exp(rnp)) |
| 442 | retval |= RCU_OFL_TASKS_EXP_GP; |
| 443 | for (i = 0; i < 4; i++) { |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 444 | lp = &rnp->blocked_tasks[i]; |
| 445 | lp_root = &rnp_root->blocked_tasks[i]; |
| 446 | while (!list_empty(lp)) { |
| 447 | tp = list_entry(lp->next, typeof(*tp), rcu_node_entry); |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 448 | raw_spin_lock(&rnp_root->lock); /* irqs already disabled */ |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 449 | list_del(&tp->rcu_node_entry); |
| 450 | tp->rcu_blocked_node = rnp_root; |
| 451 | list_add(&tp->rcu_node_entry, lp_root); |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 452 | raw_spin_unlock(&rnp_root->lock); /* irqs remain disabled */ |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 453 | } |
| 454 | } |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 455 | return retval; |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | /* |
Paul E. McKenney | 33f7614 | 2009-08-24 09:42:01 -0700 | [diff] [blame] | 459 | * Do CPU-offline processing for preemptable RCU. |
| 460 | */ |
| 461 | static void rcu_preempt_offline_cpu(int cpu) |
| 462 | { |
| 463 | __rcu_offline_cpu(cpu, &rcu_preempt_state); |
| 464 | } |
| 465 | |
| 466 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 467 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 468 | /* |
| 469 | * Check for a quiescent state from the current CPU. When a task blocks, |
| 470 | * the task is recorded in the corresponding CPU's rcu_node structure, |
| 471 | * which is checked elsewhere. |
| 472 | * |
| 473 | * Caller must disable hard irqs. |
| 474 | */ |
| 475 | static void rcu_preempt_check_callbacks(int cpu) |
| 476 | { |
| 477 | struct task_struct *t = current; |
| 478 | |
| 479 | if (t->rcu_read_lock_nesting == 0) { |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 480 | rcu_preempt_qs(cpu); |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 481 | return; |
| 482 | } |
Paul E. McKenney | a71fca5 | 2009-09-18 10:28:19 -0700 | [diff] [blame] | 483 | if (per_cpu(rcu_preempt_data, cpu).qs_pending) |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 484 | t->rcu_read_unlock_special |= RCU_READ_UNLOCK_NEED_QS; |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /* |
| 488 | * Process callbacks for preemptable RCU. |
| 489 | */ |
| 490 | static void rcu_preempt_process_callbacks(void) |
| 491 | { |
| 492 | __rcu_process_callbacks(&rcu_preempt_state, |
| 493 | &__get_cpu_var(rcu_preempt_data)); |
| 494 | } |
| 495 | |
| 496 | /* |
| 497 | * Queue a preemptable-RCU callback for invocation after a grace period. |
| 498 | */ |
| 499 | void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) |
| 500 | { |
| 501 | __call_rcu(head, func, &rcu_preempt_state); |
| 502 | } |
| 503 | EXPORT_SYMBOL_GPL(call_rcu); |
| 504 | |
Paul E. McKenney | 6ebb237 | 2009-11-22 08:53:50 -0800 | [diff] [blame] | 505 | /** |
| 506 | * synchronize_rcu - wait until a grace period has elapsed. |
| 507 | * |
| 508 | * Control will return to the caller some time after a full grace |
| 509 | * period has elapsed, in other words after all currently executing RCU |
| 510 | * read-side critical sections have completed. RCU read-side critical |
| 511 | * sections are delimited by rcu_read_lock() and rcu_read_unlock(), |
| 512 | * and may be nested. |
| 513 | */ |
| 514 | void synchronize_rcu(void) |
| 515 | { |
| 516 | struct rcu_synchronize rcu; |
| 517 | |
| 518 | if (!rcu_scheduler_active) |
| 519 | return; |
| 520 | |
| 521 | init_completion(&rcu.completion); |
| 522 | /* Will wake me after RCU finished. */ |
| 523 | call_rcu(&rcu.head, wakeme_after_rcu); |
| 524 | /* Wait for it. */ |
| 525 | wait_for_completion(&rcu.completion); |
| 526 | } |
| 527 | EXPORT_SYMBOL_GPL(synchronize_rcu); |
| 528 | |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 529 | static DECLARE_WAIT_QUEUE_HEAD(sync_rcu_preempt_exp_wq); |
| 530 | static long sync_rcu_preempt_exp_count; |
| 531 | static DEFINE_MUTEX(sync_rcu_preempt_exp_mutex); |
| 532 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 533 | /* |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 534 | * Return non-zero if there are any tasks in RCU read-side critical |
| 535 | * sections blocking the current preemptible-RCU expedited grace period. |
| 536 | * If there is no preemptible-RCU expedited grace period currently in |
| 537 | * progress, returns zero unconditionally. |
| 538 | */ |
| 539 | static int rcu_preempted_readers_exp(struct rcu_node *rnp) |
| 540 | { |
| 541 | return !list_empty(&rnp->blocked_tasks[2]) || |
| 542 | !list_empty(&rnp->blocked_tasks[3]); |
| 543 | } |
| 544 | |
| 545 | /* |
| 546 | * return non-zero if there is no RCU expedited grace period in progress |
| 547 | * for the specified rcu_node structure, in other words, if all CPUs and |
| 548 | * tasks covered by the specified rcu_node structure have done their bit |
| 549 | * for the current expedited grace period. Works only for preemptible |
| 550 | * RCU -- other RCU implementation use other means. |
| 551 | * |
| 552 | * Caller must hold sync_rcu_preempt_exp_mutex. |
| 553 | */ |
| 554 | static int sync_rcu_preempt_exp_done(struct rcu_node *rnp) |
| 555 | { |
| 556 | return !rcu_preempted_readers_exp(rnp) && |
| 557 | ACCESS_ONCE(rnp->expmask) == 0; |
| 558 | } |
| 559 | |
| 560 | /* |
| 561 | * Report the exit from RCU read-side critical section for the last task |
| 562 | * that queued itself during or before the current expedited preemptible-RCU |
| 563 | * grace period. This event is reported either to the rcu_node structure on |
| 564 | * which the task was queued or to one of that rcu_node structure's ancestors, |
| 565 | * recursively up the tree. (Calm down, calm down, we do the recursion |
| 566 | * iteratively!) |
| 567 | * |
| 568 | * Caller must hold sync_rcu_preempt_exp_mutex. |
| 569 | */ |
| 570 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp) |
| 571 | { |
| 572 | unsigned long flags; |
| 573 | unsigned long mask; |
| 574 | |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 575 | raw_spin_lock_irqsave(&rnp->lock, flags); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 576 | for (;;) { |
| 577 | if (!sync_rcu_preempt_exp_done(rnp)) |
| 578 | break; |
| 579 | if (rnp->parent == NULL) { |
| 580 | wake_up(&sync_rcu_preempt_exp_wq); |
| 581 | break; |
| 582 | } |
| 583 | mask = rnp->grpmask; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 584 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 585 | rnp = rnp->parent; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 586 | raw_spin_lock(&rnp->lock); /* irqs already disabled */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 587 | rnp->expmask &= ~mask; |
| 588 | } |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 589 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /* |
| 593 | * Snapshot the tasks blocking the newly started preemptible-RCU expedited |
| 594 | * grace period for the specified rcu_node structure. If there are no such |
| 595 | * tasks, report it up the rcu_node hierarchy. |
| 596 | * |
| 597 | * Caller must hold sync_rcu_preempt_exp_mutex and rsp->onofflock. |
| 598 | */ |
| 599 | static void |
| 600 | sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp) |
| 601 | { |
| 602 | int must_wait; |
| 603 | |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 604 | raw_spin_lock(&rnp->lock); /* irqs already disabled */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 605 | list_splice_init(&rnp->blocked_tasks[0], &rnp->blocked_tasks[2]); |
| 606 | list_splice_init(&rnp->blocked_tasks[1], &rnp->blocked_tasks[3]); |
| 607 | must_wait = rcu_preempted_readers_exp(rnp); |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 608 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 609 | if (!must_wait) |
| 610 | rcu_report_exp_rnp(rsp, rnp); |
| 611 | } |
| 612 | |
| 613 | /* |
| 614 | * Wait for an rcu-preempt grace period, but expedite it. The basic idea |
| 615 | * is to invoke synchronize_sched_expedited() to push all the tasks to |
| 616 | * the ->blocked_tasks[] lists, move all entries from the first set of |
| 617 | * ->blocked_tasks[] lists to the second set, and finally wait for this |
| 618 | * second set to drain. |
Paul E. McKenney | 019129d5 | 2009-10-14 10:15:56 -0700 | [diff] [blame] | 619 | */ |
| 620 | void synchronize_rcu_expedited(void) |
| 621 | { |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 622 | unsigned long flags; |
| 623 | struct rcu_node *rnp; |
| 624 | struct rcu_state *rsp = &rcu_preempt_state; |
| 625 | long snap; |
| 626 | int trycount = 0; |
| 627 | |
| 628 | smp_mb(); /* Caller's modifications seen first by other CPUs. */ |
| 629 | snap = ACCESS_ONCE(sync_rcu_preempt_exp_count) + 1; |
| 630 | smp_mb(); /* Above access cannot bleed into critical section. */ |
| 631 | |
| 632 | /* |
| 633 | * Acquire lock, falling back to synchronize_rcu() if too many |
| 634 | * lock-acquisition failures. Of course, if someone does the |
| 635 | * expedited grace period for us, just leave. |
| 636 | */ |
| 637 | while (!mutex_trylock(&sync_rcu_preempt_exp_mutex)) { |
| 638 | if (trycount++ < 10) |
| 639 | udelay(trycount * num_online_cpus()); |
| 640 | else { |
| 641 | synchronize_rcu(); |
| 642 | return; |
| 643 | } |
| 644 | if ((ACCESS_ONCE(sync_rcu_preempt_exp_count) - snap) > 0) |
| 645 | goto mb_ret; /* Others did our work for us. */ |
| 646 | } |
| 647 | if ((ACCESS_ONCE(sync_rcu_preempt_exp_count) - snap) > 0) |
| 648 | goto unlock_mb_ret; /* Others did our work for us. */ |
| 649 | |
| 650 | /* force all RCU readers onto blocked_tasks[]. */ |
| 651 | synchronize_sched_expedited(); |
| 652 | |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 653 | raw_spin_lock_irqsave(&rsp->onofflock, flags); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 654 | |
| 655 | /* Initialize ->expmask for all non-leaf rcu_node structures. */ |
| 656 | rcu_for_each_nonleaf_node_breadth_first(rsp, rnp) { |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 657 | raw_spin_lock(&rnp->lock); /* irqs already disabled. */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 658 | rnp->expmask = rnp->qsmaskinit; |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 659 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | /* Snapshot current state of ->blocked_tasks[] lists. */ |
| 663 | rcu_for_each_leaf_node(rsp, rnp) |
| 664 | sync_rcu_preempt_exp_init(rsp, rnp); |
| 665 | if (NUM_RCU_NODES > 1) |
| 666 | sync_rcu_preempt_exp_init(rsp, rcu_get_root(rsp)); |
| 667 | |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 668 | raw_spin_unlock_irqrestore(&rsp->onofflock, flags); |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 669 | |
| 670 | /* Wait for snapshotted ->blocked_tasks[] lists to drain. */ |
| 671 | rnp = rcu_get_root(rsp); |
| 672 | wait_event(sync_rcu_preempt_exp_wq, |
| 673 | sync_rcu_preempt_exp_done(rnp)); |
| 674 | |
| 675 | /* Clean up and exit. */ |
| 676 | smp_mb(); /* ensure expedited GP seen before counter increment. */ |
| 677 | ACCESS_ONCE(sync_rcu_preempt_exp_count)++; |
| 678 | unlock_mb_ret: |
| 679 | mutex_unlock(&sync_rcu_preempt_exp_mutex); |
| 680 | mb_ret: |
| 681 | smp_mb(); /* ensure subsequent action seen after grace period. */ |
Paul E. McKenney | 019129d5 | 2009-10-14 10:15:56 -0700 | [diff] [blame] | 682 | } |
| 683 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); |
| 684 | |
| 685 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 686 | * Check to see if there is any immediate preemptable-RCU-related work |
| 687 | * to be done. |
| 688 | */ |
| 689 | static int rcu_preempt_pending(int cpu) |
| 690 | { |
| 691 | return __rcu_pending(&rcu_preempt_state, |
| 692 | &per_cpu(rcu_preempt_data, cpu)); |
| 693 | } |
| 694 | |
| 695 | /* |
| 696 | * Does preemptable RCU need the CPU to stay out of dynticks mode? |
| 697 | */ |
| 698 | static int rcu_preempt_needs_cpu(int cpu) |
| 699 | { |
| 700 | return !!per_cpu(rcu_preempt_data, cpu).nxtlist; |
| 701 | } |
| 702 | |
Paul E. McKenney | e74f4c4 | 2009-10-06 21:48:17 -0700 | [diff] [blame] | 703 | /** |
| 704 | * rcu_barrier - Wait until all in-flight call_rcu() callbacks complete. |
| 705 | */ |
| 706 | void rcu_barrier(void) |
| 707 | { |
| 708 | _rcu_barrier(&rcu_preempt_state, call_rcu); |
| 709 | } |
| 710 | EXPORT_SYMBOL_GPL(rcu_barrier); |
| 711 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 712 | /* |
| 713 | * Initialize preemptable RCU's per-CPU data. |
| 714 | */ |
| 715 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu) |
| 716 | { |
| 717 | rcu_init_percpu_data(cpu, &rcu_preempt_state, 1); |
| 718 | } |
| 719 | |
| 720 | /* |
Paul E. McKenney | e74f4c4 | 2009-10-06 21:48:17 -0700 | [diff] [blame] | 721 | * Move preemptable RCU's callbacks to ->orphan_cbs_list. |
| 722 | */ |
| 723 | static void rcu_preempt_send_cbs_to_orphanage(void) |
| 724 | { |
| 725 | rcu_send_cbs_to_orphanage(&rcu_preempt_state); |
| 726 | } |
| 727 | |
| 728 | /* |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 729 | * Initialize preemptable RCU's state structures. |
| 730 | */ |
| 731 | static void __init __rcu_init_preempt(void) |
| 732 | { |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 733 | RCU_INIT_FLAVOR(&rcu_preempt_state, rcu_preempt_data); |
| 734 | } |
| 735 | |
| 736 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 737 | * Check for a task exiting while in a preemptable-RCU read-side |
| 738 | * critical section, clean up if so. No need to issue warnings, |
| 739 | * as debug_check_no_locks_held() already does this if lockdep |
| 740 | * is enabled. |
| 741 | */ |
| 742 | void exit_rcu(void) |
| 743 | { |
| 744 | struct task_struct *t = current; |
| 745 | |
| 746 | if (t->rcu_read_lock_nesting == 0) |
| 747 | return; |
| 748 | t->rcu_read_lock_nesting = 1; |
| 749 | rcu_read_unlock(); |
| 750 | } |
| 751 | |
| 752 | #else /* #ifdef CONFIG_TREE_PREEMPT_RCU */ |
| 753 | |
| 754 | /* |
| 755 | * Tell them what RCU they are running. |
| 756 | */ |
Paul E. McKenney | 0e0fc1c | 2009-11-11 11:28:06 -0800 | [diff] [blame] | 757 | static void __init rcu_bootup_announce(void) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 758 | { |
| 759 | printk(KERN_INFO "Hierarchical RCU implementation.\n"); |
| 760 | } |
| 761 | |
| 762 | /* |
| 763 | * Return the number of RCU batches processed thus far for debug & stats. |
| 764 | */ |
| 765 | long rcu_batches_completed(void) |
| 766 | { |
| 767 | return rcu_batches_completed_sched(); |
| 768 | } |
| 769 | EXPORT_SYMBOL_GPL(rcu_batches_completed); |
| 770 | |
| 771 | /* |
Paul E. McKenney | bf66f18 | 2010-01-04 15:09:10 -0800 | [diff] [blame] | 772 | * Force a quiescent state for RCU, which, because there is no preemptible |
| 773 | * RCU, becomes the same as rcu-sched. |
| 774 | */ |
| 775 | void rcu_force_quiescent_state(void) |
| 776 | { |
| 777 | rcu_sched_force_quiescent_state(); |
| 778 | } |
| 779 | EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); |
| 780 | |
| 781 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 782 | * Because preemptable RCU does not exist, we never have to check for |
| 783 | * CPUs being in quiescent states. |
| 784 | */ |
Paul E. McKenney | c3422be | 2009-09-13 09:15:10 -0700 | [diff] [blame] | 785 | static void rcu_preempt_note_context_switch(int cpu) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 786 | { |
| 787 | } |
| 788 | |
Paul E. McKenney | fc2219d | 2009-09-23 09:50:41 -0700 | [diff] [blame] | 789 | /* |
| 790 | * Because preemptable RCU does not exist, there are never any preempted |
| 791 | * RCU readers. |
| 792 | */ |
| 793 | static int rcu_preempted_readers(struct rcu_node *rnp) |
| 794 | { |
| 795 | return 0; |
| 796 | } |
| 797 | |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 798 | #ifdef CONFIG_HOTPLUG_CPU |
| 799 | |
| 800 | /* Because preemptible RCU does not exist, no quieting of tasks. */ |
Paul E. McKenney | d3f6bad | 2009-12-02 12:10:13 -0800 | [diff] [blame] | 801 | static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags) |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 802 | { |
Paul E. McKenney | 1304afb | 2010-02-22 17:05:02 -0800 | [diff] [blame] | 803 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
Paul E. McKenney | b668c9c | 2009-11-22 08:53:48 -0800 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 807 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 808 | #ifdef CONFIG_RCU_CPU_STALL_DETECTOR |
| 809 | |
| 810 | /* |
| 811 | * Because preemptable RCU does not exist, we never have to check for |
| 812 | * tasks blocked within RCU read-side critical sections. |
| 813 | */ |
Paul E. McKenney | 1ed509a | 2010-02-22 17:05:05 -0800 | [diff] [blame] | 814 | static void rcu_print_detail_task_stall(struct rcu_state *rsp) |
| 815 | { |
| 816 | } |
| 817 | |
| 818 | /* |
| 819 | * Because preemptable RCU does not exist, we never have to check for |
| 820 | * tasks blocked within RCU read-side critical sections. |
| 821 | */ |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 822 | static void rcu_print_task_stall(struct rcu_node *rnp) |
| 823 | { |
| 824 | } |
| 825 | |
| 826 | #endif /* #ifdef CONFIG_RCU_CPU_STALL_DETECTOR */ |
| 827 | |
| 828 | /* |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 829 | * Because there is no preemptable RCU, there can be no readers blocked, |
Paul E. McKenney | 49e2912 | 2009-09-18 09:50:19 -0700 | [diff] [blame] | 830 | * so there is no need to check for blocked tasks. So check only for |
| 831 | * bogus qsmask values. |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 832 | */ |
| 833 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
| 834 | { |
Paul E. McKenney | 49e2912 | 2009-09-18 09:50:19 -0700 | [diff] [blame] | 835 | WARN_ON_ONCE(rnp->qsmask); |
Paul E. McKenney | b0e165c | 2009-09-13 09:15:09 -0700 | [diff] [blame] | 836 | } |
| 837 | |
Paul E. McKenney | 33f7614 | 2009-08-24 09:42:01 -0700 | [diff] [blame] | 838 | #ifdef CONFIG_HOTPLUG_CPU |
| 839 | |
| 840 | /* |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 841 | * Because preemptable RCU does not exist, it never needs to migrate |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 842 | * tasks that were blocked within RCU read-side critical sections, and |
| 843 | * such non-existent tasks cannot possibly have been blocking the current |
| 844 | * grace period. |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 845 | */ |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 846 | static int rcu_preempt_offline_tasks(struct rcu_state *rsp, |
| 847 | struct rcu_node *rnp, |
| 848 | struct rcu_data *rdp) |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 849 | { |
Paul E. McKenney | 237c80c | 2009-10-15 09:26:14 -0700 | [diff] [blame] | 850 | return 0; |
Paul E. McKenney | dd5d19b | 2009-08-27 14:58:16 -0700 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | /* |
Paul E. McKenney | 33f7614 | 2009-08-24 09:42:01 -0700 | [diff] [blame] | 854 | * Because preemptable RCU does not exist, it never needs CPU-offline |
| 855 | * processing. |
| 856 | */ |
| 857 | static void rcu_preempt_offline_cpu(int cpu) |
| 858 | { |
| 859 | } |
| 860 | |
| 861 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 862 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 863 | /* |
| 864 | * Because preemptable RCU does not exist, it never has any callbacks |
| 865 | * to check. |
| 866 | */ |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 867 | static void rcu_preempt_check_callbacks(int cpu) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 868 | { |
| 869 | } |
| 870 | |
| 871 | /* |
| 872 | * Because preemptable RCU does not exist, it never has any callbacks |
| 873 | * to process. |
| 874 | */ |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 875 | static void rcu_preempt_process_callbacks(void) |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 876 | { |
| 877 | } |
| 878 | |
| 879 | /* |
| 880 | * In classic RCU, call_rcu() is just call_rcu_sched(). |
| 881 | */ |
| 882 | void call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) |
| 883 | { |
| 884 | call_rcu_sched(head, func); |
| 885 | } |
| 886 | EXPORT_SYMBOL_GPL(call_rcu); |
| 887 | |
| 888 | /* |
Paul E. McKenney | 019129d5 | 2009-10-14 10:15:56 -0700 | [diff] [blame] | 889 | * Wait for an rcu-preempt grace period, but make it happen quickly. |
| 890 | * But because preemptable RCU does not exist, map to rcu-sched. |
| 891 | */ |
| 892 | void synchronize_rcu_expedited(void) |
| 893 | { |
| 894 | synchronize_sched_expedited(); |
| 895 | } |
| 896 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); |
| 897 | |
Paul E. McKenney | d9a3da0 | 2009-12-02 12:10:15 -0800 | [diff] [blame] | 898 | #ifdef CONFIG_HOTPLUG_CPU |
| 899 | |
| 900 | /* |
| 901 | * Because preemptable RCU does not exist, there is never any need to |
| 902 | * report on tasks preempted in RCU read-side critical sections during |
| 903 | * expedited RCU grace periods. |
| 904 | */ |
| 905 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp) |
| 906 | { |
| 907 | return; |
| 908 | } |
| 909 | |
| 910 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 911 | |
Paul E. McKenney | 019129d5 | 2009-10-14 10:15:56 -0700 | [diff] [blame] | 912 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 913 | * Because preemptable RCU does not exist, it never has any work to do. |
| 914 | */ |
| 915 | static int rcu_preempt_pending(int cpu) |
| 916 | { |
| 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | /* |
| 921 | * Because preemptable RCU does not exist, it never needs any CPU. |
| 922 | */ |
| 923 | static int rcu_preempt_needs_cpu(int cpu) |
| 924 | { |
| 925 | return 0; |
| 926 | } |
| 927 | |
| 928 | /* |
Paul E. McKenney | e74f4c4 | 2009-10-06 21:48:17 -0700 | [diff] [blame] | 929 | * Because preemptable RCU does not exist, rcu_barrier() is just |
| 930 | * another name for rcu_barrier_sched(). |
| 931 | */ |
| 932 | void rcu_barrier(void) |
| 933 | { |
| 934 | rcu_barrier_sched(); |
| 935 | } |
| 936 | EXPORT_SYMBOL_GPL(rcu_barrier); |
| 937 | |
| 938 | /* |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 939 | * Because preemptable RCU does not exist, there is no per-CPU |
| 940 | * data to initialize. |
| 941 | */ |
| 942 | static void __cpuinit rcu_preempt_init_percpu_data(int cpu) |
| 943 | { |
| 944 | } |
| 945 | |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 946 | /* |
Paul E. McKenney | e74f4c4 | 2009-10-06 21:48:17 -0700 | [diff] [blame] | 947 | * Because there is no preemptable RCU, there are no callbacks to move. |
| 948 | */ |
| 949 | static void rcu_preempt_send_cbs_to_orphanage(void) |
| 950 | { |
| 951 | } |
| 952 | |
| 953 | /* |
Paul E. McKenney | 1eba8f8 | 2009-09-23 09:50:42 -0700 | [diff] [blame] | 954 | * Because preemptable RCU does not exist, it need not be initialized. |
| 955 | */ |
| 956 | static void __init __rcu_init_preempt(void) |
| 957 | { |
| 958 | } |
| 959 | |
Paul E. McKenney | f41d911 | 2009-08-22 13:56:52 -0700 | [diff] [blame] | 960 | #endif /* #else #ifdef CONFIG_TREE_PREEMPT_RCU */ |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 961 | |
| 962 | #if !defined(CONFIG_RCU_FAST_NO_HZ) |
| 963 | |
| 964 | /* |
| 965 | * Check to see if any future RCU-related work will need to be done |
| 966 | * by the current CPU, even if none need be done immediately, returning |
| 967 | * 1 if so. This function is part of the RCU implementation; it is -not- |
| 968 | * an exported member of the RCU API. |
| 969 | * |
| 970 | * Because we have preemptible RCU, just check whether this CPU needs |
| 971 | * any flavor of RCU. Do not chew up lots of CPU cycles with preemption |
| 972 | * disabled in a most-likely vain attempt to cause RCU not to need this CPU. |
| 973 | */ |
| 974 | int rcu_needs_cpu(int cpu) |
| 975 | { |
| 976 | return rcu_needs_cpu_quick_check(cpu); |
| 977 | } |
| 978 | |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 979 | /* |
| 980 | * Check to see if we need to continue a callback-flush operations to |
| 981 | * allow the last CPU to enter dyntick-idle mode. But fast dyntick-idle |
| 982 | * entry is not configured, so we never do need to. |
| 983 | */ |
| 984 | static void rcu_needs_cpu_flush(void) |
| 985 | { |
| 986 | } |
| 987 | |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 988 | #else /* #if !defined(CONFIG_RCU_FAST_NO_HZ) */ |
| 989 | |
| 990 | #define RCU_NEEDS_CPU_FLUSHES 5 |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 991 | static DEFINE_PER_CPU(int, rcu_dyntick_drain); |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 992 | static DEFINE_PER_CPU(unsigned long, rcu_dyntick_holdoff); |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 993 | |
| 994 | /* |
| 995 | * Check to see if any future RCU-related work will need to be done |
| 996 | * by the current CPU, even if none need be done immediately, returning |
| 997 | * 1 if so. This function is part of the RCU implementation; it is -not- |
| 998 | * an exported member of the RCU API. |
| 999 | * |
| 1000 | * Because we are not supporting preemptible RCU, attempt to accelerate |
| 1001 | * any current grace periods so that RCU no longer needs this CPU, but |
| 1002 | * only if all other CPUs are already in dynticks-idle mode. This will |
| 1003 | * allow the CPU cores to be powered down immediately, as opposed to after |
| 1004 | * waiting many milliseconds for grace periods to elapse. |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1005 | * |
| 1006 | * Because it is not legal to invoke rcu_process_callbacks() with irqs |
| 1007 | * disabled, we do one pass of force_quiescent_state(), then do a |
| 1008 | * raise_softirq() to cause rcu_process_callbacks() to be invoked later. |
| 1009 | * The per-cpu rcu_dyntick_drain variable controls the sequencing. |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1010 | */ |
| 1011 | int rcu_needs_cpu(int cpu) |
| 1012 | { |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1013 | int c = 0; |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1014 | int thatcpu; |
| 1015 | |
Paul E. McKenney | 622ea68 | 2010-02-27 14:53:07 -0800 | [diff] [blame] | 1016 | /* Check for being in the holdoff period. */ |
| 1017 | if (per_cpu(rcu_dyntick_holdoff, cpu) == jiffies) |
| 1018 | return rcu_needs_cpu_quick_check(cpu); |
| 1019 | |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1020 | /* Don't bother unless we are the last non-dyntick-idle CPU. */ |
| 1021 | for_each_cpu_not(thatcpu, nohz_cpu_mask) |
Lai Jiangshan | 5db3567 | 2010-03-30 18:40:36 +0800 | [diff] [blame] | 1022 | if (cpu_online(thatcpu) && thatcpu != cpu) { |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1023 | per_cpu(rcu_dyntick_drain, cpu) = 0; |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 1024 | per_cpu(rcu_dyntick_holdoff, cpu) = jiffies - 1; |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1025 | return rcu_needs_cpu_quick_check(cpu); |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1026 | } |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1027 | |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1028 | /* Check and update the rcu_dyntick_drain sequencing. */ |
| 1029 | if (per_cpu(rcu_dyntick_drain, cpu) <= 0) { |
| 1030 | /* First time through, initialize the counter. */ |
| 1031 | per_cpu(rcu_dyntick_drain, cpu) = RCU_NEEDS_CPU_FLUSHES; |
| 1032 | } else if (--per_cpu(rcu_dyntick_drain, cpu) <= 0) { |
| 1033 | /* We have hit the limit, so time to give up. */ |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 1034 | per_cpu(rcu_dyntick_holdoff, cpu) = jiffies; |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1035 | return rcu_needs_cpu_quick_check(cpu); |
| 1036 | } |
| 1037 | |
| 1038 | /* Do one step pushing remaining RCU callbacks through. */ |
| 1039 | if (per_cpu(rcu_sched_data, cpu).nxtlist) { |
| 1040 | rcu_sched_qs(cpu); |
| 1041 | force_quiescent_state(&rcu_sched_state, 0); |
| 1042 | c = c || per_cpu(rcu_sched_data, cpu).nxtlist; |
| 1043 | } |
| 1044 | if (per_cpu(rcu_bh_data, cpu).nxtlist) { |
| 1045 | rcu_bh_qs(cpu); |
| 1046 | force_quiescent_state(&rcu_bh_state, 0); |
| 1047 | c = c || per_cpu(rcu_bh_data, cpu).nxtlist; |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1048 | } |
| 1049 | |
| 1050 | /* If RCU callbacks are still pending, RCU still needs this CPU. */ |
Paul E. McKenney | 622ea68 | 2010-02-27 14:53:07 -0800 | [diff] [blame] | 1051 | if (c) |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1052 | raise_softirq(RCU_SOFTIRQ); |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1053 | return c; |
| 1054 | } |
| 1055 | |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1056 | /* |
| 1057 | * Check to see if we need to continue a callback-flush operations to |
| 1058 | * allow the last CPU to enter dyntick-idle mode. |
| 1059 | */ |
| 1060 | static void rcu_needs_cpu_flush(void) |
| 1061 | { |
| 1062 | int cpu = smp_processor_id(); |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 1063 | unsigned long flags; |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1064 | |
| 1065 | if (per_cpu(rcu_dyntick_drain, cpu) <= 0) |
| 1066 | return; |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 1067 | local_irq_save(flags); |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1068 | (void)rcu_needs_cpu(cpu); |
Paul E. McKenney | 71da813 | 2010-02-26 16:38:58 -0800 | [diff] [blame] | 1069 | local_irq_restore(flags); |
Paul E. McKenney | a47cd88 | 2010-02-26 16:38:56 -0800 | [diff] [blame] | 1070 | } |
| 1071 | |
Paul E. McKenney | 8bd93a2 | 2010-02-22 17:04:59 -0800 | [diff] [blame] | 1072 | #endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */ |