diff options
Diffstat (limited to 'kernel/rcu/tree_plugin.h')
| -rw-r--r-- | kernel/rcu/tree_plugin.h | 276 |
1 files changed, 74 insertions, 202 deletions
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 3ec85cb5d544..0d7bbe3095ad 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. |
| @@ -53,7 +49,6 @@ DEFINE_PER_CPU(char, rcu_cpu_has_work); | |||
| 53 | static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */ | 49 | static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */ |
| 54 | static bool have_rcu_nocb_mask; /* Was rcu_nocb_mask allocated? */ | 50 | static bool have_rcu_nocb_mask; /* Was rcu_nocb_mask allocated? */ |
| 55 | static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */ | 51 | static bool __read_mostly rcu_nocb_poll; /* Offload kthread are to poll. */ |
| 56 | static char __initdata nocb_buf[NR_CPUS * 5]; | ||
| 57 | #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ | 52 | #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ |
| 58 | 53 | ||
| 59 | /* | 54 | /* |
| @@ -103,6 +98,8 @@ RCU_STATE_INITIALIZER(rcu_preempt, 'p', call_rcu); | |||
| 103 | static struct rcu_state *rcu_state_p = &rcu_preempt_state; | 98 | static struct rcu_state *rcu_state_p = &rcu_preempt_state; |
| 104 | 99 | ||
| 105 | static int rcu_preempted_readers_exp(struct rcu_node *rnp); | 100 | static int rcu_preempted_readers_exp(struct rcu_node *rnp); |
| 101 | static void rcu_report_exp_rnp(struct rcu_state *rsp, struct rcu_node *rnp, | ||
| 102 | bool wake); | ||
| 106 | 103 | ||
| 107 | /* | 104 | /* |
| 108 | * Tell them what RCU they are running. | 105 | * Tell them what RCU they are running. |
| @@ -114,25 +111,6 @@ static void __init rcu_bootup_announce(void) | |||
| 114 | } | 111 | } |
| 115 | 112 | ||
| 116 | /* | 113 | /* |
| 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 | 114 | * 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 | 115 | * 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 | 116 | * not in a quiescent state. There might be any number of tasks blocked |
| @@ -307,15 +285,25 @@ static struct list_head *rcu_next_node_entry(struct task_struct *t, | |||
| 307 | } | 285 | } |
| 308 | 286 | ||
| 309 | /* | 287 | /* |
| 288 | * Return true if the specified rcu_node structure has tasks that were | ||
| 289 | * preempted within an RCU read-side critical section. | ||
| 290 | */ | ||
| 291 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp) | ||
| 292 | { | ||
| 293 | return !list_empty(&rnp->blkd_tasks); | ||
| 294 | } | ||
| 295 | |||
| 296 | /* | ||
| 310 | * Handle special cases during rcu_read_unlock(), such as needing to | 297 | * Handle special cases during rcu_read_unlock(), such as needing to |
| 311 | * notify RCU core processing or task having blocked during the RCU | 298 | * notify RCU core processing or task having blocked during the RCU |
| 312 | * read-side critical section. | 299 | * read-side critical section. |
| 313 | */ | 300 | */ |
| 314 | void rcu_read_unlock_special(struct task_struct *t) | 301 | void rcu_read_unlock_special(struct task_struct *t) |
| 315 | { | 302 | { |
| 316 | int empty; | 303 | bool empty; |
| 317 | int empty_exp; | 304 | bool empty_exp; |
| 318 | int empty_exp_now; | 305 | bool empty_norm; |
| 306 | bool empty_exp_now; | ||
| 319 | unsigned long flags; | 307 | unsigned long flags; |
| 320 | struct list_head *np; | 308 | struct list_head *np; |
| 321 | #ifdef CONFIG_RCU_BOOST | 309 | #ifdef CONFIG_RCU_BOOST |
| @@ -367,7 +355,8 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
| 367 | break; | 355 | break; |
| 368 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ | 356 | raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */ |
| 369 | } | 357 | } |
| 370 | empty = !rcu_preempt_blocked_readers_cgp(rnp); | 358 | empty = !rcu_preempt_has_tasks(rnp); |
| 359 | empty_norm = !rcu_preempt_blocked_readers_cgp(rnp); | ||
| 371 | empty_exp = !rcu_preempted_readers_exp(rnp); | 360 | empty_exp = !rcu_preempted_readers_exp(rnp); |
| 372 | smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ | 361 | smp_mb(); /* ensure expedited fastpath sees end of RCU c-s. */ |
| 373 | np = rcu_next_node_entry(t, rnp); | 362 | np = rcu_next_node_entry(t, rnp); |
| @@ -387,13 +376,21 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
| 387 | #endif /* #ifdef CONFIG_RCU_BOOST */ | 376 | #endif /* #ifdef CONFIG_RCU_BOOST */ |
| 388 | 377 | ||
| 389 | /* | 378 | /* |
| 379 | * If this was the last task on the list, go see if we | ||
| 380 | * need to propagate ->qsmaskinit bit clearing up the | ||
| 381 | * rcu_node tree. | ||
| 382 | */ | ||
| 383 | if (!empty && !rcu_preempt_has_tasks(rnp)) | ||
| 384 | rcu_cleanup_dead_rnp(rnp); | ||
| 385 | |||
| 386 | /* | ||
| 390 | * If this was the last task on the current list, and if | 387 | * If this was the last task on the current list, and if |
| 391 | * we aren't waiting on any CPUs, report the quiescent state. | 388 | * we aren't waiting on any CPUs, report the quiescent state. |
| 392 | * Note that rcu_report_unblock_qs_rnp() releases rnp->lock, | 389 | * Note that rcu_report_unblock_qs_rnp() releases rnp->lock, |
| 393 | * so we must take a snapshot of the expedited state. | 390 | * so we must take a snapshot of the expedited state. |
| 394 | */ | 391 | */ |
| 395 | empty_exp_now = !rcu_preempted_readers_exp(rnp); | 392 | empty_exp_now = !rcu_preempted_readers_exp(rnp); |
| 396 | if (!empty && !rcu_preempt_blocked_readers_cgp(rnp)) { | 393 | if (!empty_norm && !rcu_preempt_blocked_readers_cgp(rnp)) { |
| 397 | trace_rcu_quiescent_state_report(TPS("preempt_rcu"), | 394 | trace_rcu_quiescent_state_report(TPS("preempt_rcu"), |
| 398 | rnp->gpnum, | 395 | rnp->gpnum, |
| 399 | 0, rnp->qsmask, | 396 | 0, rnp->qsmask, |
| @@ -408,10 +405,8 @@ void rcu_read_unlock_special(struct task_struct *t) | |||
| 408 | 405 | ||
| 409 | #ifdef CONFIG_RCU_BOOST | 406 | #ifdef CONFIG_RCU_BOOST |
| 410 | /* Unboost if we were boosted. */ | 407 | /* Unboost if we were boosted. */ |
| 411 | if (drop_boost_mutex) { | 408 | if (drop_boost_mutex) |
| 412 | rt_mutex_unlock(&rnp->boost_mtx); | 409 | rt_mutex_unlock(&rnp->boost_mtx); |
| 413 | complete(&rnp->boost_completion); | ||
| 414 | } | ||
| 415 | #endif /* #ifdef CONFIG_RCU_BOOST */ | 410 | #endif /* #ifdef CONFIG_RCU_BOOST */ |
| 416 | 411 | ||
| 417 | /* | 412 | /* |
| @@ -519,99 +514,13 @@ static int rcu_print_task_stall(struct rcu_node *rnp) | |||
| 519 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | 514 | static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) |
| 520 | { | 515 | { |
| 521 | WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)); | 516 | WARN_ON_ONCE(rcu_preempt_blocked_readers_cgp(rnp)); |
| 522 | if (!list_empty(&rnp->blkd_tasks)) | 517 | if (rcu_preempt_has_tasks(rnp)) |
| 523 | rnp->gp_tasks = rnp->blkd_tasks.next; | 518 | rnp->gp_tasks = rnp->blkd_tasks.next; |
| 524 | WARN_ON_ONCE(rnp->qsmask); | 519 | WARN_ON_ONCE(rnp->qsmask); |
| 525 | } | 520 | } |
| 526 | 521 | ||
| 527 | #ifdef CONFIG_HOTPLUG_CPU | 522 | #ifdef CONFIG_HOTPLUG_CPU |
| 528 | 523 | ||
| 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 */ | 524 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| 616 | 525 | ||
| 617 | /* | 526 | /* |
| @@ -771,7 +680,7 @@ sync_rcu_preempt_exp_init(struct rcu_state *rsp, struct rcu_node *rnp) | |||
| 771 | 680 | ||
| 772 | raw_spin_lock_irqsave(&rnp->lock, flags); | 681 | raw_spin_lock_irqsave(&rnp->lock, flags); |
| 773 | smp_mb__after_unlock_lock(); | 682 | smp_mb__after_unlock_lock(); |
| 774 | if (list_empty(&rnp->blkd_tasks)) { | 683 | if (!rcu_preempt_has_tasks(rnp)) { |
| 775 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 684 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
| 776 | } else { | 685 | } else { |
| 777 | rnp->exp_tasks = rnp->blkd_tasks.next; | 686 | rnp->exp_tasks = rnp->blkd_tasks.next; |
| @@ -933,15 +842,6 @@ static void __init rcu_bootup_announce(void) | |||
| 933 | } | 842 | } |
| 934 | 843 | ||
| 935 | /* | 844 | /* |
| 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 | 845 | * Because preemptible RCU does not exist, we never have to check for |
| 946 | * CPUs being in quiescent states. | 846 | * CPUs being in quiescent states. |
| 947 | */ | 847 | */ |
| @@ -960,11 +860,12 @@ static int rcu_preempt_blocked_readers_cgp(struct rcu_node *rnp) | |||
| 960 | 860 | ||
| 961 | #ifdef CONFIG_HOTPLUG_CPU | 861 | #ifdef CONFIG_HOTPLUG_CPU |
| 962 | 862 | ||
| 963 | /* Because preemptible RCU does not exist, no quieting of tasks. */ | 863 | /* |
| 964 | static void rcu_report_unblock_qs_rnp(struct rcu_node *rnp, unsigned long flags) | 864 | * Because there is no preemptible RCU, there can be no readers blocked. |
| 965 | __releases(rnp->lock) | 865 | */ |
| 866 | static bool rcu_preempt_has_tasks(struct rcu_node *rnp) | ||
| 966 | { | 867 | { |
| 967 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 868 | return false; |
| 968 | } | 869 | } |
| 969 | 870 | ||
| 970 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ | 871 | #endif /* #ifdef CONFIG_HOTPLUG_CPU */ |
| @@ -996,23 +897,6 @@ static void rcu_preempt_check_blocked_tasks(struct rcu_node *rnp) | |||
| 996 | WARN_ON_ONCE(rnp->qsmask); | 897 | WARN_ON_ONCE(rnp->qsmask); |
| 997 | } | 898 | } |
| 998 | 899 | ||
| 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 | /* | 900 | /* |
| 1017 | * Because preemptible RCU does not exist, it never has any callbacks | 901 | * Because preemptible RCU does not exist, it never has any callbacks |
| 1018 | * to check. | 902 | * to check. |
| @@ -1031,20 +915,6 @@ void synchronize_rcu_expedited(void) | |||
| 1031 | } | 915 | } |
| 1032 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); | 916 | EXPORT_SYMBOL_GPL(synchronize_rcu_expedited); |
| 1033 | 917 | ||
| 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 | /* | 918 | /* |
| 1049 | * Because preemptible RCU does not exist, rcu_barrier() is just | 919 | * Because preemptible RCU does not exist, rcu_barrier() is just |
| 1050 | * another name for rcu_barrier_sched(). | 920 | * another name for rcu_barrier_sched(). |
| @@ -1080,7 +950,7 @@ void exit_rcu(void) | |||
| 1080 | 950 | ||
| 1081 | static void rcu_initiate_boost_trace(struct rcu_node *rnp) | 951 | static void rcu_initiate_boost_trace(struct rcu_node *rnp) |
| 1082 | { | 952 | { |
| 1083 | if (list_empty(&rnp->blkd_tasks)) | 953 | if (!rcu_preempt_has_tasks(rnp)) |
| 1084 | rnp->n_balk_blkd_tasks++; | 954 | rnp->n_balk_blkd_tasks++; |
| 1085 | else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL) | 955 | else if (rnp->exp_tasks == NULL && rnp->gp_tasks == NULL) |
| 1086 | rnp->n_balk_exp_gp_tasks++; | 956 | rnp->n_balk_exp_gp_tasks++; |
| @@ -1127,7 +997,8 @@ static int rcu_boost(struct rcu_node *rnp) | |||
| 1127 | struct task_struct *t; | 997 | struct task_struct *t; |
| 1128 | struct list_head *tb; | 998 | struct list_head *tb; |
| 1129 | 999 | ||
| 1130 | if (rnp->exp_tasks == NULL && rnp->boost_tasks == NULL) | 1000 | if (ACCESS_ONCE(rnp->exp_tasks) == NULL && |
| 1001 | ACCESS_ONCE(rnp->boost_tasks) == NULL) | ||
| 1131 | return 0; /* Nothing left to boost. */ | 1002 | return 0; /* Nothing left to boost. */ |
| 1132 | 1003 | ||
| 1133 | raw_spin_lock_irqsave(&rnp->lock, flags); | 1004 | raw_spin_lock_irqsave(&rnp->lock, flags); |
| @@ -1175,15 +1046,11 @@ static int rcu_boost(struct rcu_node *rnp) | |||
| 1175 | */ | 1046 | */ |
| 1176 | t = container_of(tb, struct task_struct, rcu_node_entry); | 1047 | t = container_of(tb, struct task_struct, rcu_node_entry); |
| 1177 | rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); | 1048 | rt_mutex_init_proxy_locked(&rnp->boost_mtx, t); |
| 1178 | init_completion(&rnp->boost_completion); | ||
| 1179 | raw_spin_unlock_irqrestore(&rnp->lock, flags); | 1049 | raw_spin_unlock_irqrestore(&rnp->lock, flags); |
| 1180 | /* Lock only for side effect: boosts task t's priority. */ | 1050 | /* Lock only for side effect: boosts task t's priority. */ |
| 1181 | rt_mutex_lock(&rnp->boost_mtx); | 1051 | rt_mutex_lock(&rnp->boost_mtx); |
| 1182 | rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ | 1052 | rt_mutex_unlock(&rnp->boost_mtx); /* Then keep lockdep happy. */ |
| 1183 | 1053 | ||
| 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 || | 1054 | return ACCESS_ONCE(rnp->exp_tasks) != NULL || |
| 1188 | ACCESS_ONCE(rnp->boost_tasks) != NULL; | 1055 | ACCESS_ONCE(rnp->boost_tasks) != NULL; |
| 1189 | } | 1056 | } |
| @@ -1416,12 +1283,8 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu) | |||
| 1416 | for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) | 1283 | for (cpu = rnp->grplo; cpu <= rnp->grphi; cpu++, mask >>= 1) |
| 1417 | if ((mask & 0x1) && cpu != outgoingcpu) | 1284 | if ((mask & 0x1) && cpu != outgoingcpu) |
| 1418 | cpumask_set_cpu(cpu, cm); | 1285 | cpumask_set_cpu(cpu, cm); |
| 1419 | if (cpumask_weight(cm) == 0) { | 1286 | if (cpumask_weight(cm) == 0) |
| 1420 | cpumask_setall(cm); | 1287 | 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); | 1288 | set_cpus_allowed_ptr(t, cm); |
| 1426 | free_cpumask_var(cm); | 1289 | free_cpumask_var(cm); |
| 1427 | } | 1290 | } |
| @@ -1446,12 +1309,8 @@ static void __init rcu_spawn_boost_kthreads(void) | |||
| 1446 | for_each_possible_cpu(cpu) | 1309 | for_each_possible_cpu(cpu) |
| 1447 | per_cpu(rcu_cpu_has_work, cpu) = 0; | 1310 | per_cpu(rcu_cpu_has_work, cpu) = 0; |
| 1448 | BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); | 1311 | BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); |
| 1449 | rnp = rcu_get_root(rcu_state_p); | 1312 | rcu_for_each_leaf_node(rcu_state_p, rnp) |
| 1450 | (void)rcu_spawn_one_boost_kthread(rcu_state_p, rnp); | 1313 | (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 | } | 1314 | } |
| 1456 | 1315 | ||
| 1457 | static void rcu_prepare_kthreads(int cpu) | 1316 | static void rcu_prepare_kthreads(int cpu) |
| @@ -1605,7 +1464,8 @@ static bool __maybe_unused rcu_try_advance_all_cbs(void) | |||
| 1605 | * completed since we last checked and there are | 1464 | * completed since we last checked and there are |
| 1606 | * callbacks not yet ready to invoke. | 1465 | * callbacks not yet ready to invoke. |
| 1607 | */ | 1466 | */ |
| 1608 | if (rdp->completed != rnp->completed && | 1467 | if ((rdp->completed != rnp->completed || |
| 1468 | unlikely(ACCESS_ONCE(rdp->gpwrap))) && | ||
| 1609 | rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL]) | 1469 | rdp->nxttail[RCU_DONE_TAIL] != rdp->nxttail[RCU_NEXT_TAIL]) |
| 1610 | note_gp_changes(rsp, rdp); | 1470 | note_gp_changes(rsp, rdp); |
| 1611 | 1471 | ||
| @@ -1898,11 +1758,12 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu) | |||
| 1898 | ticks_value = rsp->gpnum - rdp->gpnum; | 1758 | ticks_value = rsp->gpnum - rdp->gpnum; |
| 1899 | } | 1759 | } |
| 1900 | print_cpu_stall_fast_no_hz(fast_no_hz, cpu); | 1760 | 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", | 1761 | pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u fqs=%ld %s\n", |
| 1902 | cpu, ticks_value, ticks_title, | 1762 | cpu, ticks_value, ticks_title, |
| 1903 | atomic_read(&rdtp->dynticks) & 0xfff, | 1763 | atomic_read(&rdtp->dynticks) & 0xfff, |
| 1904 | rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting, | 1764 | rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting, |
| 1905 | rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), | 1765 | rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), |
| 1766 | ACCESS_ONCE(rsp->n_force_qs) - rsp->n_force_qs_gpstart, | ||
| 1906 | fast_no_hz); | 1767 | fast_no_hz); |
| 1907 | } | 1768 | } |
| 1908 | 1769 | ||
| @@ -2056,9 +1917,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) | 1917 | static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) |
| 2057 | { | 1918 | { |
| 2058 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); | 1919 | struct rcu_data *rdp = per_cpu_ptr(rsp->rda, cpu); |
| 1920 | unsigned long ret; | ||
| 1921 | #ifdef CONFIG_PROVE_RCU | ||
| 2059 | struct rcu_head *rhp; | 1922 | struct rcu_head *rhp; |
| 1923 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
| 2060 | 1924 | ||
| 2061 | /* No-CBs CPUs might have callbacks on any of three lists. */ | 1925 | /* |
| 1926 | * Check count of all no-CBs callbacks awaiting invocation. | ||
| 1927 | * There needs to be a barrier before this function is called, | ||
| 1928 | * but associated with a prior determination that no more | ||
| 1929 | * callbacks would be posted. In the worst case, the first | ||
| 1930 | * barrier in _rcu_barrier() suffices (but the caller cannot | ||
| 1931 | * necessarily rely on this, not a substitute for the caller | ||
| 1932 | * getting the concurrency design right!). There must also be | ||
| 1933 | * a barrier between the following load an posting of a callback | ||
| 1934 | * (if a callback is in fact needed). This is associated with an | ||
| 1935 | * atomic_inc() in the caller. | ||
| 1936 | */ | ||
| 1937 | ret = atomic_long_read(&rdp->nocb_q_count); | ||
| 1938 | |||
| 1939 | #ifdef CONFIG_PROVE_RCU | ||
| 2062 | rhp = ACCESS_ONCE(rdp->nocb_head); | 1940 | rhp = ACCESS_ONCE(rdp->nocb_head); |
| 2063 | if (!rhp) | 1941 | if (!rhp) |
| 2064 | rhp = ACCESS_ONCE(rdp->nocb_gp_head); | 1942 | rhp = ACCESS_ONCE(rdp->nocb_gp_head); |
| @@ -2072,8 +1950,9 @@ static bool rcu_nocb_cpu_needs_barrier(struct rcu_state *rsp, int cpu) | |||
| 2072 | cpu, rhp->func); | 1950 | cpu, rhp->func); |
| 2073 | WARN_ON_ONCE(1); | 1951 | WARN_ON_ONCE(1); |
| 2074 | } | 1952 | } |
| 1953 | #endif /* #ifdef CONFIG_PROVE_RCU */ | ||
| 2075 | 1954 | ||
| 2076 | return !!rhp; | 1955 | return !!ret; |
| 2077 | } | 1956 | } |
| 2078 | 1957 | ||
| 2079 | /* | 1958 | /* |
| @@ -2095,9 +1974,10 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp, | |||
| 2095 | struct task_struct *t; | 1974 | struct task_struct *t; |
| 2096 | 1975 | ||
| 2097 | /* Enqueue the callback on the nocb list and update counts. */ | 1976 | /* Enqueue the callback on the nocb list and update counts. */ |
| 1977 | atomic_long_add(rhcount, &rdp->nocb_q_count); | ||
| 1978 | /* rcu_barrier() relies on ->nocb_q_count add before xchg. */ | ||
| 2098 | old_rhpp = xchg(&rdp->nocb_tail, rhtp); | 1979 | old_rhpp = xchg(&rdp->nocb_tail, rhtp); |
| 2099 | ACCESS_ONCE(*old_rhpp) = rhp; | 1980 | 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); | 1981 | atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy); |
| 2102 | smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */ | 1982 | smp_mb__after_atomic(); /* Store *old_rhpp before _wake test. */ |
| 2103 | 1983 | ||
| @@ -2288,9 +2168,6 @@ wait_again: | |||
| 2288 | /* Move callbacks to wait-for-GP list, which is empty. */ | 2168 | /* Move callbacks to wait-for-GP list, which is empty. */ |
| 2289 | ACCESS_ONCE(rdp->nocb_head) = NULL; | 2169 | ACCESS_ONCE(rdp->nocb_head) = NULL; |
| 2290 | rdp->nocb_gp_tail = xchg(&rdp->nocb_tail, &rdp->nocb_head); | 2170 | 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; | 2171 | gotcbs = true; |
| 2295 | } | 2172 | } |
| 2296 | 2173 | ||
| @@ -2338,9 +2215,6 @@ wait_again: | |||
| 2338 | /* Append callbacks to follower's "done" list. */ | 2215 | /* Append callbacks to follower's "done" list. */ |
| 2339 | tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail); | 2216 | tail = xchg(&rdp->nocb_follower_tail, rdp->nocb_gp_tail); |
| 2340 | *tail = rdp->nocb_gp_head; | 2217 | *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. */ | 2218 | smp_mb__after_atomic(); /* Store *tail before wakeup. */ |
| 2345 | if (rdp != my_rdp && tail == &rdp->nocb_follower_head) { | 2219 | if (rdp != my_rdp && tail == &rdp->nocb_follower_head) { |
| 2346 | /* | 2220 | /* |
| @@ -2415,13 +2289,11 @@ static int rcu_nocb_kthread(void *arg) | |||
| 2415 | trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty"); | 2289 | trace_rcu_nocb_wake(rdp->rsp->name, rdp->cpu, "WokeNonEmpty"); |
| 2416 | ACCESS_ONCE(rdp->nocb_follower_head) = NULL; | 2290 | ACCESS_ONCE(rdp->nocb_follower_head) = NULL; |
| 2417 | tail = xchg(&rdp->nocb_follower_tail, &rdp->nocb_follower_head); | 2291 | 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 | 2292 | ||
| 2423 | /* Each pass through the following loop invokes a callback. */ | 2293 | /* Each pass through the following loop invokes a callback. */ |
| 2424 | trace_rcu_batch_start(rdp->rsp->name, cl, c, -1); | 2294 | trace_rcu_batch_start(rdp->rsp->name, |
| 2295 | atomic_long_read(&rdp->nocb_q_count_lazy), | ||
| 2296 | atomic_long_read(&rdp->nocb_q_count), -1); | ||
| 2425 | c = cl = 0; | 2297 | c = cl = 0; |
| 2426 | while (list) { | 2298 | while (list) { |
| 2427 | next = list->next; | 2299 | next = list->next; |
| @@ -2443,9 +2315,9 @@ static int rcu_nocb_kthread(void *arg) | |||
| 2443 | list = next; | 2315 | list = next; |
| 2444 | } | 2316 | } |
| 2445 | trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1); | 2317 | trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1); |
| 2446 | ACCESS_ONCE(rdp->nocb_p_count) = rdp->nocb_p_count - c; | 2318 | smp_mb__before_atomic(); /* _add after CB invocation. */ |
| 2447 | ACCESS_ONCE(rdp->nocb_p_count_lazy) = | 2319 | atomic_long_add(-c, &rdp->nocb_q_count); |
| 2448 | rdp->nocb_p_count_lazy - cl; | 2320 | atomic_long_add(-cl, &rdp->nocb_q_count_lazy); |
| 2449 | rdp->n_nocbs_invoked += c; | 2321 | rdp->n_nocbs_invoked += c; |
| 2450 | } | 2322 | } |
| 2451 | return 0; | 2323 | return 0; |
| @@ -2513,8 +2385,8 @@ void __init rcu_init_nohz(void) | |||
| 2513 | cpumask_and(rcu_nocb_mask, cpu_possible_mask, | 2385 | cpumask_and(rcu_nocb_mask, cpu_possible_mask, |
| 2514 | rcu_nocb_mask); | 2386 | rcu_nocb_mask); |
| 2515 | } | 2387 | } |
| 2516 | cpulist_scnprintf(nocb_buf, sizeof(nocb_buf), rcu_nocb_mask); | 2388 | pr_info("\tOffload RCU callbacks from CPUs: %*pbl.\n", |
| 2517 | pr_info("\tOffload RCU callbacks from CPUs: %s.\n", nocb_buf); | 2389 | cpumask_pr_args(rcu_nocb_mask)); |
| 2518 | if (rcu_nocb_poll) | 2390 | if (rcu_nocb_poll) |
| 2519 | pr_info("\tPoll for callbacks from no-CBs CPUs.\n"); | 2391 | pr_info("\tPoll for callbacks from no-CBs CPUs.\n"); |
| 2520 | 2392 | ||
