diff options
Diffstat (limited to 'kernel/rcu/tree.c')
-rw-r--r-- | kernel/rcu/tree.c | 508 |
1 files changed, 14 insertions, 494 deletions
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index acd6ccf56faf..ec77ec336f58 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c | |||
@@ -102,11 +102,6 @@ int rcu_num_lvls __read_mostly = RCU_NUM_LVLS; | |||
102 | /* Number of rcu_nodes at specified level. */ | 102 | /* Number of rcu_nodes at specified level. */ |
103 | int num_rcu_lvl[] = NUM_RCU_LVL_INIT; | 103 | int num_rcu_lvl[] = NUM_RCU_LVL_INIT; |
104 | int rcu_num_nodes __read_mostly = NUM_RCU_NODES; /* Total # rcu_nodes in use. */ | 104 | int rcu_num_nodes __read_mostly = NUM_RCU_NODES; /* Total # rcu_nodes in use. */ |
105 | /* panic() on RCU Stall sysctl. */ | ||
106 | int sysctl_panic_on_rcu_stall __read_mostly; | ||
107 | /* Commandeer a sysrq key to dump RCU's tree. */ | ||
108 | static bool sysrq_rcu; | ||
109 | module_param(sysrq_rcu, bool, 0444); | ||
110 | 105 | ||
111 | /* | 106 | /* |
112 | * The rcu_scheduler_active variable is initialized to the value | 107 | * The rcu_scheduler_active variable is initialized to the value |
@@ -149,7 +144,7 @@ static void sync_sched_exp_online_cleanup(int cpu); | |||
149 | 144 | ||
150 | /* rcuc/rcub kthread realtime priority */ | 145 | /* rcuc/rcub kthread realtime priority */ |
151 | static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0; | 146 | static int kthread_prio = IS_ENABLED(CONFIG_RCU_BOOST) ? 1 : 0; |
152 | module_param(kthread_prio, int, 0644); | 147 | module_param(kthread_prio, int, 0444); |
153 | 148 | ||
154 | /* Delay in jiffies for grace-period initialization delays, debug only. */ | 149 | /* Delay in jiffies for grace-period initialization delays, debug only. */ |
155 | 150 | ||
@@ -406,7 +401,7 @@ static bool rcu_kick_kthreads; | |||
406 | */ | 401 | */ |
407 | static ulong jiffies_till_sched_qs = ULONG_MAX; | 402 | static ulong jiffies_till_sched_qs = ULONG_MAX; |
408 | module_param(jiffies_till_sched_qs, ulong, 0444); | 403 | module_param(jiffies_till_sched_qs, ulong, 0444); |
409 | static ulong jiffies_to_sched_qs; /* Adjusted version of above if not default */ | 404 | static ulong jiffies_to_sched_qs; /* See adjust_jiffies_till_sched_qs(). */ |
410 | module_param(jiffies_to_sched_qs, ulong, 0444); /* Display only! */ | 405 | module_param(jiffies_to_sched_qs, ulong, 0444); /* Display only! */ |
411 | 406 | ||
412 | /* | 407 | /* |
@@ -424,6 +419,7 @@ static void adjust_jiffies_till_sched_qs(void) | |||
424 | WRITE_ONCE(jiffies_to_sched_qs, jiffies_till_sched_qs); | 419 | WRITE_ONCE(jiffies_to_sched_qs, jiffies_till_sched_qs); |
425 | return; | 420 | return; |
426 | } | 421 | } |
422 | /* Otherwise, set to third fqs scan, but bound below on large system. */ | ||
427 | j = READ_ONCE(jiffies_till_first_fqs) + | 423 | j = READ_ONCE(jiffies_till_first_fqs) + |
428 | 2 * READ_ONCE(jiffies_till_next_fqs); | 424 | 2 * READ_ONCE(jiffies_till_next_fqs); |
429 | if (j < HZ / 10 + nr_cpu_ids / RCU_JIFFIES_FQS_DIV) | 425 | if (j < HZ / 10 + nr_cpu_ids / RCU_JIFFIES_FQS_DIV) |
@@ -513,74 +509,6 @@ static const char *gp_state_getname(short gs) | |||
513 | } | 509 | } |
514 | 510 | ||
515 | /* | 511 | /* |
516 | * Show the state of the grace-period kthreads. | ||
517 | */ | ||
518 | void show_rcu_gp_kthreads(void) | ||
519 | { | ||
520 | int cpu; | ||
521 | unsigned long j; | ||
522 | unsigned long ja; | ||
523 | unsigned long jr; | ||
524 | unsigned long jw; | ||
525 | struct rcu_data *rdp; | ||
526 | struct rcu_node *rnp; | ||
527 | |||
528 | j = jiffies; | ||
529 | ja = j - READ_ONCE(rcu_state.gp_activity); | ||
530 | jr = j - READ_ONCE(rcu_state.gp_req_activity); | ||
531 | jw = j - READ_ONCE(rcu_state.gp_wake_time); | ||
532 | pr_info("%s: wait state: %s(%d) ->state: %#lx delta ->gp_activity %lu ->gp_req_activity %lu ->gp_wake_time %lu ->gp_wake_seq %ld ->gp_seq %ld ->gp_seq_needed %ld ->gp_flags %#x\n", | ||
533 | rcu_state.name, gp_state_getname(rcu_state.gp_state), | ||
534 | rcu_state.gp_state, | ||
535 | rcu_state.gp_kthread ? rcu_state.gp_kthread->state : 0x1ffffL, | ||
536 | ja, jr, jw, (long)READ_ONCE(rcu_state.gp_wake_seq), | ||
537 | (long)READ_ONCE(rcu_state.gp_seq), | ||
538 | (long)READ_ONCE(rcu_get_root()->gp_seq_needed), | ||
539 | READ_ONCE(rcu_state.gp_flags)); | ||
540 | rcu_for_each_node_breadth_first(rnp) { | ||
541 | if (ULONG_CMP_GE(rcu_state.gp_seq, rnp->gp_seq_needed)) | ||
542 | continue; | ||
543 | pr_info("\trcu_node %d:%d ->gp_seq %ld ->gp_seq_needed %ld\n", | ||
544 | rnp->grplo, rnp->grphi, (long)rnp->gp_seq, | ||
545 | (long)rnp->gp_seq_needed); | ||
546 | if (!rcu_is_leaf_node(rnp)) | ||
547 | continue; | ||
548 | for_each_leaf_node_possible_cpu(rnp, cpu) { | ||
549 | rdp = per_cpu_ptr(&rcu_data, cpu); | ||
550 | if (rdp->gpwrap || | ||
551 | ULONG_CMP_GE(rcu_state.gp_seq, | ||
552 | rdp->gp_seq_needed)) | ||
553 | continue; | ||
554 | pr_info("\tcpu %d ->gp_seq_needed %ld\n", | ||
555 | cpu, (long)rdp->gp_seq_needed); | ||
556 | } | ||
557 | } | ||
558 | /* sched_show_task(rcu_state.gp_kthread); */ | ||
559 | } | ||
560 | EXPORT_SYMBOL_GPL(show_rcu_gp_kthreads); | ||
561 | |||
562 | /* Dump grace-period-request information due to commandeered sysrq. */ | ||
563 | static void sysrq_show_rcu(int key) | ||
564 | { | ||
565 | show_rcu_gp_kthreads(); | ||
566 | } | ||
567 | |||
568 | static struct sysrq_key_op sysrq_rcudump_op = { | ||
569 | .handler = sysrq_show_rcu, | ||
570 | .help_msg = "show-rcu(y)", | ||
571 | .action_msg = "Show RCU tree", | ||
572 | .enable_mask = SYSRQ_ENABLE_DUMP, | ||
573 | }; | ||
574 | |||
575 | static int __init rcu_sysrq_init(void) | ||
576 | { | ||
577 | if (sysrq_rcu) | ||
578 | return register_sysrq_key('y', &sysrq_rcudump_op); | ||
579 | return 0; | ||
580 | } | ||
581 | early_initcall(rcu_sysrq_init); | ||
582 | |||
583 | /* | ||
584 | * Send along grace-period-related data for rcutorture diagnostics. | 512 | * Send along grace-period-related data for rcutorture diagnostics. |
585 | */ | 513 | */ |
586 | void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, | 514 | void rcutorture_get_gp_data(enum rcutorture_type test_type, int *flags, |
@@ -1034,27 +962,6 @@ static int dyntick_save_progress_counter(struct rcu_data *rdp) | |||
1034 | } | 962 | } |
1035 | 963 | ||
1036 | /* | 964 | /* |
1037 | * Handler for the irq_work request posted when a grace period has | ||
1038 | * gone on for too long, but not yet long enough for an RCU CPU | ||
1039 | * stall warning. Set state appropriately, but just complain if | ||
1040 | * there is unexpected state on entry. | ||
1041 | */ | ||
1042 | static void rcu_iw_handler(struct irq_work *iwp) | ||
1043 | { | ||
1044 | struct rcu_data *rdp; | ||
1045 | struct rcu_node *rnp; | ||
1046 | |||
1047 | rdp = container_of(iwp, struct rcu_data, rcu_iw); | ||
1048 | rnp = rdp->mynode; | ||
1049 | raw_spin_lock_rcu_node(rnp); | ||
1050 | if (!WARN_ON_ONCE(!rdp->rcu_iw_pending)) { | ||
1051 | rdp->rcu_iw_gp_seq = rnp->gp_seq; | ||
1052 | rdp->rcu_iw_pending = false; | ||
1053 | } | ||
1054 | raw_spin_unlock_rcu_node(rnp); | ||
1055 | } | ||
1056 | |||
1057 | /* | ||
1058 | * Return true if the specified CPU has passed through a quiescent | 965 | * Return true if the specified CPU has passed through a quiescent |
1059 | * state by virtue of being in or having passed through an dynticks | 966 | * state by virtue of being in or having passed through an dynticks |
1060 | * idle state since the last call to dyntick_save_progress_counter() | 967 | * idle state since the last call to dyntick_save_progress_counter() |
@@ -1167,295 +1074,6 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp) | |||
1167 | return 0; | 1074 | return 0; |
1168 | } | 1075 | } |
1169 | 1076 | ||
1170 | static void record_gp_stall_check_time(void) | ||
1171 | { | ||
1172 | unsigned long j = jiffies; | ||
1173 | unsigned long j1; | ||
1174 | |||
1175 | rcu_state.gp_start = j; | ||
1176 | j1 = rcu_jiffies_till_stall_check(); | ||
1177 | /* Record ->gp_start before ->jiffies_stall. */ | ||
1178 | smp_store_release(&rcu_state.jiffies_stall, j + j1); /* ^^^ */ | ||
1179 | rcu_state.jiffies_resched = j + j1 / 2; | ||
1180 | rcu_state.n_force_qs_gpstart = READ_ONCE(rcu_state.n_force_qs); | ||
1181 | } | ||
1182 | |||
1183 | /* | ||
1184 | * Complain about starvation of grace-period kthread. | ||
1185 | */ | ||
1186 | static void rcu_check_gp_kthread_starvation(void) | ||
1187 | { | ||
1188 | struct task_struct *gpk = rcu_state.gp_kthread; | ||
1189 | unsigned long j; | ||
1190 | |||
1191 | j = jiffies - READ_ONCE(rcu_state.gp_activity); | ||
1192 | if (j > 2 * HZ) { | ||
1193 | pr_err("%s kthread starved for %ld jiffies! g%ld f%#x %s(%d) ->state=%#lx ->cpu=%d\n", | ||
1194 | rcu_state.name, j, | ||
1195 | (long)rcu_seq_current(&rcu_state.gp_seq), | ||
1196 | READ_ONCE(rcu_state.gp_flags), | ||
1197 | gp_state_getname(rcu_state.gp_state), rcu_state.gp_state, | ||
1198 | gpk ? gpk->state : ~0, gpk ? task_cpu(gpk) : -1); | ||
1199 | if (gpk) { | ||
1200 | pr_err("RCU grace-period kthread stack dump:\n"); | ||
1201 | sched_show_task(gpk); | ||
1202 | wake_up_process(gpk); | ||
1203 | } | ||
1204 | } | ||
1205 | } | ||
1206 | |||
1207 | /* | ||
1208 | * Dump stacks of all tasks running on stalled CPUs. First try using | ||
1209 | * NMIs, but fall back to manual remote stack tracing on architectures | ||
1210 | * that don't support NMI-based stack dumps. The NMI-triggered stack | ||
1211 | * traces are more accurate because they are printed by the target CPU. | ||
1212 | */ | ||
1213 | static void rcu_dump_cpu_stacks(void) | ||
1214 | { | ||
1215 | int cpu; | ||
1216 | unsigned long flags; | ||
1217 | struct rcu_node *rnp; | ||
1218 | |||
1219 | rcu_for_each_leaf_node(rnp) { | ||
1220 | raw_spin_lock_irqsave_rcu_node(rnp, flags); | ||
1221 | for_each_leaf_node_possible_cpu(rnp, cpu) | ||
1222 | if (rnp->qsmask & leaf_node_cpu_bit(rnp, cpu)) | ||
1223 | if (!trigger_single_cpu_backtrace(cpu)) | ||
1224 | dump_cpu_task(cpu); | ||
1225 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1229 | /* | ||
1230 | * If too much time has passed in the current grace period, and if | ||
1231 | * so configured, go kick the relevant kthreads. | ||
1232 | */ | ||
1233 | static void rcu_stall_kick_kthreads(void) | ||
1234 | { | ||
1235 | unsigned long j; | ||
1236 | |||
1237 | if (!rcu_kick_kthreads) | ||
1238 | return; | ||
1239 | j = READ_ONCE(rcu_state.jiffies_kick_kthreads); | ||
1240 | if (time_after(jiffies, j) && rcu_state.gp_kthread && | ||
1241 | (rcu_gp_in_progress() || READ_ONCE(rcu_state.gp_flags))) { | ||
1242 | WARN_ONCE(1, "Kicking %s grace-period kthread\n", | ||
1243 | rcu_state.name); | ||
1244 | rcu_ftrace_dump(DUMP_ALL); | ||
1245 | wake_up_process(rcu_state.gp_kthread); | ||
1246 | WRITE_ONCE(rcu_state.jiffies_kick_kthreads, j + HZ); | ||
1247 | } | ||
1248 | } | ||
1249 | |||
1250 | static void panic_on_rcu_stall(void) | ||
1251 | { | ||
1252 | if (sysctl_panic_on_rcu_stall) | ||
1253 | panic("RCU Stall\n"); | ||
1254 | } | ||
1255 | |||
1256 | static void print_other_cpu_stall(unsigned long gp_seq) | ||
1257 | { | ||
1258 | int cpu; | ||
1259 | unsigned long flags; | ||
1260 | unsigned long gpa; | ||
1261 | unsigned long j; | ||
1262 | int ndetected = 0; | ||
1263 | struct rcu_node *rnp = rcu_get_root(); | ||
1264 | long totqlen = 0; | ||
1265 | |||
1266 | /* Kick and suppress, if so configured. */ | ||
1267 | rcu_stall_kick_kthreads(); | ||
1268 | if (rcu_cpu_stall_suppress) | ||
1269 | return; | ||
1270 | |||
1271 | /* | ||
1272 | * OK, time to rat on our buddy... | ||
1273 | * See Documentation/RCU/stallwarn.txt for info on how to debug | ||
1274 | * RCU CPU stall warnings. | ||
1275 | */ | ||
1276 | pr_err("INFO: %s detected stalls on CPUs/tasks:", rcu_state.name); | ||
1277 | print_cpu_stall_info_begin(); | ||
1278 | rcu_for_each_leaf_node(rnp) { | ||
1279 | raw_spin_lock_irqsave_rcu_node(rnp, flags); | ||
1280 | ndetected += rcu_print_task_stall(rnp); | ||
1281 | if (rnp->qsmask != 0) { | ||
1282 | for_each_leaf_node_possible_cpu(rnp, cpu) | ||
1283 | if (rnp->qsmask & leaf_node_cpu_bit(rnp, cpu)) { | ||
1284 | print_cpu_stall_info(cpu); | ||
1285 | ndetected++; | ||
1286 | } | ||
1287 | } | ||
1288 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
1289 | } | ||
1290 | |||
1291 | print_cpu_stall_info_end(); | ||
1292 | for_each_possible_cpu(cpu) | ||
1293 | totqlen += rcu_get_n_cbs_cpu(cpu); | ||
1294 | pr_cont("(detected by %d, t=%ld jiffies, g=%ld, q=%lu)\n", | ||
1295 | smp_processor_id(), (long)(jiffies - rcu_state.gp_start), | ||
1296 | (long)rcu_seq_current(&rcu_state.gp_seq), totqlen); | ||
1297 | if (ndetected) { | ||
1298 | rcu_dump_cpu_stacks(); | ||
1299 | |||
1300 | /* Complain about tasks blocking the grace period. */ | ||
1301 | rcu_print_detail_task_stall(); | ||
1302 | } else { | ||
1303 | if (rcu_seq_current(&rcu_state.gp_seq) != gp_seq) { | ||
1304 | pr_err("INFO: Stall ended before state dump start\n"); | ||
1305 | } else { | ||
1306 | j = jiffies; | ||
1307 | gpa = READ_ONCE(rcu_state.gp_activity); | ||
1308 | pr_err("All QSes seen, last %s kthread activity %ld (%ld-%ld), jiffies_till_next_fqs=%ld, root ->qsmask %#lx\n", | ||
1309 | rcu_state.name, j - gpa, j, gpa, | ||
1310 | READ_ONCE(jiffies_till_next_fqs), | ||
1311 | rcu_get_root()->qsmask); | ||
1312 | /* In this case, the current CPU might be at fault. */ | ||
1313 | sched_show_task(current); | ||
1314 | } | ||
1315 | } | ||
1316 | /* Rewrite if needed in case of slow consoles. */ | ||
1317 | if (ULONG_CMP_GE(jiffies, READ_ONCE(rcu_state.jiffies_stall))) | ||
1318 | WRITE_ONCE(rcu_state.jiffies_stall, | ||
1319 | jiffies + 3 * rcu_jiffies_till_stall_check() + 3); | ||
1320 | |||
1321 | rcu_check_gp_kthread_starvation(); | ||
1322 | |||
1323 | panic_on_rcu_stall(); | ||
1324 | |||
1325 | rcu_force_quiescent_state(); /* Kick them all. */ | ||
1326 | } | ||
1327 | |||
1328 | static void print_cpu_stall(void) | ||
1329 | { | ||
1330 | int cpu; | ||
1331 | unsigned long flags; | ||
1332 | struct rcu_data *rdp = this_cpu_ptr(&rcu_data); | ||
1333 | struct rcu_node *rnp = rcu_get_root(); | ||
1334 | long totqlen = 0; | ||
1335 | |||
1336 | /* Kick and suppress, if so configured. */ | ||
1337 | rcu_stall_kick_kthreads(); | ||
1338 | if (rcu_cpu_stall_suppress) | ||
1339 | return; | ||
1340 | |||
1341 | /* | ||
1342 | * OK, time to rat on ourselves... | ||
1343 | * See Documentation/RCU/stallwarn.txt for info on how to debug | ||
1344 | * RCU CPU stall warnings. | ||
1345 | */ | ||
1346 | pr_err("INFO: %s self-detected stall on CPU", rcu_state.name); | ||
1347 | print_cpu_stall_info_begin(); | ||
1348 | raw_spin_lock_irqsave_rcu_node(rdp->mynode, flags); | ||
1349 | print_cpu_stall_info(smp_processor_id()); | ||
1350 | raw_spin_unlock_irqrestore_rcu_node(rdp->mynode, flags); | ||
1351 | print_cpu_stall_info_end(); | ||
1352 | for_each_possible_cpu(cpu) | ||
1353 | totqlen += rcu_get_n_cbs_cpu(cpu); | ||
1354 | pr_cont(" (t=%lu jiffies g=%ld q=%lu)\n", | ||
1355 | jiffies - rcu_state.gp_start, | ||
1356 | (long)rcu_seq_current(&rcu_state.gp_seq), totqlen); | ||
1357 | |||
1358 | rcu_check_gp_kthread_starvation(); | ||
1359 | |||
1360 | rcu_dump_cpu_stacks(); | ||
1361 | |||
1362 | raw_spin_lock_irqsave_rcu_node(rnp, flags); | ||
1363 | /* Rewrite if needed in case of slow consoles. */ | ||
1364 | if (ULONG_CMP_GE(jiffies, READ_ONCE(rcu_state.jiffies_stall))) | ||
1365 | WRITE_ONCE(rcu_state.jiffies_stall, | ||
1366 | jiffies + 3 * rcu_jiffies_till_stall_check() + 3); | ||
1367 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
1368 | |||
1369 | panic_on_rcu_stall(); | ||
1370 | |||
1371 | /* | ||
1372 | * Attempt to revive the RCU machinery by forcing a context switch. | ||
1373 | * | ||
1374 | * A context switch would normally allow the RCU state machine to make | ||
1375 | * progress and it could be we're stuck in kernel space without context | ||
1376 | * switches for an entirely unreasonable amount of time. | ||
1377 | */ | ||
1378 | set_tsk_need_resched(current); | ||
1379 | set_preempt_need_resched(); | ||
1380 | } | ||
1381 | |||
1382 | static void check_cpu_stall(struct rcu_data *rdp) | ||
1383 | { | ||
1384 | unsigned long gs1; | ||
1385 | unsigned long gs2; | ||
1386 | unsigned long gps; | ||
1387 | unsigned long j; | ||
1388 | unsigned long jn; | ||
1389 | unsigned long js; | ||
1390 | struct rcu_node *rnp; | ||
1391 | |||
1392 | if ((rcu_cpu_stall_suppress && !rcu_kick_kthreads) || | ||
1393 | !rcu_gp_in_progress()) | ||
1394 | return; | ||
1395 | rcu_stall_kick_kthreads(); | ||
1396 | j = jiffies; | ||
1397 | |||
1398 | /* | ||
1399 | * Lots of memory barriers to reject false positives. | ||
1400 | * | ||
1401 | * The idea is to pick up rcu_state.gp_seq, then | ||
1402 | * rcu_state.jiffies_stall, then rcu_state.gp_start, and finally | ||
1403 | * another copy of rcu_state.gp_seq. These values are updated in | ||
1404 | * the opposite order with memory barriers (or equivalent) during | ||
1405 | * grace-period initialization and cleanup. Now, a false positive | ||
1406 | * can occur if we get an new value of rcu_state.gp_start and a old | ||
1407 | * value of rcu_state.jiffies_stall. But given the memory barriers, | ||
1408 | * the only way that this can happen is if one grace period ends | ||
1409 | * and another starts between these two fetches. This is detected | ||
1410 | * by comparing the second fetch of rcu_state.gp_seq with the | ||
1411 | * previous fetch from rcu_state.gp_seq. | ||
1412 | * | ||
1413 | * Given this check, comparisons of jiffies, rcu_state.jiffies_stall, | ||
1414 | * and rcu_state.gp_start suffice to forestall false positives. | ||
1415 | */ | ||
1416 | gs1 = READ_ONCE(rcu_state.gp_seq); | ||
1417 | smp_rmb(); /* Pick up ->gp_seq first... */ | ||
1418 | js = READ_ONCE(rcu_state.jiffies_stall); | ||
1419 | smp_rmb(); /* ...then ->jiffies_stall before the rest... */ | ||
1420 | gps = READ_ONCE(rcu_state.gp_start); | ||
1421 | smp_rmb(); /* ...and finally ->gp_start before ->gp_seq again. */ | ||
1422 | gs2 = READ_ONCE(rcu_state.gp_seq); | ||
1423 | if (gs1 != gs2 || | ||
1424 | ULONG_CMP_LT(j, js) || | ||
1425 | ULONG_CMP_GE(gps, js)) | ||
1426 | return; /* No stall or GP completed since entering function. */ | ||
1427 | rnp = rdp->mynode; | ||
1428 | jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3; | ||
1429 | if (rcu_gp_in_progress() && | ||
1430 | (READ_ONCE(rnp->qsmask) & rdp->grpmask) && | ||
1431 | cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) { | ||
1432 | |||
1433 | /* We haven't checked in, so go dump stack. */ | ||
1434 | print_cpu_stall(); | ||
1435 | |||
1436 | } else if (rcu_gp_in_progress() && | ||
1437 | ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) && | ||
1438 | cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) { | ||
1439 | |||
1440 | /* They had a few time units to dump stack, so complain. */ | ||
1441 | print_other_cpu_stall(gs2); | ||
1442 | } | ||
1443 | } | ||
1444 | |||
1445 | /** | ||
1446 | * rcu_cpu_stall_reset - prevent further stall warnings in current grace period | ||
1447 | * | ||
1448 | * Set the stall-warning timeout way off into the future, thus preventing | ||
1449 | * any RCU CPU stall-warning messages from appearing in the current set of | ||
1450 | * RCU grace periods. | ||
1451 | * | ||
1452 | * The caller must disable hard irqs. | ||
1453 | */ | ||
1454 | void rcu_cpu_stall_reset(void) | ||
1455 | { | ||
1456 | WRITE_ONCE(rcu_state.jiffies_stall, jiffies + ULONG_MAX / 2); | ||
1457 | } | ||
1458 | |||
1459 | /* Trace-event wrapper function for trace_rcu_future_grace_period. */ | 1077 | /* Trace-event wrapper function for trace_rcu_future_grace_period. */ |
1460 | static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp, | 1078 | static void trace_rcu_this_gp(struct rcu_node *rnp, struct rcu_data *rdp, |
1461 | unsigned long gp_seq_req, const char *s) | 1079 | unsigned long gp_seq_req, const char *s) |
@@ -1585,7 +1203,7 @@ static bool rcu_future_gp_cleanup(struct rcu_node *rnp) | |||
1585 | static void rcu_gp_kthread_wake(void) | 1203 | static void rcu_gp_kthread_wake(void) |
1586 | { | 1204 | { |
1587 | if ((current == rcu_state.gp_kthread && | 1205 | if ((current == rcu_state.gp_kthread && |
1588 | !in_interrupt() && !in_serving_softirq()) || | 1206 | !in_irq() && !in_serving_softirq()) || |
1589 | !READ_ONCE(rcu_state.gp_flags) || | 1207 | !READ_ONCE(rcu_state.gp_flags) || |
1590 | !rcu_state.gp_kthread) | 1208 | !rcu_state.gp_kthread) |
1591 | return; | 1209 | return; |
@@ -2295,11 +1913,10 @@ rcu_report_qs_rdp(int cpu, struct rcu_data *rdp) | |||
2295 | return; | 1913 | return; |
2296 | } | 1914 | } |
2297 | mask = rdp->grpmask; | 1915 | mask = rdp->grpmask; |
1916 | rdp->core_needs_qs = false; | ||
2298 | if ((rnp->qsmask & mask) == 0) { | 1917 | if ((rnp->qsmask & mask) == 0) { |
2299 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | 1918 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
2300 | } else { | 1919 | } else { |
2301 | rdp->core_needs_qs = false; | ||
2302 | |||
2303 | /* | 1920 | /* |
2304 | * This GP can't end until cpu checks in, so all of our | 1921 | * This GP can't end until cpu checks in, so all of our |
2305 | * callbacks can be processed during the next GP. | 1922 | * callbacks can be processed during the next GP. |
@@ -2548,11 +2165,11 @@ void rcu_sched_clock_irq(int user) | |||
2548 | } | 2165 | } |
2549 | 2166 | ||
2550 | /* | 2167 | /* |
2551 | * Scan the leaf rcu_node structures, processing dyntick state for any that | 2168 | * Scan the leaf rcu_node structures. For each structure on which all |
2552 | * have not yet encountered a quiescent state, using the function specified. | 2169 | * CPUs have reported a quiescent state and on which there are tasks |
2553 | * Also initiate boosting for any threads blocked on the root rcu_node. | 2170 | * blocking the current grace period, initiate RCU priority boosting. |
2554 | * | 2171 | * Otherwise, invoke the specified function to check dyntick state for |
2555 | * The caller must have suppressed start of new grace periods. | 2172 | * each CPU that has not yet reported a quiescent state. |
2556 | */ | 2173 | */ |
2557 | static void force_qs_rnp(int (*f)(struct rcu_data *rdp)) | 2174 | static void force_qs_rnp(int (*f)(struct rcu_data *rdp)) |
2558 | { | 2175 | { |
@@ -2635,101 +2252,6 @@ void rcu_force_quiescent_state(void) | |||
2635 | } | 2252 | } |
2636 | EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); | 2253 | EXPORT_SYMBOL_GPL(rcu_force_quiescent_state); |
2637 | 2254 | ||
2638 | /* | ||
2639 | * This function checks for grace-period requests that fail to motivate | ||
2640 | * RCU to come out of its idle mode. | ||
2641 | */ | ||
2642 | void | ||
2643 | rcu_check_gp_start_stall(struct rcu_node *rnp, struct rcu_data *rdp, | ||
2644 | const unsigned long gpssdelay) | ||
2645 | { | ||
2646 | unsigned long flags; | ||
2647 | unsigned long j; | ||
2648 | struct rcu_node *rnp_root = rcu_get_root(); | ||
2649 | static atomic_t warned = ATOMIC_INIT(0); | ||
2650 | |||
2651 | if (!IS_ENABLED(CONFIG_PROVE_RCU) || rcu_gp_in_progress() || | ||
2652 | ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed)) | ||
2653 | return; | ||
2654 | j = jiffies; /* Expensive access, and in common case don't get here. */ | ||
2655 | if (time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) || | ||
2656 | time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) || | ||
2657 | atomic_read(&warned)) | ||
2658 | return; | ||
2659 | |||
2660 | raw_spin_lock_irqsave_rcu_node(rnp, flags); | ||
2661 | j = jiffies; | ||
2662 | if (rcu_gp_in_progress() || | ||
2663 | ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed) || | ||
2664 | time_before(j, READ_ONCE(rcu_state.gp_req_activity) + gpssdelay) || | ||
2665 | time_before(j, READ_ONCE(rcu_state.gp_activity) + gpssdelay) || | ||
2666 | atomic_read(&warned)) { | ||
2667 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
2668 | return; | ||
2669 | } | ||
2670 | /* Hold onto the leaf lock to make others see warned==1. */ | ||
2671 | |||
2672 | if (rnp_root != rnp) | ||
2673 | raw_spin_lock_rcu_node(rnp_root); /* irqs already disabled. */ | ||
2674 | j = jiffies; | ||
2675 | if (rcu_gp_in_progress() || | ||
2676 | ULONG_CMP_GE(rnp_root->gp_seq, rnp_root->gp_seq_needed) || | ||
2677 | time_before(j, rcu_state.gp_req_activity + gpssdelay) || | ||
2678 | time_before(j, rcu_state.gp_activity + gpssdelay) || | ||
2679 | atomic_xchg(&warned, 1)) { | ||
2680 | raw_spin_unlock_rcu_node(rnp_root); /* irqs remain disabled. */ | ||
2681 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
2682 | return; | ||
2683 | } | ||
2684 | WARN_ON(1); | ||
2685 | if (rnp_root != rnp) | ||
2686 | raw_spin_unlock_rcu_node(rnp_root); | ||
2687 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
2688 | show_rcu_gp_kthreads(); | ||
2689 | } | ||
2690 | |||
2691 | /* | ||
2692 | * Do a forward-progress check for rcutorture. This is normally invoked | ||
2693 | * due to an OOM event. The argument "j" gives the time period during | ||
2694 | * which rcutorture would like progress to have been made. | ||
2695 | */ | ||
2696 | void rcu_fwd_progress_check(unsigned long j) | ||
2697 | { | ||
2698 | unsigned long cbs; | ||
2699 | int cpu; | ||
2700 | unsigned long max_cbs = 0; | ||
2701 | int max_cpu = -1; | ||
2702 | struct rcu_data *rdp; | ||
2703 | |||
2704 | if (rcu_gp_in_progress()) { | ||
2705 | pr_info("%s: GP age %lu jiffies\n", | ||
2706 | __func__, jiffies - rcu_state.gp_start); | ||
2707 | show_rcu_gp_kthreads(); | ||
2708 | } else { | ||
2709 | pr_info("%s: Last GP end %lu jiffies ago\n", | ||
2710 | __func__, jiffies - rcu_state.gp_end); | ||
2711 | preempt_disable(); | ||
2712 | rdp = this_cpu_ptr(&rcu_data); | ||
2713 | rcu_check_gp_start_stall(rdp->mynode, rdp, j); | ||
2714 | preempt_enable(); | ||
2715 | } | ||
2716 | for_each_possible_cpu(cpu) { | ||
2717 | cbs = rcu_get_n_cbs_cpu(cpu); | ||
2718 | if (!cbs) | ||
2719 | continue; | ||
2720 | if (max_cpu < 0) | ||
2721 | pr_info("%s: callbacks", __func__); | ||
2722 | pr_cont(" %d: %lu", cpu, cbs); | ||
2723 | if (cbs <= max_cbs) | ||
2724 | continue; | ||
2725 | max_cbs = cbs; | ||
2726 | max_cpu = cpu; | ||
2727 | } | ||
2728 | if (max_cpu >= 0) | ||
2729 | pr_cont("\n"); | ||
2730 | } | ||
2731 | EXPORT_SYMBOL_GPL(rcu_fwd_progress_check); | ||
2732 | |||
2733 | /* Perform RCU core processing work for the current CPU. */ | 2255 | /* Perform RCU core processing work for the current CPU. */ |
2734 | static __latent_entropy void rcu_core(struct softirq_action *unused) | 2256 | static __latent_entropy void rcu_core(struct softirq_action *unused) |
2735 | { | 2257 | { |
@@ -3559,13 +3081,11 @@ static int rcu_pm_notify(struct notifier_block *self, | |||
3559 | switch (action) { | 3081 | switch (action) { |
3560 | case PM_HIBERNATION_PREPARE: | 3082 | case PM_HIBERNATION_PREPARE: |
3561 | case PM_SUSPEND_PREPARE: | 3083 | case PM_SUSPEND_PREPARE: |
3562 | if (nr_cpu_ids <= 256) /* Expediting bad for large systems. */ | 3084 | rcu_expedite_gp(); |
3563 | rcu_expedite_gp(); | ||
3564 | break; | 3085 | break; |
3565 | case PM_POST_HIBERNATION: | 3086 | case PM_POST_HIBERNATION: |
3566 | case PM_POST_SUSPEND: | 3087 | case PM_POST_SUSPEND: |
3567 | if (nr_cpu_ids <= 256) /* Expediting bad for large systems. */ | 3088 | rcu_unexpedite_gp(); |
3568 | rcu_unexpedite_gp(); | ||
3569 | break; | 3089 | break; |
3570 | default: | 3090 | default: |
3571 | break; | 3091 | break; |
@@ -3742,8 +3262,7 @@ static void __init rcu_init_geometry(void) | |||
3742 | jiffies_till_first_fqs = d; | 3262 | jiffies_till_first_fqs = d; |
3743 | if (jiffies_till_next_fqs == ULONG_MAX) | 3263 | if (jiffies_till_next_fqs == ULONG_MAX) |
3744 | jiffies_till_next_fqs = d; | 3264 | jiffies_till_next_fqs = d; |
3745 | if (jiffies_till_sched_qs == ULONG_MAX) | 3265 | adjust_jiffies_till_sched_qs(); |
3746 | adjust_jiffies_till_sched_qs(); | ||
3747 | 3266 | ||
3748 | /* If the compile-time values are accurate, just leave. */ | 3267 | /* If the compile-time values are accurate, just leave. */ |
3749 | if (rcu_fanout_leaf == RCU_FANOUT_LEAF && | 3268 | if (rcu_fanout_leaf == RCU_FANOUT_LEAF && |
@@ -3858,5 +3377,6 @@ void __init rcu_init(void) | |||
3858 | srcu_init(); | 3377 | srcu_init(); |
3859 | } | 3378 | } |
3860 | 3379 | ||
3380 | #include "tree_stall.h" | ||
3861 | #include "tree_exp.h" | 3381 | #include "tree_exp.h" |
3862 | #include "tree_plugin.h" | 3382 | #include "tree_plugin.h" |