diff options
Diffstat (limited to 'kernel/rcu/tree_plugin.h')
-rw-r--r-- | kernel/rcu/tree_plugin.h | 271 |
1 files changed, 72 insertions, 199 deletions
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 3ec85cb5d544..2e850a51bb8f 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h | |||
@@ -34,10 +34,6 @@ | |||
34 | 34 | ||
35 | #include "../locking/rtmutex_common.h" | 35 | #include "../locking/rtmutex_common.h" |
36 | 36 | ||
37 | /* rcuc/rcub kthread realtime priority */ | ||
38 | static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO; | ||
39 | module_param(kthread_prio, int, 0644); | ||
40 | |||
41 | /* | 37 | /* |
42 | * Control variables for per-CPU and per-rcu_node kthreads. These | 38 | * Control variables for per-CPU and per-rcu_node kthreads. These |
43 | * handle all flavors of RCU. | 39 | * handle all flavors of RCU. |
@@ -103,6 +99,8 @@ RCU_STATE_INITIALIZER(rcu_preempt, 'p', call_rcu); | |||
103 | static struct rcu_state *rcu_state_p = &rcu_preempt_state; | 99 | static struct rcu_state *rcu_state_p = &rcu_preempt_state; |
104 | 100 | ||
105 | static int rcu_preempted_readers_exp(struct rcu_node *rnp); | 101 | static int rcu_preempted_readers_exp(struct rcu_node *rnp); |
102 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, | ||
103 | bool wake); | ||
106 | 104 | ||
107 | /* | 105 | /* |
108 | * Tell them what RCU they are running. | 106 | * Tell them what RCU they are running. |
@@ -114,25 +112,6 @@ static void __init rcu_bootup_announce(void) | |||
114 | } | 112 | } |
115 | 113 | ||
116 | /* | 114 | /* |
117 | * Return the number of RCU-preempt batches processed thus far | ||
118 | * for debug and statistics. | ||
119 | */ | ||
120 | static long rcu_batches_completed_preempt(void) | ||
121 | { | ||
122 | return rcu_preempt_state.completed; | ||
123 | } | ||
124 | EXPORT_SYMBOL_GPL(rcu_batches_completed_preempt); | ||
125 | |||
126 | /* | ||
127 | * Return the number of RCU batches processed thus far for debug & stats. | ||
128 | */ | ||
129 | long rcu_batches_completed(void) | ||
130 | { | ||
131 | return rcu_batches_completed_preempt(); | ||
132 | } | ||
133 | EXPORT_SYMBOL_GPL(rcu_batches_completed); | ||
134 | |||
135 | /* | ||
136 | * Record a preemptible-RCU quiescent state for the specified CPU. Note | 115 | * Record a preemptible-RCU quiescent state for the specified CPU. Note |
137 | * that this just means that the task currently running on the CPU is | 116 | * that this just means that the task currently running on the CPU is |
138 | * not in a quiescent state. There might be any number of tasks blocked | 117 | * not in a quiescent state. There might be any number of tasks blocked |
@@ -307,15 +286,25 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t, | |||
307 | } | 286 | } |
308 | 287 | ||
309 | /* | 288 | /* |
289 | * Return true if the specified rcu_node structure has tasks that were | ||
290 | * preempted within an RCU read-side critical section. | ||
291 | */ | ||
292 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp) | ||
293 | { | ||
294 | return !list_empty(&rnp->blkd_tasks); | ||
295 | } | ||
296 | |||
297 | /* | ||
310 | * Handle special cases during rcu_read_unlock(), such as needing to | 298 | * Handle special cases during rcu_read_unlock(), such as needing to |
311 | * notify RCU core processing or task having blocked during the RCU | 299 | * notify RCU core processing or task having blocked during the RCU |
312 | * read-side critical section. | 300 | * read-side critical section. |
313 | */ | 301 | */ |
314 | void rcu_read_unlock_special(struct task_struct *t) | 302 | void rcu_read_unlock_special(struct task_struct *t) |
315 | { | 303 | { |
316 | int empty; | 304 | bool empty; |
317 | int empty_exp; | 305 | bool empty_exp; |
318 | int empty_exp_now; | 306 | bool empty_norm; |
307 | bool empty_exp_now; | ||
319 | unsigned long flags; | 308 | unsigned long flags; |
320 | struct list_head *np; | 309 | struct list_head *np; |
321 | #ifdef CONFIG_RCU_BOOST | 310 | #ifdef CONFIG_RCU_BOOST |
@@ -367,7 +356,8 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
367 | break; | 356 | break; |
368 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ | 357 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
369 | } | 358 | } |
370 | empty = !rcu_preempt_blocked_readers_cgp(rnp); | 359 | empty = !rcu_preempt_has_tasks(rnp); |
360 | empty_norm = !rcu_preempt_blocked_readers_cgp(rnp); | ||
371 | empty_exp = !rcu_preempted_readers_exp(rnp); | 361 | empty_exp = !rcu_preempted_readers_exp(rnp); |
372 | smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ | 362 | smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ |
373 | np = rcu_next_node_entry(t, rnp); | 363 | np = rcu_next_node_entry(t, rnp); |
@@ -387,13 +377,21 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
387 | #endif /* #ifdef CONFIG_RCU_BOOST */ | 377 | #endif /* #ifdef CONFIG_RCU_BOOST */ |
388 | 378 | ||
389 | /* | 379 | /* |
380 | * If this was the last task on the list, go see if we | ||
381 | * need to propagate ->qsmaskinit bit clearing up the | ||
382 | * rcu_node tree. | ||
383 | */ | ||
384 | if (!empty && !rcu_preempt_has_tasks(rnp)) | ||
385 | rcu_cleanup_dead_rnp(rnp); | ||
386 | |||
387 | /* | ||
390 | * If this was the last task on the current list, and if | 388 | * If this was the last task on the current list, and if |
391 | * we aren't waiting on any CPUs, report the quiescent state. | 389 | * we aren't waiting on any CPUs, report the quiescent state. |
392 | * Note that rcu_report_unblock_qs_rnp() releases rnp->lock, | 390 | * Note that rcu_report_unblock_qs_rnp() releases rnp->lock, |
393 | * so we must take a snapshot of the expedited state. | 391 | * so we must take a snapshot of the expedited state. |
394 | */ | 392 | */ |
395 | empty_exp_now = !rcu_preempted_readers_exp(rnp); | 393 | empty_exp_now = !rcu_preempted_readers_exp(rnp); |
396 | if (!empty && !rcu_preempt_blocked_readers_cgp(rnp)) { | 394 | if (!empty_norm && !rcu_preempt_blocked_readers_cgp(rnp)) { |
397 | trace_rcu_quiescent_state_report(TPS("preempt_rcu"), | 395 | trace_rcu_quiescent_state_report(TPS("preempt_rcu"), |
398 | rnp->gpnum, | 396 | rnp->gpnum, |
399 | 0, rnp->qsmask, | 397 | 0, rnp->qsmask, |
@@ -408,10 +406,8 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
408 | 406 | ||
409 | #ifdef CONFIG_RCU_BOOST | 407 | #ifdef CONFIG_RCU_BOOST |
410 | /* Unboost if we were boosted. */ | 408 | /* Unboost if we were boosted. */ |
411 | if (drop_boost_mutex) { | 409 | if (drop_boost_mutex) |
412 | rt_mutex_unlock(&rnp->boost_mtx); | 410 | rt_mutex_unlock(&rnp->boost_mtx); |
413 | complete(&rnp->boost_completion); | ||
414 | } | ||
415 | #endif /* #ifdef CONFIG_RCU_BOOST */ | 411 | #endif /* #ifdef CONFIG_RCU_BOOST */ |
416 | 412 | ||
417 | /* | 413 | /* |
@@ -519,99 +515,13 @@ static int rcu_print_task_stall(struct rcu_node *rnp) | |||
519 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | 515 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
520 | { | 516 | { |
521 | WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)); | 517 | WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)); |
522 | if (!list_empty(&rnp->blkd_tasks)) | 518 | if (rcu_preempt_has_tasks(rnp)) |
523 | rnp->gp_tasks = rnp->blkd_tasks.next; | 519 | rnp->gp_tasks = rnp->blkd_tasks.next; |
524 | WARN_ON_ONCE(rnp->qsmask); | 520 | WARN_ON_ONCE(rnp->qsmask); |
525 | } | 521 | } |
526 | 522 | ||
527 | #ifdef CONFIG_HOTPLUG_CPU | 523 | #ifdef CONFIG_HOTPLUG_CPU |
528 | 524 | ||
529 | /* | ||
530 | * Handle tasklist migration for case in which all CPUs covered by the | ||
531 | * specified rcu_node have gone offline. Move them up to the root | ||
532 | * rcu_node. The reason for not just moving them to the immediate | ||
533 | * parent is to remove the need for rcu_read_unlock_special() to | ||
534 | * make more than two attempts to acquire the target rcu_node's lock. | ||
535 | * Returns true if there were tasks blocking the current RCU grace | ||
536 | * period. | ||
537 | * | ||
538 | * Returns 1 if there was previously a task blocking the current grace | ||
539 | * period on the specified rcu_node structure. | ||
540 | * | ||
541 | * The caller must hold rnp->lock with irqs disabled. | ||
542 | */ | ||
543 | static int rcu_preempt_offline_tasks(struct rcu_state *rsp, | ||
544 | struct rcu_node *rnp, | ||
545 | struct rcu_data *rdp) | ||
546 | { | ||
547 | struct list_head *lp; | ||
548 | struct list_head *lp_root; | ||
549 | int retval = 0; | ||
550 | struct rcu_node *rnp_root = rcu_get_root(rsp); | ||
551 | struct task_struct *t; | ||
552 | |||
553 | if (rnp == rnp_root) { | ||
554 | WARN_ONCE(1, "Last CPU thought to be offlined?"); | ||
555 | return 0; /* Shouldn't happen: at least one CPU online. */ | ||
556 | } | ||
557 | |||
558 | /* If we are on an internal node, complain bitterly. */ | ||
559 | WARN_ON_ONCE(rnp != rdp->mynode); | ||
560 | |||
561 | /* | ||
562 | * Move tasks up to root rcu_node. Don't try to get fancy for | ||
563 | * this corner-case operation -- just put this node's tasks | ||
564 | * at the head of the root node's list, and update the root node's | ||
565 | * ->gp_tasks and ->exp_tasks pointers to those of this node's, | ||
566 | * if non-NULL. This might result in waiting for more tasks than | ||
567 | * absolutely necessary, but this is a good performance/complexity | ||
568 | * tradeoff. | ||
569 | */ | ||
570 | if (rcu_preempt_blocked_readers_cgp(rnp) && rnp->qsmask == 0) | ||
571 | retval |= RCU_OFL_TASKS_NORM_GP; | ||
572 | if (rcu_preempted_readers_exp(rnp)) | ||
573 | retval |= RCU_OFL_TASKS_EXP_GP; | ||
574 | lp = &rnp->blkd_tasks; | ||
575 | lp_root = &rnp_root->blkd_tasks; | ||
576 | while (!list_empty(lp)) { | ||
577 | t = list_entry(lp->next, typeof(*t), rcu_node_entry); | ||
578 | raw_spin_lock(&rnp_root->lock); /* irqs already disabled */ | ||
579 | smp_mb__after_unlock_lock(); | ||
580 | list_del(&t->rcu_node_entry); | ||
581 | t->rcu_blocked_node = rnp_root; | ||
582 | list_add(&t->rcu_node_entry, lp_root); | ||
583 | if (&t->rcu_node_entry == rnp->gp_tasks) | ||
584 | rnp_root->gp_tasks = rnp->gp_tasks; | ||
585 | if (&t->rcu_node_entry == rnp->exp_tasks) | ||
586 | rnp_root->exp_tasks = rnp->exp_tasks; | ||
587 | #ifdef CONFIG_RCU_BOOST | ||
588 | if (&t->rcu_node_entry == rnp->boost_tasks) | ||
589 | rnp_root->boost_tasks = rnp->boost_tasks; | ||
590 | #endif /* #ifdef CONFIG_RCU_BOOST */ | ||
591 | raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */ | ||
592 | } | ||
593 | |||
594 | rnp->gp_tasks = NULL; | ||
595 | rnp->exp_tasks = NULL; | ||
596 | #ifdef CONFIG_RCU_BOOST | ||
597 | rnp->boost_tasks = NULL; | ||
598 | /* | ||
599 | * In case root is being boosted and leaf was not. Make sure | ||
600 | * that we boost the tasks blocking the current grace period | ||
601 | * in this case. | ||
602 | */ | ||
603 | raw_spin_lock(&rnp_root->lock); /* irqs already disabled */ | ||
604 | smp_mb__after_unlock_lock(); | ||
605 | if (rnp_root->boost_tasks != NULL && | ||
606 | rnp_root->boost_tasks != rnp_root->gp_tasks && | ||
607 | rnp_root->boost_tasks != rnp_root->exp_tasks) | ||
608 | rnp_root->boost_tasks = rnp_root->gp_tasks; | ||
609 | raw_spin_unlock(&rnp_root->lock); /* irqs still disabled */ | ||
610 | #endif /* #ifdef CONFIG_RCU_BOOST */ | ||
611 | |||
612 | return retval; | ||
613 | } | ||
614 | |||
615 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | 525 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
616 | 526 | ||
617 | /* | 527 | /* |
@@ -771,7 +681,7 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp) | |||
771 | 681 | ||
772 | raw_spin_lock_irqsave(&rnp->lock, flags); | 682 | raw_spin_lock_irqsave(&rnp->lock, flags); |
773 | smp_mb__after_unlock_lock(); | 683 | smp_mb__after_unlock_lock(); |
774 | if (list_empty(&rnp->blkd_tasks)) { | 684 | if (!rcu_preempt_has_tasks(rnp)) { |
775 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 685 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
776 | } else { | 686 | } else { |
777 | rnp->exp_tasks = rnp->blkd_tasks.next; | 687 | rnp->exp_tasks = rnp->blkd_tasks.next; |
@@ -933,15 +843,6 @@ static void __init rcu_bootup_announce(void) | |||
933 | } | 843 | } |
934 | 844 | ||
935 | /* | 845 | /* |
936 | * Return the number of RCU batches processed thus far for debug & stats. | ||
937 | */ | ||
938 | long rcu_batches_completed(void) | ||
939 | { | ||
940 | return rcu_batches_completed_sched(); | ||
941 | } | ||
942 | EXPORT_SYMBOL_GPL(rcu_batches_completed); | ||
943 | |||
944 | /* | ||
945 | * Because preemptible RCU does not exist, we never have to check for | 846 | * Because preemptible RCU does not exist, we never have to check for |
946 | * CPUs being in quiescent states. | 847 | * CPUs being in quiescent states. |
947 | */ | 848 | */ |
@@ -960,11 +861,12 @@ static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) | |||
960 | 861 | ||
961 | #ifdef CONFIG_HOTPLUG_CPU | 862 | #ifdef CONFIG_HOTPLUG_CPU |
962 | 863 | ||
963 | /* Because preemptible RCU does not exist, no quieting of tasks. */ | 864 | /* |
964 | static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags) | 865 | * Because there is no preemptible RCU, there can be no readers blocked. |
965 | __releases(rnp->lock) | 866 | */ |
867 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp) | ||
966 | { | 868 | { |
967 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 869 | return false; |
968 | } | 870 | } |
969 | 871 | ||
970 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | 872 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
@@ -996,23 +898,6 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | |||
996 | WARN_ON_ONCE(rnp->qsmask); | 898 | WARN_ON_ONCE(rnp->qsmask); |
997 | } | 899 | } |
998 | 900 | ||
999 | #ifdef CONFIG_HOTPLUG_CPU | ||
1000 | |||
1001 | /* | ||
1002 | * Because preemptible RCU does not exist, it never needs to migrate | ||
1003 | * tasks that were blocked within RCU read-side critical sections, and | ||
1004 | * such non-existent tasks cannot possibly have been blocking the current | ||
1005 | * grace period. | ||
1006 | */ | ||
1007 | static int rcu_preempt_offline_tasks(struct rcu_state *rsp, | ||
1008 | struct rcu_node *rnp, | ||
1009 | struct rcu_data *rdp) | ||
1010 | { | ||
1011 | return 0; | ||
1012 | } | ||
1013 | |||
1014 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
1015 | |||
1016 | /* | 901 | /* |
1017 | * Because preemptible RCU does not exist, it never has any callbacks | 902 | * Because preemptible RCU does not exist, it never has any callbacks |
1018 | * to check. | 903 | * to check. |
@@ -1031,20 +916,6 @@ void synchronize_rcu_expedited(void) | |||
1031 | } | 916 | } |
1032 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); | 917 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); |
1033 | 918 | ||
1034 | #ifdef CONFIG_HOTPLUG_CPU | ||
1035 | |||
1036 | /* | ||
1037 | * Because preemptible RCU does not exist, there is never any need to | ||
1038 | * report on tasks preempted in RCU read-side critical sections during | ||
1039 | * expedited RCU grace periods. | ||
1040 | */ | ||
1041 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, | ||
1042 | bool wake) | ||
1043 | { | ||
1044 | } | ||
1045 | |||
1046 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | ||
1047 | |||
1048 | /* | 919 | /* |
1049 | * Because preemptible RCU does not exist, rcu_barrier() is just | 920 | * Because preemptible RCU does not exist, rcu_barrier() is just |
1050 | * another name for rcu_barrier_sched(). | 921 | * another name for rcu_barrier_sched(). |
@@ -1080,7 +951,7 @@ void exit_rcu(void) | |||
1080 | 951 | ||
1081 | static void rcu_initiate_boost_trace(struct rcu_node *rnp) | 952 | static void rcu_initiate_boost_trace(struct rcu_node *rnp) |
1082 | { | 953 | { |
1083 | if (list_empty(&rnp->blkd_tasks)) | 954 | if (!rcu_preempt_has_tasks(rnp)) |
1084 | rnp->n_balk_blkd_tasks++; | 955 | rnp->n_balk_blkd_tasks++; |
1085 | else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL) | 956 | else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL) |
1086 | rnp->n_balk_exp_gp_tasks++; | 957 | rnp->n_balk_exp_gp_tasks++; |
@@ -1127,7 +998,8 @@ static int rcu_boost(struct rcu_node *rnp) | |||
1127 | struct task_struct *t; | 998 | struct task_struct *t; |
1128 | struct list_head *tb; | 999 | struct list_head *tb; |
1129 | 1000 | ||
1130 | if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL) | 1001 | if (ACCESS_ONCE(rnp->exp_tasks) == NULL && |
1002 | ACCESS_ONCE(rnp->boost_tasks) == NULL) | ||
1131 | return 0; /* Nothing left to boost. */ | 1003 | return 0; /* Nothing left to boost. */ |
1132 | 1004 | ||
1133 | raw_spin_lock_irqsave(&rnp->lock, flags); | 1005 | raw_spin_lock_irqsave(&rnp->lock, flags); |
@@ -1175,15 +1047,11 @@ static int rcu_boost(struct rcu_node *rnp) | |||
1175 | */ | 1047 | */ |
1176 | t = container_of(tb, struct task_struct, rcu_node_entry); | 1048 | t = container_of(tb, struct task_struct, rcu_node_entry); |
1177 | rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); | 1049 | rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); |
1178 | init_completion(&rnp->boost_completion); | ||
1179 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 1050 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
1180 | /* Lock only for side effect: boosts task t's priority. */ | 1051 | /* Lock only for side effect: boosts task t's priority. */ |
1181 | rt_mutex_lock(&rnp->boost_mtx); | 1052 | rt_mutex_lock(&rnp->boost_mtx); |
1182 | rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ | 1053 | rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ |
1183 | 1054 | ||
1184 | /* Wait for boostee to be done w/boost_mtx before reinitializing. */ | ||
1185 | wait_for_completion(&rnp->boost_completion); | ||
1186 | |||
1187 | return ACCESS_ONCE(rnp->exp_tasks) != NULL || | 1055 | return ACCESS_ONCE(rnp->exp_tasks) != NULL || |
1188 | ACCESS_ONCE(rnp->boost_tasks) != NULL; | 1056 | ACCESS_ONCE(rnp->boost_tasks) != NULL; |
1189 | } | 1057 | } |
@@ -1416,12 +1284,8 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) | |||
1416 | for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) | 1284 | for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) |
1417 | if ((mask & 0x1) && cpu != outgoingcpu) | 1285 | if ((mask & 0x1) && cpu != outgoingcpu) |
1418 | cpumask_set_cpu(cpu, cm); | 1286 | cpumask_set_cpu(cpu, cm); |
1419 | if (cpumask_weight(cm) == 0) { | 1287 | if (cpumask_weight(cm) == 0) |
1420 | cpumask_setall(cm); | 1288 | cpumask_setall(cm); |
1421 | for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++) | ||
1422 | cpumask_clear_cpu(cpu, cm); | ||
1423 | WARN_ON_ONCE(cpumask_weight(cm) == 0); | ||
1424 | } | ||
1425 | set_cpus_allowed_ptr(t, cm); | 1289 | set_cpus_allowed_ptr(t, cm); |
1426 | free_cpumask_var(cm); | 1290 | free_cpumask_var(cm); |
1427 | } | 1291 | } |
@@ -1446,12 +1310,8 @@ static void __init rcu_spawn_boost_kthreads(void) | |||
1446 | for_each_possible_cpu(cpu) | 1310 | for_each_possible_cpu(cpu) |
1447 | per_cpu(rcu_cpu_has_work, cpu) = 0; | 1311 | per_cpu(rcu_cpu_has_work, cpu) = 0; |
1448 | BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); | 1312 | BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); |
1449 | rnp = rcu_get_root(rcu_state_p); | 1313 | rcu_for_each_leaf_node(rcu_state_p, rnp) |
1450 | (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); | 1314 | (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); |
1451 | if (NUM_RCU_NODES > 1) { | ||
1452 | rcu_for_each_leaf_node(rcu_state_p, rnp) | ||
1453 | (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); | ||
1454 | } | ||
1455 | } | 1315 | } |
1456 | 1316 | ||
1457 | static void rcu_prepare_kthreads(int cpu) | 1317 | static void rcu_prepare_kthreads(int cpu) |
@@ -1605,7 +1465,8 @@ static bool __maybe_unused rcu_try_advance_all_cbs(void) | |||
1605 | * completed since we last checked and there are | 1465 | * completed since we last checked and there are |
1606 | * callbacks not yet ready to invoke. | 1466 | * callbacks not yet ready to invoke. |
1607 | */ | 1467 | */ |
1608 | if (rdp->completed != rnp->completed && | 1468 | if ((rdp->completed != rnp->completed || |
1469 | unlikely(ACCESS_ONCE(rdp->gpwrap))) && | ||
1609 | rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL]) | 1470 | rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL]) |
1610 | note_gp_changes(rsp, rdp); | 1471 | note_gp_changes(rsp, rdp); |
1611 | 1472 | ||
@@ -1898,11 +1759,12 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu) | |||
1898 | ticks_value = rsp->gpnum - rdp->gpnum; | 1759 | ticks_value = rsp->gpnum - rdp->gpnum; |
1899 | } | 1760 | } |
1900 | print_cpu_stall_fast_no_hz(fast_no_hz, cpu); | 1761 | print_cpu_stall_fast_no_hz(fast_no_hz, cpu); |
1901 | pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n", | 1762 | pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n", |
1902 | cpu, ticks_value, ticks_title, | 1763 | cpu, ticks_value, ticks_title, |
1903 | atomic_read(&rdtp->dynticks) & 0xfff, | 1764 | atomic_read(&rdtp->dynticks) & 0xfff, |
1904 | rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting, | 1765 | rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting, |
1905 | rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), | 1766 | rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), |
1767 | ACCESS_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart, | ||
1906 | fast_no_hz); | 1768 | fast_no_hz); |
1907 | } | 1769 | } |
1908 | 1770 | ||
@@ -2056,9 +1918,26 @@ static void wake_nocb_leader(struct rcu_data *rdp, bool force) | |||
2056 | static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) | 1918 | static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) |
2057 | { | 1919 | { |
2058 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); | 1920 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); |
1921 | unsigned long ret; | ||
1922 | #ifdef CONFIG_PROVE_RCU | ||
2059 | struct rcu_head *rhp; | 1923 | struct rcu_head *rhp; |
1924 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
2060 | 1925 | ||
2061 | /* No-CBs CPUs might have callbacks on any of three lists. */ | 1926 | /* |
1927 | * Check count of all no-CBs callbacks awaiting invocation. | ||
1928 | * There needs to be a barrier before this function is called, | ||
1929 | * but associated with a prior determination that no more | ||
1930 | * callbacks would be posted. In the worst case, the first | ||
1931 | * barrier in _rcu_barrier() suffices (but the caller cannot | ||
1932 | * necessarily rely on this, not a substitute for the caller | ||
1933 | * getting the concurrency design right!). There must also be | ||
1934 | * a barrier between the following load an posting of a callback | ||
1935 | * (if a callback is in fact needed). This is associated with an | ||
1936 | * atomic_inc() in the caller. | ||
1937 | */ | ||
1938 | ret = atomic_long_read(&rdp->nocb_q_count); | ||
1939 | |||
1940 | #ifdef CONFIG_PROVE_RCU | ||
2062 | rhp = ACCESS_ONCE(rdp->nocb_head); | 1941 | rhp = ACCESS_ONCE(rdp->nocb_head); |
2063 | if (!rhp) | 1942 | if (!rhp) |
2064 | rhp = ACCESS_ONCE(rdp->nocb_gp_head); | 1943 | rhp = ACCESS_ONCE(rdp->nocb_gp_head); |
@@ -2072,8 +1951,9 @@ static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) | |||
2072 | cpu, rhp->func); | 1951 | cpu, rhp->func); |
2073 | WARN_ON_ONCE(1); | 1952 | WARN_ON_ONCE(1); |
2074 | } | 1953 | } |
1954 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
2075 | 1955 | ||
2076 | return !!rhp; | 1956 | return !!ret; |
2077 | } | 1957 | } |
2078 | 1958 | ||
2079 | /* | 1959 | /* |
@@ -2095,9 +1975,10 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp, | |||
2095 | struct task_struct *t; | 1975 | struct task_struct *t; |
2096 | 1976 | ||
2097 | /* Enqueue the callback on the nocb list and update counts. */ | 1977 | /* Enqueue the callback on the nocb list and update counts. */ |
1978 | atomic_long_add(rhcount, &rdp->nocb_q_count); | ||
1979 | /* rcu_barrier() relies on ->nocb_q_count add before xchg. */ | ||
2098 | old_rhpp = xchg(&rdp->nocb_tail, rhtp); | 1980 | old_rhpp = xchg(&rdp->nocb_tail, rhtp); |
2099 | ACCESS_ONCE(*old_rhpp) = rhp; | 1981 | ACCESS_ONCE(*old_rhpp) = rhp; |
2100 | atomic_long_add(rhcount, &rdp->nocb_q_count); | ||
2101 | atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy); | 1982 | atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy); |
2102 | smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */ | 1983 | smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */ |
2103 | 1984 | ||
@@ -2288,9 +2169,6 @@ wait_again: | |||
2288 | /* Move callbacks to wait-for-GP list, which is empty. */ | 2169 | /* Move callbacks to wait-for-GP list, which is empty. */ |
2289 | ACCESS_ONCE(rdp->nocb_head) = NULL; | 2170 | ACCESS_ONCE(rdp->nocb_head) = NULL; |
2290 | rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head); | 2171 | rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head); |
2291 | rdp->nocb_gp_count = atomic_long_xchg(&rdp->nocb_q_count, 0); | ||
2292 | rdp->nocb_gp_count_lazy = | ||
2293 | atomic_long_xchg(&rdp->nocb_q_count_lazy, 0); | ||
2294 | gotcbs = true; | 2172 | gotcbs = true; |
2295 | } | 2173 | } |
2296 | 2174 | ||
@@ -2338,9 +2216,6 @@ wait_again: | |||
2338 | /* Append callbacks to follower's "done" list. */ | 2216 | /* Append callbacks to follower's "done" list. */ |
2339 | tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail); | 2217 | tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail); |
2340 | *tail = rdp->nocb_gp_head; | 2218 | *tail = rdp->nocb_gp_head; |
2341 | atomic_long_add(rdp->nocb_gp_count, &rdp->nocb_follower_count); | ||
2342 | atomic_long_add(rdp->nocb_gp_count_lazy, | ||
2343 | &rdp->nocb_follower_count_lazy); | ||
2344 | smp_mb__after_atomic(); /* Store *tail before wakeup. */ | 2219 | smp_mb__after_atomic(); /* Store *tail before wakeup. */ |
2345 | if (rdp != my_rdp && tail == &rdp->nocb_follower_head) { | 2220 | if (rdp != my_rdp && tail == &rdp->nocb_follower_head) { |
2346 | /* | 2221 | /* |
@@ -2415,13 +2290,11 @@ static int rcu_nocb_kthread(void *arg) | |||
2415 | trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty"); | 2290 | trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty"); |
2416 | ACCESS_ONCE(rdp->nocb_follower_head) = NULL; | 2291 | ACCESS_ONCE(rdp->nocb_follower_head) = NULL; |
2417 | tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head); | 2292 | tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head); |
2418 | c = atomic_long_xchg(&rdp->nocb_follower_count, 0); | ||
2419 | cl = atomic_long_xchg(&rdp->nocb_follower_count_lazy, 0); | ||
2420 | rdp->nocb_p_count += c; | ||
2421 | rdp->nocb_p_count_lazy += cl; | ||
2422 | 2293 | ||
2423 | /* Each pass through the following loop invokes a callback. */ | 2294 | /* Each pass through the following loop invokes a callback. */ |
2424 | trace_rcu_batch_start(rdp->rsp->name, cl, c, -1); | 2295 | trace_rcu_batch_start(rdp->rsp->name, |
2296 | atomic_long_read(&rdp->nocb_q_count_lazy), | ||
2297 | atomic_long_read(&rdp->nocb_q_count), -1); | ||
2425 | c = cl = 0; | 2298 | c = cl = 0; |
2426 | while (list) { | 2299 | while (list) { |
2427 | next = list->next; | 2300 | next = list->next; |
@@ -2443,9 +2316,9 @@ static int rcu_nocb_kthread(void *arg) | |||
2443 | list = next; | 2316 | list = next; |
2444 | } | 2317 | } |
2445 | trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1); | 2318 | trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1); |
2446 | ACCESS_ONCE(rdp->nocb_p_count) = rdp->nocb_p_count - c; | 2319 | smp_mb__before_atomic(); /* _add after CB invocation. */ |
2447 | ACCESS_ONCE(rdp->nocb_p_count_lazy) = | 2320 | atomic_long_add(-c, &rdp->nocb_q_count); |
2448 | rdp->nocb_p_count_lazy - cl; | 2321 | atomic_long_add(-cl, &rdp->nocb_q_count_lazy); |
2449 | rdp->n_nocbs_invoked += c; | 2322 | rdp->n_nocbs_invoked += c; |
2450 | } | 2323 | } |
2451 | return 0; | 2324 | return 0; |