aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rcutree.c
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2013-05-02 11:37:49 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2013-05-02 11:54:19 -0400
commitc032862fba51a3ca504752d3a25186b324c5ce83 (patch)
tree955dc2ba4ab3df76ecc2bb780ee84aca04967e8d /kernel/rcutree.c
parentfda76e074c7737fc57855dd17c762e50ed526052 (diff)
parent8700c95adb033843fc163d112b9d21d4fda78018 (diff)
Merge commit '8700c95adb03' into timers/nohz
The full dynticks tree needs the latest RCU and sched upstream updates in order to fix some dependencies. Merge a common upstream merge point that has these updates. Conflicts: include/linux/perf_event.h kernel/rcutree.h kernel/rcutree_plugin.h Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Diffstat (limited to 'kernel/rcutree.c')
-rw-r--r--kernel/rcutree.c260
1 files changed, 197 insertions, 63 deletions
diff --git a/kernel/rcutree.c b/kernel/rcutree.c
index 1d4ceff793a4..16ea67925015 100644
--- a/kernel/rcutree.c
+++ b/kernel/rcutree.c
@@ -64,7 +64,7 @@
64static struct lock_class_key rcu_node_class[RCU_NUM_LVLS]; 64static struct lock_class_key rcu_node_class[RCU_NUM_LVLS];
65static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS]; 65static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS];
66 66
67#define RCU_STATE_INITIALIZER(sname, cr) { \ 67#define RCU_STATE_INITIALIZER(sname, sabbr, cr) { \
68 .level = { &sname##_state.node[0] }, \ 68 .level = { &sname##_state.node[0] }, \
69 .call = cr, \ 69 .call = cr, \
70 .fqs_state = RCU_GP_IDLE, \ 70 .fqs_state = RCU_GP_IDLE, \
@@ -76,13 +76,14 @@ static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS];
76 .barrier_mutex = __MUTEX_INITIALIZER(sname##_state.barrier_mutex), \ 76 .barrier_mutex = __MUTEX_INITIALIZER(sname##_state.barrier_mutex), \
77 .onoff_mutex = __MUTEX_INITIALIZER(sname##_state.onoff_mutex), \ 77 .onoff_mutex = __MUTEX_INITIALIZER(sname##_state.onoff_mutex), \
78 .name = #sname, \ 78 .name = #sname, \
79 .abbr = sabbr, \
79} 80}
80 81
81struct rcu_state rcu_sched_state = 82struct rcu_state rcu_sched_state =
82 RCU_STATE_INITIALIZER(rcu_sched, call_rcu_sched); 83 RCU_STATE_INITIALIZER(rcu_sched, 's', call_rcu_sched);
83DEFINE_PER_CPU(struct rcu_data, rcu_sched_data); 84DEFINE_PER_CPU(struct rcu_data, rcu_sched_data);
84 85
85struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh, call_rcu_bh); 86struct rcu_state rcu_bh_state = RCU_STATE_INITIALIZER(rcu_bh, 'b', call_rcu_bh);
86DEFINE_PER_CPU(struct rcu_data, rcu_bh_data); 87DEFINE_PER_CPU(struct rcu_data, rcu_bh_data);
87 88
88static struct rcu_state *rcu_state; 89static struct rcu_state *rcu_state;
@@ -223,6 +224,8 @@ static ulong jiffies_till_next_fqs = RCU_JIFFIES_TILL_FORCE_QS;
223module_param(jiffies_till_first_fqs, ulong, 0644); 224module_param(jiffies_till_first_fqs, ulong, 0644);
224module_param(jiffies_till_next_fqs, ulong, 0644); 225module_param(jiffies_till_next_fqs, ulong, 0644);
225 226
227static void rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
228 struct rcu_data *rdp);
226static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *)); 229static void force_qs_rnp(struct rcu_state *rsp, int (*f)(struct rcu_data *));
227static void force_quiescent_state(struct rcu_state *rsp); 230static void force_quiescent_state(struct rcu_state *rsp);
228static int rcu_pending(int cpu); 231static int rcu_pending(int cpu);
@@ -310,6 +313,8 @@ cpu_needs_another_gp(struct rcu_state *rsp, struct rcu_data *rdp)
310 313
311 if (rcu_gp_in_progress(rsp)) 314 if (rcu_gp_in_progress(rsp))
312 return 0; /* No, a grace period is already in progress. */ 315 return 0; /* No, a grace period is already in progress. */
316 if (rcu_nocb_needs_gp(rsp))
317 return 1; /* Yes, a no-CBs CPU needs one. */
313 if (!rdp->nxttail[RCU_NEXT_TAIL]) 318 if (!rdp->nxttail[RCU_NEXT_TAIL])
314 return 0; /* No, this is a no-CBs (or offline) CPU. */ 319 return 0; /* No, this is a no-CBs (or offline) CPU. */
315 if (*rdp->nxttail[RCU_NEXT_READY_TAIL]) 320 if (*rdp->nxttail[RCU_NEXT_READY_TAIL])
@@ -1045,10 +1050,11 @@ static void init_callback_list(struct rcu_data *rdp)
1045{ 1050{
1046 int i; 1051 int i;
1047 1052
1053 if (init_nocb_callback_list(rdp))
1054 return;
1048 rdp->nxtlist = NULL; 1055 rdp->nxtlist = NULL;
1049 for (i = 0; i < RCU_NEXT_SIZE; i++) 1056 for (i = 0; i < RCU_NEXT_SIZE; i++)
1050 rdp->nxttail[i] = &rdp->nxtlist; 1057 rdp->nxttail[i] = &rdp->nxtlist;
1051 init_nocb_callback_list(rdp);
1052} 1058}
1053 1059
1054/* 1060/*
@@ -1081,6 +1087,120 @@ static unsigned long rcu_cbs_completed(struct rcu_state *rsp,
1081} 1087}
1082 1088
1083/* 1089/*
1090 * Trace-event helper function for rcu_start_future_gp() and
1091 * rcu_nocb_wait_gp().
1092 */
1093static void trace_rcu_future_gp(struct rcu_node *rnp, struct rcu_data *rdp,
1094 unsigned long c, char *s)
1095{
1096 trace_rcu_future_grace_period(rdp->rsp->name, rnp->gpnum,
1097 rnp->completed, c, rnp->level,
1098 rnp->grplo, rnp->grphi, s);
1099}
1100
1101/*
1102 * Start some future grace period, as needed to handle newly arrived
1103 * callbacks. The required future grace periods are recorded in each
1104 * rcu_node structure's ->need_future_gp field.
1105 *
1106 * The caller must hold the specified rcu_node structure's ->lock.
1107 */
1108static unsigned long __maybe_unused
1109rcu_start_future_gp(struct rcu_node *rnp, struct rcu_data *rdp)
1110{
1111 unsigned long c;
1112 int i;
1113 struct rcu_node *rnp_root = rcu_get_root(rdp->rsp);
1114
1115 /*
1116 * Pick up grace-period number for new callbacks. If this
1117 * grace period is already marked as needed, return to the caller.
1118 */
1119 c = rcu_cbs_completed(rdp->rsp, rnp);
1120 trace_rcu_future_gp(rnp, rdp, c, "Startleaf");
1121 if (rnp->need_future_gp[c & 0x1]) {
1122 trace_rcu_future_gp(rnp, rdp, c, "Prestartleaf");
1123 return c;
1124 }
1125
1126 /*
1127 * If either this rcu_node structure or the root rcu_node structure
1128 * believe that a grace period is in progress, then we must wait
1129 * for the one following, which is in "c". Because our request
1130 * will be noticed at the end of the current grace period, we don't
1131 * need to explicitly start one.
1132 */
1133 if (rnp->gpnum != rnp->completed ||
1134 ACCESS_ONCE(rnp->gpnum) != ACCESS_ONCE(rnp->completed)) {
1135 rnp->need_future_gp[c & 0x1]++;
1136 trace_rcu_future_gp(rnp, rdp, c, "Startedleaf");
1137 return c;
1138 }
1139
1140 /*
1141 * There might be no grace period in progress. If we don't already
1142 * hold it, acquire the root rcu_node structure's lock in order to
1143 * start one (if needed).
1144 */
1145 if (rnp != rnp_root)
1146 raw_spin_lock(&rnp_root->lock);
1147
1148 /*
1149 * Get a new grace-period number. If there really is no grace
1150 * period in progress, it will be smaller than the one we obtained
1151 * earlier. Adjust callbacks as needed. Note that even no-CBs
1152 * CPUs have a ->nxtcompleted[] array, so no no-CBs checks needed.
1153 */
1154 c = rcu_cbs_completed(rdp->rsp, rnp_root);
1155 for (i = RCU_DONE_TAIL; i < RCU_NEXT_TAIL; i++)
1156 if (ULONG_CMP_LT(c, rdp->nxtcompleted[i]))
1157 rdp->nxtcompleted[i] = c;
1158
1159 /*
1160 * If the needed for the required grace period is already
1161 * recorded, trace and leave.
1162 */
1163 if (rnp_root->need_future_gp[c & 0x1]) {
1164 trace_rcu_future_gp(rnp, rdp, c, "Prestartedroot");
1165 goto unlock_out;
1166 }
1167
1168 /* Record the need for the future grace period. */
1169 rnp_root->need_future_gp[c & 0x1]++;
1170
1171 /* If a grace period is not already in progress, start one. */
1172 if (rnp_root->gpnum != rnp_root->completed) {
1173 trace_rcu_future_gp(rnp, rdp, c, "Startedleafroot");
1174 } else {
1175 trace_rcu_future_gp(rnp, rdp, c, "Startedroot");
1176 rcu_start_gp_advanced(rdp->rsp, rnp_root, rdp);
1177 }
1178unlock_out:
1179 if (rnp != rnp_root)
1180 raw_spin_unlock(&rnp_root->lock);
1181 return c;
1182}
1183
1184/*
1185 * Clean up any old requests for the just-ended grace period. Also return
1186 * whether any additional grace periods have been requested. Also invoke
1187 * rcu_nocb_gp_cleanup() in order to wake up any no-callbacks kthreads
1188 * waiting for this grace period to complete.
1189 */
1190static int rcu_future_gp_cleanup(struct rcu_state *rsp, struct rcu_node *rnp)
1191{
1192 int c = rnp->completed;
1193 int needmore;
1194 struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
1195
1196 rcu_nocb_gp_cleanup(rsp, rnp);
1197 rnp->need_future_gp[c & 0x1] = 0;
1198 needmore = rnp->need_future_gp[(c + 1) & 0x1];
1199 trace_rcu_future_gp(rnp, rdp, c, needmore ? "CleanupMore" : "Cleanup");
1200 return needmore;
1201}
1202
1203/*
1084 * If there is room, assign a ->completed number to any callbacks on 1204 * If there is room, assign a ->completed number to any callbacks on
1085 * this CPU that have not already been assigned. Also accelerate any 1205 * this CPU that have not already been assigned. Also accelerate any
1086 * callbacks that were previously assigned a ->completed number that has 1206 * callbacks that were previously assigned a ->completed number that has
@@ -1139,6 +1259,8 @@ static void rcu_accelerate_cbs(struct rcu_state *rsp, struct rcu_node *rnp,
1139 rdp->nxttail[i] = rdp->nxttail[RCU_NEXT_TAIL]; 1259 rdp->nxttail[i] = rdp->nxttail[RCU_NEXT_TAIL];
1140 rdp->nxtcompleted[i] = c; 1260 rdp->nxtcompleted[i] = c;
1141 } 1261 }
1262 /* Record any needed additional grace periods. */
1263 rcu_start_future_gp(rnp, rdp);
1142 1264
1143 /* Trace depending on how much we were able to accelerate. */ 1265 /* Trace depending on how much we were able to accelerate. */
1144 if (!*rdp->nxttail[RCU_WAIT_TAIL]) 1266 if (!*rdp->nxttail[RCU_WAIT_TAIL])
@@ -1318,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
1318 rdp = this_cpu_ptr(rsp->rda); 1440 rdp = this_cpu_ptr(rsp->rda);
1319 rcu_preempt_check_blocked_tasks(rnp); 1441 rcu_preempt_check_blocked_tasks(rnp);
1320 rnp->qsmask = rnp->qsmaskinit; 1442 rnp->qsmask = rnp->qsmaskinit;
1321 rnp->gpnum = rsp->gpnum; 1443 ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
1322 WARN_ON_ONCE(rnp->completed != rsp->completed); 1444 WARN_ON_ONCE(rnp->completed != rsp->completed);
1323 rnp->completed = rsp->completed; 1445 ACCESS_ONCE(rnp->completed) = rsp->completed;
1324 if (rnp == rdp->mynode) 1446 if (rnp == rdp->mynode)
1325 rcu_start_gp_per_cpu(rsp, rnp, rdp); 1447 rcu_start_gp_per_cpu(rsp, rnp, rdp);
1326 rcu_preempt_boost_start_gp(rnp); 1448 rcu_preempt_boost_start_gp(rnp);
@@ -1329,7 +1451,8 @@ static int rcu_gp_init(struct rcu_state *rsp)
1329 rnp->grphi, rnp->qsmask); 1451 rnp->grphi, rnp->qsmask);
1330 raw_spin_unlock_irq(&rnp->lock); 1452 raw_spin_unlock_irq(&rnp->lock);
1331#ifdef CONFIG_PROVE_RCU_DELAY 1453#ifdef CONFIG_PROVE_RCU_DELAY
1332 if ((random32() % (rcu_num_nodes * 8)) == 0) 1454 if ((prandom_u32() % (rcu_num_nodes * 8)) == 0 &&
1455 system_state == SYSTEM_RUNNING)
1333 schedule_timeout_uninterruptible(2); 1456 schedule_timeout_uninterruptible(2);
1334#endif /* #ifdef CONFIG_PROVE_RCU_DELAY */ 1457#endif /* #ifdef CONFIG_PROVE_RCU_DELAY */
1335 cond_resched(); 1458 cond_resched();
@@ -1371,6 +1494,7 @@ int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
1371static void rcu_gp_cleanup(struct rcu_state *rsp) 1494static void rcu_gp_cleanup(struct rcu_state *rsp)
1372{ 1495{
1373 unsigned long gp_duration; 1496 unsigned long gp_duration;
1497 int nocb = 0;
1374 struct rcu_data *rdp; 1498 struct rcu_data *rdp;
1375 struct rcu_node *rnp = rcu_get_root(rsp); 1499 struct rcu_node *rnp = rcu_get_root(rsp);
1376 1500
@@ -1400,17 +1524,23 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
1400 */ 1524 */
1401 rcu_for_each_node_breadth_first(rsp, rnp) { 1525 rcu_for_each_node_breadth_first(rsp, rnp) {
1402 raw_spin_lock_irq(&rnp->lock); 1526 raw_spin_lock_irq(&rnp->lock);
1403 rnp->completed = rsp->gpnum; 1527 ACCESS_ONCE(rnp->completed) = rsp->gpnum;
1528 rdp = this_cpu_ptr(rsp->rda);
1529 if (rnp == rdp->mynode)
1530 __rcu_process_gp_end(rsp, rnp, rdp);
1531 nocb += rcu_future_gp_cleanup(rsp, rnp);
1404 raw_spin_unlock_irq(&rnp->lock); 1532 raw_spin_unlock_irq(&rnp->lock);
1405 cond_resched(); 1533 cond_resched();
1406 } 1534 }
1407 rnp = rcu_get_root(rsp); 1535 rnp = rcu_get_root(rsp);
1408 raw_spin_lock_irq(&rnp->lock); 1536 raw_spin_lock_irq(&rnp->lock);
1537 rcu_nocb_gp_set(rnp, nocb);
1409 1538
1410 rsp->completed = rsp->gpnum; /* Declare grace period done. */ 1539 rsp->completed = rsp->gpnum; /* Declare grace period done. */
1411 trace_rcu_grace_period(rsp->name, rsp->completed, "end"); 1540 trace_rcu_grace_period(rsp->name, rsp->completed, "end");
1412 rsp->fqs_state = RCU_GP_IDLE; 1541 rsp->fqs_state = RCU_GP_IDLE;
1413 rdp = this_cpu_ptr(rsp->rda); 1542 rdp = this_cpu_ptr(rsp->rda);
1543 rcu_advance_cbs(rsp, rnp, rdp); /* Reduce false positives below. */
1414 if (cpu_needs_another_gp(rsp, rdp)) 1544 if (cpu_needs_another_gp(rsp, rdp))
1415 rsp->gp_flags = 1; 1545 rsp->gp_flags = 1;
1416 raw_spin_unlock_irq(&rnp->lock); 1546 raw_spin_unlock_irq(&rnp->lock);
@@ -1486,57 +1616,62 @@ static int __noreturn rcu_gp_kthread(void *arg)
1486/* 1616/*
1487 * Start a new RCU grace period if warranted, re-initializing the hierarchy 1617 * Start a new RCU grace period if warranted, re-initializing the hierarchy
1488 * in preparation for detecting the next grace period. The caller must hold 1618 * in preparation for detecting the next grace period. The caller must hold
1489 * the root node's ->lock, which is released before return. Hard irqs must 1619 * the root node's ->lock and hard irqs must be disabled.
1490 * be disabled.
1491 * 1620 *
1492 * Note that it is legal for a dying CPU (which is marked as offline) to 1621 * Note that it is legal for a dying CPU (which is marked as offline) to
1493 * invoke this function. This can happen when the dying CPU reports its 1622 * invoke this function. This can happen when the dying CPU reports its
1494 * quiescent state. 1623 * quiescent state.
1495 */ 1624 */
1496static void 1625static void
1497rcu_start_gp(struct rcu_state *rsp, unsigned long flags) 1626rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp,
1498 __releases(rcu_get_root(rsp)->lock) 1627 struct rcu_data *rdp)
1499{ 1628{
1500 struct rcu_data *rdp = this_cpu_ptr(rsp->rda); 1629 if (!rsp->gp_kthread || !cpu_needs_another_gp(rsp, rdp)) {
1501 struct rcu_node *rnp = rcu_get_root(rsp);
1502
1503 if (!rsp->gp_kthread ||
1504 !cpu_needs_another_gp(rsp, rdp)) {
1505 /* 1630 /*
1506 * Either we have not yet spawned the grace-period 1631 * Either we have not yet spawned the grace-period
1507 * task, this CPU does not need another grace period, 1632 * task, this CPU does not need another grace period,
1508 * or a grace period is already in progress. 1633 * or a grace period is already in progress.
1509 * Either way, don't start a new grace period. 1634 * Either way, don't start a new grace period.
1510 */ 1635 */
1511 raw_spin_unlock_irqrestore(&rnp->lock, flags);
1512 return; 1636 return;
1513 } 1637 }
1514
1515 /*
1516 * Because there is no grace period in progress right now,
1517 * any callbacks we have up to this point will be satisfied
1518 * by the next grace period. So this is a good place to
1519 * assign a grace period number to recently posted callbacks.
1520 */
1521 rcu_accelerate_cbs(rsp, rnp, rdp);
1522
1523 rsp->gp_flags = RCU_GP_FLAG_INIT; 1638 rsp->gp_flags = RCU_GP_FLAG_INIT;
1524 raw_spin_unlock(&rnp->lock); /* Interrupts remain disabled. */
1525
1526 /* Ensure that CPU is aware of completion of last grace period. */
1527 rcu_process_gp_end(rsp, rdp);
1528 local_irq_restore(flags);
1529 1639
1530 /* Wake up rcu_gp_kthread() to start the grace period. */ 1640 /* Wake up rcu_gp_kthread() to start the grace period. */
1531 wake_up(&rsp->gp_wq); 1641 wake_up(&rsp->gp_wq);
1532} 1642}
1533 1643
1534/* 1644/*
1645 * Similar to rcu_start_gp_advanced(), but also advance the calling CPU's
1646 * callbacks. Note that rcu_start_gp_advanced() cannot do this because it
1647 * is invoked indirectly from rcu_advance_cbs(), which would result in
1648 * endless recursion -- or would do so if it wasn't for the self-deadlock
1649 * that is encountered beforehand.
1650 */
1651static void
1652rcu_start_gp(struct rcu_state *rsp)
1653{
1654 struct rcu_data *rdp = this_cpu_ptr(rsp->rda);
1655 struct rcu_node *rnp = rcu_get_root(rsp);
1656
1657 /*
1658 * If there is no grace period in progress right now, any
1659 * callbacks we have up to this point will be satisfied by the
1660 * next grace period. Also, advancing the callbacks reduces the
1661 * probability of false positives from cpu_needs_another_gp()
1662 * resulting in pointless grace periods. So, advance callbacks
1663 * then start the grace period!
1664 */
1665 rcu_advance_cbs(rsp, rnp, rdp);
1666 rcu_start_gp_advanced(rsp, rnp, rdp);
1667}
1668
1669/*
1535 * Report a full set of quiescent states to the specified rcu_state 1670 * Report a full set of quiescent states to the specified rcu_state
1536 * data structure. This involves cleaning up after the prior grace 1671 * data structure. This involves cleaning up after the prior grace
1537 * period and letting rcu_start_gp() start up the next grace period 1672 * period and letting rcu_start_gp() start up the next grace period
1538 * if one is needed. Note that the caller must hold rnp->lock, as 1673 * if one is needed. Note that the caller must hold rnp->lock, which
1539 * required by rcu_start_gp(), which will release it. 1674 * is released before return.
1540 */ 1675 */
1541static void rcu_report_qs_rsp(struct rcu_state *rsp, unsigned long flags) 1676static void rcu_report_qs_rsp(struct rcu_state *rsp, unsigned long flags)
1542 __releases(rcu_get_root(rsp)->lock) 1677 __releases(rcu_get_root(rsp)->lock)
@@ -2134,7 +2269,8 @@ __rcu_process_callbacks(struct rcu_state *rsp)
2134 local_irq_save(flags); 2269 local_irq_save(flags);
2135 if (cpu_needs_another_gp(rsp, rdp)) { 2270 if (cpu_needs_another_gp(rsp, rdp)) {
2136 raw_spin_lock(&rcu_get_root(rsp)->lock); /* irqs disabled. */ 2271 raw_spin_lock(&rcu_get_root(rsp)->lock); /* irqs disabled. */
2137 rcu_start_gp(rsp, flags); /* releases above lock */ 2272 rcu_start_gp(rsp);
2273 raw_spin_unlock_irqrestore(&rcu_get_root(rsp)->lock, flags);
2138 } else { 2274 } else {
2139 local_irq_restore(flags); 2275 local_irq_restore(flags);
2140 } 2276 }
@@ -2179,7 +2315,8 @@ static void invoke_rcu_callbacks(struct rcu_state *rsp, struct rcu_data *rdp)
2179 2315
2180static void invoke_rcu_core(void) 2316static void invoke_rcu_core(void)
2181{ 2317{
2182 raise_softirq(RCU_SOFTIRQ); 2318 if (cpu_online(smp_processor_id()))
2319 raise_softirq(RCU_SOFTIRQ);
2183} 2320}
2184 2321
2185/* 2322/*
@@ -2214,11 +2351,11 @@ static void __call_rcu_core(struct rcu_state *rsp, struct rcu_data *rdp,
2214 2351
2215 /* Start a new grace period if one not already started. */ 2352 /* Start a new grace period if one not already started. */
2216 if (!rcu_gp_in_progress(rsp)) { 2353 if (!rcu_gp_in_progress(rsp)) {
2217 unsigned long nestflag;
2218 struct rcu_node *rnp_root = rcu_get_root(rsp); 2354 struct rcu_node *rnp_root = rcu_get_root(rsp);
2219 2355
2220 raw_spin_lock_irqsave(&rnp_root->lock, nestflag); 2356 raw_spin_lock(&rnp_root->lock);
2221 rcu_start_gp(rsp, nestflag); /* rlses rnp_root->lock */ 2357 rcu_start_gp(rsp);
2358 raw_spin_unlock(&rnp_root->lock);
2222 } else { 2359 } else {
2223 /* Give the grace period a kick. */ 2360 /* Give the grace period a kick. */
2224 rdp->blimit = LONG_MAX; 2361 rdp->blimit = LONG_MAX;
@@ -2638,19 +2775,27 @@ static int rcu_pending(int cpu)
2638} 2775}
2639 2776
2640/* 2777/*
2641 * Check to see if any future RCU-related work will need to be done 2778 * Return true if the specified CPU has any callback. If all_lazy is
2642 * by the current CPU, even if none need be done immediately, returning 2779 * non-NULL, store an indication of whether all callbacks are lazy.
2643 * 1 if so. 2780 * (If there are no callbacks, all of them are deemed to be lazy.)
2644 */ 2781 */
2645static int rcu_cpu_has_callbacks(int cpu) 2782static int rcu_cpu_has_callbacks(int cpu, bool *all_lazy)
2646{ 2783{
2784 bool al = true;
2785 bool hc = false;
2786 struct rcu_data *rdp;
2647 struct rcu_state *rsp; 2787 struct rcu_state *rsp;
2648 2788
2649 /* RCU callbacks either ready or pending? */ 2789 for_each_rcu_flavor(rsp) {
2650 for_each_rcu_flavor(rsp) 2790 rdp = per_cpu_ptr(rsp->rda, cpu);
2651 if (per_cpu_ptr(rsp->rda, cpu)->nxtlist) 2791 if (rdp->qlen != rdp->qlen_lazy)
2652 return 1; 2792 al = false;
2653 return 0; 2793 if (rdp->nxtlist)
2794 hc = true;
2795 }
2796 if (all_lazy)
2797 *all_lazy = al;
2798 return hc;
2654} 2799}
2655 2800
2656/* 2801/*
@@ -2869,7 +3014,6 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
2869 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE; 3014 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
2870 atomic_set(&rdp->dynticks->dynticks, 3015 atomic_set(&rdp->dynticks->dynticks,
2871 (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1); 3016 (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
2872 rcu_prepare_for_idle_init(cpu);
2873 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ 3017 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
2874 3018
2875 /* Add CPU to rcu_node bitmasks. */ 3019 /* Add CPU to rcu_node bitmasks. */
@@ -2919,7 +3063,6 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
2919 struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu); 3063 struct rcu_data *rdp = per_cpu_ptr(rcu_state->rda, cpu);
2920 struct rcu_node *rnp = rdp->mynode; 3064 struct rcu_node *rnp = rdp->mynode;
2921 struct rcu_state *rsp; 3065 struct rcu_state *rsp;
2922 int ret = NOTIFY_OK;
2923 3066
2924 trace_rcu_utilization("Start CPU hotplug"); 3067 trace_rcu_utilization("Start CPU hotplug");
2925 switch (action) { 3068 switch (action) {
@@ -2933,21 +3076,12 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
2933 rcu_boost_kthread_setaffinity(rnp, -1); 3076 rcu_boost_kthread_setaffinity(rnp, -1);
2934 break; 3077 break;
2935 case CPU_DOWN_PREPARE: 3078 case CPU_DOWN_PREPARE:
2936 if (nocb_cpu_expendable(cpu)) 3079 rcu_boost_kthread_setaffinity(rnp, cpu);
2937 rcu_boost_kthread_setaffinity(rnp, cpu);
2938 else
2939 ret = NOTIFY_BAD;
2940 break; 3080 break;
2941 case CPU_DYING: 3081 case CPU_DYING:
2942 case CPU_DYING_FROZEN: 3082 case CPU_DYING_FROZEN:
2943 /*
2944 * The whole machine is "stopped" except this CPU, so we can
2945 * touch any data without introducing corruption. We send the
2946 * dying CPU's callbacks to an arbitrarily chosen online CPU.
2947 */
2948 for_each_rcu_flavor(rsp) 3083 for_each_rcu_flavor(rsp)
2949 rcu_cleanup_dying_cpu(rsp); 3084 rcu_cleanup_dying_cpu(rsp);
2950 rcu_cleanup_after_idle(cpu);
2951 break; 3085 break;
2952 case CPU_DEAD: 3086 case CPU_DEAD:
2953 case CPU_DEAD_FROZEN: 3087 case CPU_DEAD_FROZEN:
@@ -2960,7 +3094,7 @@ static int __cpuinit rcu_cpu_notify(struct notifier_block *self,
2960 break; 3094 break;
2961 } 3095 }
2962 trace_rcu_utilization("End CPU hotplug"); 3096 trace_rcu_utilization("End CPU hotplug");
2963 return ret; 3097 return NOTIFY_OK;
2964} 3098}
2965 3099
2966/* 3100/*
@@ -3095,6 +3229,7 @@ static void __init rcu_init_one(struct rcu_state *rsp,
3095 } 3229 }
3096 rnp->level = i; 3230 rnp->level = i;
3097 INIT_LIST_HEAD(&rnp->blkd_tasks); 3231 INIT_LIST_HEAD(&rnp->blkd_tasks);
3232 rcu_init_one_nocb(rnp);
3098 } 3233 }
3099 } 3234 }
3100 3235
@@ -3180,8 +3315,7 @@ void __init rcu_init(void)
3180 rcu_init_one(&rcu_sched_state, &rcu_sched_data); 3315 rcu_init_one(&rcu_sched_state, &rcu_sched_data);
3181 rcu_init_one(&rcu_bh_state, &rcu_bh_data); 3316 rcu_init_one(&rcu_bh_state, &rcu_bh_data);
3182 __rcu_init_preempt(); 3317 __rcu_init_preempt();
3183 rcu_init_nocb(); 3318 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
3184 open_softirq(RCU_SOFTIRQ, rcu_process_callbacks);
3185 3319
3186 /* 3320 /*
3187 * We don't need protection against CPU-hotplug here because 3321 * We don't need protection against CPU-hotplug here because