diff options
Diffstat (limited to 'kernel/rcu/tree_plugin.h')
-rw-r--r-- | kernel/rcu/tree_plugin.h | 257 |
1 files changed, 29 insertions, 228 deletions
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 97dba50f6fb2..1102765f91fd 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h | |||
@@ -285,7 +285,7 @@ static void rcu_qs(void) | |||
285 | TPS("cpuqs")); | 285 | TPS("cpuqs")); |
286 | __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); | 286 | __this_cpu_write(rcu_data.cpu_no_qs.b.norm, false); |
287 | barrier(); /* Coordinate with rcu_flavor_sched_clock_irq(). */ | 287 | barrier(); /* Coordinate with rcu_flavor_sched_clock_irq(). */ |
288 | current->rcu_read_unlock_special.b.need_qs = false; | 288 | WRITE_ONCE(current->rcu_read_unlock_special.b.need_qs, false); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
@@ -643,100 +643,6 @@ static void rcu_read_unlock_special(struct task_struct *t) | |||
643 | } | 643 | } |
644 | 644 | ||
645 | /* | 645 | /* |
646 | * Dump detailed information for all tasks blocking the current RCU | ||
647 | * grace period on the specified rcu_node structure. | ||
648 | */ | ||
649 | static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp) | ||
650 | { | ||
651 | unsigned long flags; | ||
652 | struct task_struct *t; | ||
653 | |||
654 | raw_spin_lock_irqsave_rcu_node(rnp, flags); | ||
655 | if (!rcu_preempt_blocked_readers_cgp(rnp)) { | ||
656 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
657 | return; | ||
658 | } | ||
659 | t = list_entry(rnp->gp_tasks->prev, | ||
660 | struct task_struct, rcu_node_entry); | ||
661 | list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) { | ||
662 | /* | ||
663 | * We could be printing a lot while holding a spinlock. | ||
664 | * Avoid triggering hard lockup. | ||
665 | */ | ||
666 | touch_nmi_watchdog(); | ||
667 | sched_show_task(t); | ||
668 | } | ||
669 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | ||
670 | } | ||
671 | |||
672 | /* | ||
673 | * Dump detailed information for all tasks blocking the current RCU | ||
674 | * grace period. | ||
675 | */ | ||
676 | static void rcu_print_detail_task_stall(void) | ||
677 | { | ||
678 | struct rcu_node *rnp = rcu_get_root(); | ||
679 | |||
680 | rcu_print_detail_task_stall_rnp(rnp); | ||
681 | rcu_for_each_leaf_node(rnp) | ||
682 | rcu_print_detail_task_stall_rnp(rnp); | ||
683 | } | ||
684 | |||
685 | static void rcu_print_task_stall_begin(struct rcu_node *rnp) | ||
686 | { | ||
687 | pr_err("\tTasks blocked on level-%d rcu_node (CPUs %d-%d):", | ||
688 | rnp->level, rnp->grplo, rnp->grphi); | ||
689 | } | ||
690 | |||
691 | static void rcu_print_task_stall_end(void) | ||
692 | { | ||
693 | pr_cont("\n"); | ||
694 | } | ||
695 | |||
696 | /* | ||
697 | * Scan the current list of tasks blocked within RCU read-side critical | ||
698 | * sections, printing out the tid of each. | ||
699 | */ | ||
700 | static int rcu_print_task_stall(struct rcu_node *rnp) | ||
701 | { | ||
702 | struct task_struct *t; | ||
703 | int ndetected = 0; | ||
704 | |||
705 | if (!rcu_preempt_blocked_readers_cgp(rnp)) | ||
706 | return 0; | ||
707 | rcu_print_task_stall_begin(rnp); | ||
708 | t = list_entry(rnp->gp_tasks->prev, | ||
709 | struct task_struct, rcu_node_entry); | ||
710 | list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) { | ||
711 | pr_cont(" P%d", t->pid); | ||
712 | ndetected++; | ||
713 | } | ||
714 | rcu_print_task_stall_end(); | ||
715 | return ndetected; | ||
716 | } | ||
717 | |||
718 | /* | ||
719 | * Scan the current list of tasks blocked within RCU read-side critical | ||
720 | * sections, printing out the tid of each that is blocking the current | ||
721 | * expedited grace period. | ||
722 | */ | ||
723 | static int rcu_print_task_exp_stall(struct rcu_node *rnp) | ||
724 | { | ||
725 | struct task_struct *t; | ||
726 | int ndetected = 0; | ||
727 | |||
728 | if (!rnp->exp_tasks) | ||
729 | return 0; | ||
730 | t = list_entry(rnp->exp_tasks->prev, | ||
731 | struct task_struct, rcu_node_entry); | ||
732 | list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry) { | ||
733 | pr_cont(" P%d", t->pid); | ||
734 | ndetected++; | ||
735 | } | ||
736 | return ndetected; | ||
737 | } | ||
738 | |||
739 | /* | ||
740 | * Check that the list of blocked tasks for the newly completed grace | 646 | * Check that the list of blocked tasks for the newly completed grace |
741 | * period is in fact empty. It is a serious bug to complete a grace | 647 | * period is in fact empty. It is a serious bug to complete a grace |
742 | * period that still has RCU readers blocked! This function must be | 648 | * period that still has RCU readers blocked! This function must be |
@@ -804,19 +710,25 @@ static void rcu_flavor_sched_clock_irq(int user) | |||
804 | 710 | ||
805 | /* | 711 | /* |
806 | * Check for a task exiting while in a preemptible-RCU read-side | 712 | * Check for a task exiting while in a preemptible-RCU read-side |
807 | * critical section, clean up if so. No need to issue warnings, | 713 | * critical section, clean up if so. No need to issue warnings, as |
808 | * as debug_check_no_locks_held() already does this if lockdep | 714 | * debug_check_no_locks_held() already does this if lockdep is enabled. |
809 | * is enabled. | 715 | * Besides, if this function does anything other than just immediately |
716 | * return, there was a bug of some sort. Spewing warnings from this | ||
717 | * function is like as not to simply obscure important prior warnings. | ||
810 | */ | 718 | */ |
811 | void exit_rcu(void) | 719 | void exit_rcu(void) |
812 | { | 720 | { |
813 | struct task_struct *t = current; | 721 | struct task_struct *t = current; |
814 | 722 | ||
815 | if (likely(list_empty(¤t->rcu_node_entry))) | 723 | if (unlikely(!list_empty(¤t->rcu_node_entry))) { |
724 | t->rcu_read_lock_nesting = 1; | ||
725 | barrier(); | ||
726 | WRITE_ONCE(t->rcu_read_unlock_special.b.blocked, true); | ||
727 | } else if (unlikely(t->rcu_read_lock_nesting)) { | ||
728 | t->rcu_read_lock_nesting = 1; | ||
729 | } else { | ||
816 | return; | 730 | return; |
817 | t->rcu_read_lock_nesting = 1; | 731 | } |
818 | barrier(); | ||
819 | t->rcu_read_unlock_special.b.blocked = true; | ||
820 | __rcu_read_unlock(); | 732 | __rcu_read_unlock(); |
821 | rcu_preempt_deferred_qs(current); | 733 | rcu_preempt_deferred_qs(current); |
822 | } | 734 | } |
@@ -980,33 +892,6 @@ static bool rcu_preempt_need_deferred_qs(struct task_struct *t) | |||
980 | static void rcu_preempt_deferred_qs(struct task_struct *t) { } | 892 | static void rcu_preempt_deferred_qs(struct task_struct *t) { } |
981 | 893 | ||
982 | /* | 894 | /* |
983 | * Because preemptible RCU does not exist, we never have to check for | ||
984 | * tasks blocked within RCU read-side critical sections. | ||
985 | */ | ||
986 | static void rcu_print_detail_task_stall(void) | ||
987 | { | ||
988 | } | ||
989 | |||
990 | /* | ||
991 | * Because preemptible RCU does not exist, we never have to check for | ||
992 | * tasks blocked within RCU read-side critical sections. | ||
993 | */ | ||
994 | static int rcu_print_task_stall(struct rcu_node *rnp) | ||
995 | { | ||
996 | return 0; | ||
997 | } | ||
998 | |||
999 | /* | ||
1000 | * Because preemptible RCU does not exist, we never have to check for | ||
1001 | * tasks blocked within RCU read-side critical sections that are | ||
1002 | * blocking the current expedited grace period. | ||
1003 | */ | ||
1004 | static int rcu_print_task_exp_stall(struct rcu_node *rnp) | ||
1005 | { | ||
1006 | return 0; | ||
1007 | } | ||
1008 | |||
1009 | /* | ||
1010 | * Because there is no preemptible RCU, there can be no readers blocked, | 895 | * Because there is no preemptible RCU, there can be no readers blocked, |
1011 | * so there is no need to check for blocked tasks. So check only for | 896 | * so there is no need to check for blocked tasks. So check only for |
1012 | * bogus qsmask values. | 897 | * bogus qsmask values. |
@@ -1185,8 +1070,6 @@ static int rcu_boost_kthread(void *arg) | |||
1185 | static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) | 1070 | static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) |
1186 | __releases(rnp->lock) | 1071 | __releases(rnp->lock) |
1187 | { | 1072 | { |
1188 | struct task_struct *t; | ||
1189 | |||
1190 | raw_lockdep_assert_held_rcu_node(rnp); | 1073 | raw_lockdep_assert_held_rcu_node(rnp); |
1191 | if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) { | 1074 | if (!rcu_preempt_blocked_readers_cgp(rnp) && rnp->exp_tasks == NULL) { |
1192 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | 1075 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
@@ -1200,9 +1083,8 @@ static void rcu_initiate_boost(struct rcu_node *rnp, unsigned long flags) | |||
1200 | if (rnp->exp_tasks == NULL) | 1083 | if (rnp->exp_tasks == NULL) |
1201 | rnp->boost_tasks = rnp->gp_tasks; | 1084 | rnp->boost_tasks = rnp->gp_tasks; |
1202 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | 1085 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
1203 | t = rnp->boost_kthread_task; | 1086 | rcu_wake_cond(rnp->boost_kthread_task, |
1204 | if (t) | 1087 | rnp->boost_kthread_status); |
1205 | rcu_wake_cond(t, rnp->boost_kthread_status); | ||
1206 | } else { | 1088 | } else { |
1207 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); | 1089 | raw_spin_unlock_irqrestore_rcu_node(rnp, flags); |
1208 | } | 1090 | } |
@@ -1649,98 +1531,6 @@ static void rcu_cleanup_after_idle(void) | |||
1649 | 1531 | ||
1650 | #endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */ | 1532 | #endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */ |
1651 | 1533 | ||
1652 | #ifdef CONFIG_RCU_FAST_NO_HZ | ||
1653 | |||
1654 | static void print_cpu_stall_fast_no_hz(char *cp, int cpu) | ||
1655 | { | ||
1656 | struct rcu_data *rdp = &per_cpu(rcu_data, cpu); | ||
1657 | |||
1658 | sprintf(cp, "last_accelerate: %04lx/%04lx, Nonlazy posted: %c%c%c", | ||
1659 | rdp->last_accelerate & 0xffff, jiffies & 0xffff, | ||
1660 | ".l"[rdp->all_lazy], | ||
1661 | ".L"[!rcu_segcblist_n_nonlazy_cbs(&rdp->cblist)], | ||
1662 | ".D"[!rdp->tick_nohz_enabled_snap]); | ||
1663 | } | ||
1664 | |||
1665 | #else /* #ifdef CONFIG_RCU_FAST_NO_HZ */ | ||
1666 | |||
1667 | static void print_cpu_stall_fast_no_hz(char *cp, int cpu) | ||
1668 | { | ||
1669 | *cp = '\0'; | ||
1670 | } | ||
1671 | |||
1672 | #endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */ | ||
1673 | |||
1674 | /* Initiate the stall-info list. */ | ||
1675 | static void print_cpu_stall_info_begin(void) | ||
1676 | { | ||
1677 | pr_cont("\n"); | ||
1678 | } | ||
1679 | |||
1680 | /* | ||
1681 | * Print out diagnostic information for the specified stalled CPU. | ||
1682 | * | ||
1683 | * If the specified CPU is aware of the current RCU grace period, then | ||
1684 | * print the number of scheduling clock interrupts the CPU has taken | ||
1685 | * during the time that it has been aware. Otherwise, print the number | ||
1686 | * of RCU grace periods that this CPU is ignorant of, for example, "1" | ||
1687 | * if the CPU was aware of the previous grace period. | ||
1688 | * | ||
1689 | * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info. | ||
1690 | */ | ||
1691 | static void print_cpu_stall_info(int cpu) | ||
1692 | { | ||
1693 | unsigned long delta; | ||
1694 | char fast_no_hz[72]; | ||
1695 | struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu); | ||
1696 | char *ticks_title; | ||
1697 | unsigned long ticks_value; | ||
1698 | |||
1699 | /* | ||
1700 | * We could be printing a lot while holding a spinlock. Avoid | ||
1701 | * triggering hard lockup. | ||
1702 | */ | ||
1703 | touch_nmi_watchdog(); | ||
1704 | |||
1705 | ticks_value = rcu_seq_ctr(rcu_state.gp_seq - rdp->gp_seq); | ||
1706 | if (ticks_value) { | ||
1707 | ticks_title = "GPs behind"; | ||
1708 | } else { | ||
1709 | ticks_title = "ticks this GP"; | ||
1710 | ticks_value = rdp->ticks_this_gp; | ||
1711 | } | ||
1712 | print_cpu_stall_fast_no_hz(fast_no_hz, cpu); | ||
1713 | delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq); | ||
1714 | pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n", | ||
1715 | cpu, | ||
1716 | "O."[!!cpu_online(cpu)], | ||
1717 | "o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)], | ||
1718 | "N."[!!(rdp->grpmask & rdp->mynode->qsmaskinitnext)], | ||
1719 | !IS_ENABLED(CONFIG_IRQ_WORK) ? '?' : | ||
1720 | rdp->rcu_iw_pending ? (int)min(delta, 9UL) + '0' : | ||
1721 | "!."[!delta], | ||
1722 | ticks_value, ticks_title, | ||
1723 | rcu_dynticks_snap(rdp) & 0xfff, | ||
1724 | rdp->dynticks_nesting, rdp->dynticks_nmi_nesting, | ||
1725 | rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu), | ||
1726 | READ_ONCE(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart, | ||
1727 | fast_no_hz); | ||
1728 | } | ||
1729 | |||
1730 | /* Terminate the stall-info list. */ | ||
1731 | static void print_cpu_stall_info_end(void) | ||
1732 | { | ||
1733 | pr_err("\t"); | ||
1734 | } | ||
1735 | |||
1736 | /* Zero ->ticks_this_gp and snapshot the number of RCU softirq handlers. */ | ||
1737 | static void zero_cpu_stall_ticks(struct rcu_data *rdp) | ||
1738 | { | ||
1739 | rdp->ticks_this_gp = 0; | ||
1740 | rdp->softirq_snap = kstat_softirqs_cpu(RCU_SOFTIRQ, smp_processor_id()); | ||
1741 | WRITE_ONCE(rdp->last_fqs_resched, jiffies); | ||
1742 | } | ||
1743 | |||
1744 | #ifdef CONFIG_RCU_NOCB_CPU | 1534 | #ifdef CONFIG_RCU_NOCB_CPU |
1745 | 1535 | ||
1746 | /* | 1536 | /* |
@@ -1766,11 +1556,22 @@ static void zero_cpu_stall_ticks(struct rcu_data *rdp) | |||
1766 | */ | 1556 | */ |
1767 | 1557 | ||
1768 | 1558 | ||
1769 | /* Parse the boot-time rcu_nocb_mask CPU list from the kernel parameters. */ | 1559 | /* |
1560 | * Parse the boot-time rcu_nocb_mask CPU list from the kernel parameters. | ||
1561 | * The string after the "rcu_nocbs=" is either "all" for all CPUs, or a | ||
1562 | * comma-separated list of CPUs and/or CPU ranges. If an invalid list is | ||
1563 | * given, a warning is emitted and all CPUs are offloaded. | ||
1564 | */ | ||
1770 | static int __init rcu_nocb_setup(char *str) | 1565 | static int __init rcu_nocb_setup(char *str) |
1771 | { | 1566 | { |
1772 | alloc_bootmem_cpumask_var(&rcu_nocb_mask); | 1567 | alloc_bootmem_cpumask_var(&rcu_nocb_mask); |
1773 | cpulist_parse(str, rcu_nocb_mask); | 1568 | if (!strcasecmp(str, "all")) |
1569 | cpumask_setall(rcu_nocb_mask); | ||
1570 | else | ||
1571 | if (cpulist_parse(str, rcu_nocb_mask)) { | ||
1572 | pr_warn("rcu_nocbs= bad CPU range, all CPUs set\n"); | ||
1573 | cpumask_setall(rcu_nocb_mask); | ||
1574 | } | ||
1774 | return 1; | 1575 | return 1; |
1775 | } | 1576 | } |
1776 | __setup("rcu_nocbs=", rcu_nocb_setup); | 1577 | __setup("rcu_nocbs=", rcu_nocb_setup); |