aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcutree_plugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/rcutree_plugin.h')
-rw-r--r--kernel/rcutree_plugin.h85
1 files changed, 61 insertions, 24 deletions
diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
index 5ca2d26c5971..0bdb592eee66 100644
--- a/kernel/rcutree_plugin.h
+++ b/kernel/rcutree_plugin.h
@@ -160,11 +160,51 @@ static int rcu_preempted_readers(struct rcu_node *rnp)
160 return !list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]); 160 return !list_empty(&rnp->blocked_tasks[rnp->gpnum & 0x1]);
161} 161}
162 162
163/*
164 * Record a quiescent state for all tasks that were previously queued
165 * on the specified rcu_node structure and that were blocking the current
166 * RCU grace period. The caller must hold the specified rnp->lock with
167 * irqs disabled, and this lock is released upon return, but irqs remain
168 * disabled.
169 */
170static void task_quiet(struct rcu_node *rnp, unsigned long flags)
171 __releases(rnp->lock)
172{
173 unsigned long mask;
174 struct rcu_node *rnp_p;
175
176 if (rnp->qsmask != 0 || rcu_preempted_readers(rnp)) {
177 spin_unlock_irqrestore(&rnp->lock, flags);
178 return; /* Still need more quiescent states! */
179 }
180
181 rnp_p = rnp->parent;
182 if (rnp_p == NULL) {
183 /*
184 * Either there is only one rcu_node in the tree,
185 * or tasks were kicked up to root rcu_node due to
186 * CPUs going offline.
187 */
188 cpu_quiet_msk_finish(&rcu_preempt_state, flags);
189 return;
190 }
191
192 /* Report up the rest of the hierarchy. */
193 mask = rnp->grpmask;
194 spin_unlock(&rnp->lock); /* irqs remain disabled. */
195 spin_lock(&rnp_p->lock); /* irqs already disabled. */
196 cpu_quiet_msk(mask, &rcu_preempt_state, rnp_p, flags);
197}
198
199/*
200 * Handle special cases during rcu_read_unlock(), such as needing to
201 * notify RCU core processing or task having blocked during the RCU
202 * read-side critical section.
203 */
163static void rcu_read_unlock_special(struct task_struct *t) 204static void rcu_read_unlock_special(struct task_struct *t)
164{ 205{
165 int empty; 206 int empty;
166 unsigned long flags; 207 unsigned long flags;
167 unsigned long mask;
168 struct rcu_node *rnp; 208 struct rcu_node *rnp;
169 int special; 209 int special;
170 210
@@ -213,30 +253,15 @@ static void rcu_read_unlock_special(struct task_struct *t)
213 /* 253 /*
214 * If this was the last task on the current list, and if 254 * If this was the last task on the current list, and if
215 * we aren't waiting on any CPUs, report the quiescent state. 255 * we aren't waiting on any CPUs, report the quiescent state.
216 * Note that both cpu_quiet_msk_finish() and cpu_quiet_msk() 256 * Note that task_quiet() releases rnp->lock.
217 * drop rnp->lock and restore irq.
218 */ 257 */
219 if (!empty && rnp->qsmask == 0 && 258 if (empty)
220 !rcu_preempted_readers(rnp)) {
221 struct rcu_node *rnp_p;
222
223 if (rnp->parent == NULL) {
224 /* Only one rcu_node in the tree. */
225 cpu_quiet_msk_finish(&rcu_preempt_state, flags);
226 return;
227 }
228 /* Report up the rest of the hierarchy. */
229 mask = rnp->grpmask;
230 spin_unlock_irqrestore(&rnp->lock, flags); 259 spin_unlock_irqrestore(&rnp->lock, flags);
231 rnp_p = rnp->parent; 260 else
232 spin_lock_irqsave(&rnp_p->lock, flags); 261 task_quiet(rnp, flags);
233 WARN_ON_ONCE(rnp->qsmask); 262 } else {
234 cpu_quiet_msk(mask, &rcu_preempt_state, rnp_p, flags); 263 local_irq_restore(flags);
235 return;
236 }
237 spin_unlock(&rnp->lock);
238 } 264 }
239 local_irq_restore(flags);
240} 265}
241 266
242/* 267/*
@@ -303,6 +328,8 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp)
303 * rcu_node. The reason for not just moving them to the immediate 328 * rcu_node. The reason for not just moving them to the immediate
304 * parent is to remove the need for rcu_read_unlock_special() to 329 * parent is to remove the need for rcu_read_unlock_special() to
305 * make more than two attempts to acquire the target rcu_node's lock. 330 * make more than two attempts to acquire the target rcu_node's lock.
331 * Returns true if there were tasks blocking the current RCU grace
332 * period.
306 * 333 *
307 * Returns 1 if there was previously a task blocking the current grace 334 * Returns 1 if there was previously a task blocking the current grace
308 * period on the specified rcu_node structure. 335 * period on the specified rcu_node structure.
@@ -316,7 +343,7 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
316 int i; 343 int i;
317 struct list_head *lp; 344 struct list_head *lp;
318 struct list_head *lp_root; 345 struct list_head *lp_root;
319 int retval = rcu_preempted_readers(rnp); 346 int retval;
320 struct rcu_node *rnp_root = rcu_get_root(rsp); 347 struct rcu_node *rnp_root = rcu_get_root(rsp);
321 struct task_struct *tp; 348 struct task_struct *tp;
322 349
@@ -334,6 +361,7 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
334 * rcu_nodes in terms of gp_num value. This fact allows us to 361 * rcu_nodes in terms of gp_num value. This fact allows us to
335 * move the blocked_tasks[] array directly, element by element. 362 * move the blocked_tasks[] array directly, element by element.
336 */ 363 */
364 retval = rcu_preempted_readers(rnp);
337 for (i = 0; i < 2; i++) { 365 for (i = 0; i < 2; i++) {
338 lp = &rnp->blocked_tasks[i]; 366 lp = &rnp->blocked_tasks[i];
339 lp_root = &rnp_root->blocked_tasks[i]; 367 lp_root = &rnp_root->blocked_tasks[i];
@@ -346,7 +374,6 @@ static int rcu_preempt_offline_tasks(struct rcu_state *rsp,
346 spin_unlock(&rnp_root->lock); /* irqs remain disabled */ 374 spin_unlock(&rnp_root->lock); /* irqs remain disabled */
347 } 375 }
348 } 376 }
349
350 return retval; 377 return retval;
351} 378}
352 379
@@ -512,6 +539,16 @@ static int rcu_preempted_readers(struct rcu_node *rnp)
512 return 0; 539 return 0;
513} 540}
514 541
542#ifdef CONFIG_HOTPLUG_CPU
543
544/* Because preemptible RCU does not exist, no quieting of tasks. */
545static void task_quiet(struct rcu_node *rnp, unsigned long flags)
546{
547 spin_unlock_irqrestore(&rnp->lock, flags);
548}
549
550#endif /* #ifdef CONFIG_HOTPLUG_CPU */
551
515#ifdef CONFIG_RCU_CPU_STALL_DETECTOR 552#ifdef CONFIG_RCU_CPU_STALL_DETECTOR
516 553
517/* 554/*