rcu: Move FAST_NO_HZ stall-warning code to tree_stall.h
authorPaul E. McKenney <paulmck@linux.ibm.com>
Sat, 12 Jan 2019 05:05:17 +0000 (21:05 -0800)
committerPaul E. McKenney <paulmck@linux.ibm.com>
Tue, 26 Mar 2019 21:40:13 +0000 (14:40 -0700)
This commit further consolidates the stall-warning code by moving
print_cpu_stall_info() and its helper functions along with
zero_cpu_stall_ticks() to kernel/rcu/tree_stall.h.

Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
kernel/rcu/tree.h
kernel/rcu/tree_plugin.h
kernel/rcu/tree_stall.h

index d73472af49e708835ecfe2eafc1690a57dec53d8..49bf3b00bb5032af82beb1c66635b5215658abc3 100644 (file)
@@ -416,7 +416,6 @@ static void rcu_prepare_for_idle(void);
 static bool rcu_preempt_has_tasks(struct rcu_node *rnp);
 static bool rcu_preempt_need_deferred_qs(struct task_struct *t);
 static void rcu_preempt_deferred_qs(struct task_struct *t);
-static void print_cpu_stall_info(int cpu);
 static void zero_cpu_stall_ticks(struct rcu_data *rdp);
 static bool rcu_nocb_cpu_needs_barrier(int cpu);
 static struct swait_queue_head *rcu_nocb_gp_get(struct rcu_node *rnp);
index 2df5bb04fd7a365584cd8b062535686f3497e252..a1f9d7c15bd82822e87eaae35347e91224101de2 100644 (file)
@@ -1528,86 +1528,6 @@ static void rcu_cleanup_after_idle(void)
 
 #endif /* #else #if !defined(CONFIG_RCU_FAST_NO_HZ) */
 
-#ifdef CONFIG_RCU_FAST_NO_HZ
-
-static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
-{
-       struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
-
-       sprintf(cp, "last_accelerate: %04lx/%04lx, Nonlazy posted: %c%c%c",
-               rdp->last_accelerate & 0xffff, jiffies & 0xffff,
-               ".l"[rdp->all_lazy],
-               ".L"[!rcu_segcblist_n_nonlazy_cbs(&rdp->cblist)],
-               ".D"[!rdp->tick_nohz_enabled_snap]);
-}
-
-#else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
-
-static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
-{
-       *cp = '\0';
-}
-
-#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
-
-/*
- * Print out diagnostic information for the specified stalled CPU.
- *
- * If the specified CPU is aware of the current RCU grace period, then
- * print the number of scheduling clock interrupts the CPU has taken
- * during the time that it has been aware.  Otherwise, print the number
- * of RCU grace periods that this CPU is ignorant of, for example, "1"
- * if the CPU was aware of the previous grace period.
- *
- * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
- */
-static void print_cpu_stall_info(int cpu)
-{
-       unsigned long delta;
-       char fast_no_hz[72];
-       struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
-       char *ticks_title;
-       unsigned long ticks_value;
-
-       /*
-        * We could be printing a lot while holding a spinlock.  Avoid
-        * triggering hard lockup.
-        */
-       touch_nmi_watchdog();
-
-       ticks_value = rcu_seq_ctr(rcu_state.gp_seq - rdp->gp_seq);
-       if (ticks_value) {
-               ticks_title = "GPs behind";
-       } else {
-               ticks_title = "ticks this GP";
-               ticks_value = rdp->ticks_this_gp;
-       }
-       print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
-       delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq);
-       pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n",
-              cpu,
-              "O."[!!cpu_online(cpu)],
-              "o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)],
-              "N."[!!(rdp->grpmask & rdp->mynode->qsmaskinitnext)],
-              !IS_ENABLED(CONFIG_IRQ_WORK) ? '?' :
-                       rdp->rcu_iw_pending ? (int)min(delta, 9UL) + '0' :
-                               "!."[!delta],
-              ticks_value, ticks_title,
-              rcu_dynticks_snap(rdp) & 0xfff,
-              rdp->dynticks_nesting, rdp->dynticks_nmi_nesting,
-              rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
-              READ_ONCE(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart,
-              fast_no_hz);
-}
-
-/* Zero ->ticks_this_gp and snapshot the number of RCU softirq handlers. */
-static void zero_cpu_stall_ticks(struct rcu_data *rdp)
-{
-       rdp->ticks_this_gp = 0;
-       rdp->softirq_snap = kstat_softirqs_cpu(RCU_SOFTIRQ, smp_processor_id());
-       WRITE_ONCE(rdp->last_fqs_resched, jiffies);
-}
-
 #ifdef CONFIG_RCU_NOCB_CPU
 
 /*
index 7ef3b596e45ff2a9ec3c53c661167fe6de7b3544..19b915380a6fca3fe83410424eae099e00f23249 100644 (file)
@@ -223,6 +223,86 @@ static void panic_on_rcu_stall(void)
                panic("RCU Stall\n");
 }
 
+#ifdef CONFIG_RCU_FAST_NO_HZ
+
+static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
+{
+       struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
+
+       sprintf(cp, "last_accelerate: %04lx/%04lx, Nonlazy posted: %c%c%c",
+               rdp->last_accelerate & 0xffff, jiffies & 0xffff,
+               ".l"[rdp->all_lazy],
+               ".L"[!rcu_segcblist_n_nonlazy_cbs(&rdp->cblist)],
+               ".D"[!rdp->tick_nohz_enabled_snap]);
+}
+
+#else /* #ifdef CONFIG_RCU_FAST_NO_HZ */
+
+static void print_cpu_stall_fast_no_hz(char *cp, int cpu)
+{
+       *cp = '\0';
+}
+
+#endif /* #else #ifdef CONFIG_RCU_FAST_NO_HZ */
+
+/*
+ * Print out diagnostic information for the specified stalled CPU.
+ *
+ * If the specified CPU is aware of the current RCU grace period, then
+ * print the number of scheduling clock interrupts the CPU has taken
+ * during the time that it has been aware.  Otherwise, print the number
+ * of RCU grace periods that this CPU is ignorant of, for example, "1"
+ * if the CPU was aware of the previous grace period.
+ *
+ * Also print out idle and (if CONFIG_RCU_FAST_NO_HZ) idle-entry info.
+ */
+static void print_cpu_stall_info(int cpu)
+{
+       unsigned long delta;
+       char fast_no_hz[72];
+       struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
+       char *ticks_title;
+       unsigned long ticks_value;
+
+       /*
+        * We could be printing a lot while holding a spinlock.  Avoid
+        * triggering hard lockup.
+        */
+       touch_nmi_watchdog();
+
+       ticks_value = rcu_seq_ctr(rcu_state.gp_seq - rdp->gp_seq);
+       if (ticks_value) {
+               ticks_title = "GPs behind";
+       } else {
+               ticks_title = "ticks this GP";
+               ticks_value = rdp->ticks_this_gp;
+       }
+       print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
+       delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq);
+       pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n",
+              cpu,
+              "O."[!!cpu_online(cpu)],
+              "o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)],
+              "N."[!!(rdp->grpmask & rdp->mynode->qsmaskinitnext)],
+              !IS_ENABLED(CONFIG_IRQ_WORK) ? '?' :
+                       rdp->rcu_iw_pending ? (int)min(delta, 9UL) + '0' :
+                               "!."[!delta],
+              ticks_value, ticks_title,
+              rcu_dynticks_snap(rdp) & 0xfff,
+              rdp->dynticks_nesting, rdp->dynticks_nmi_nesting,
+              rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
+              READ_ONCE(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart,
+              fast_no_hz);
+}
+
+/* Zero ->ticks_this_gp and snapshot the number of RCU softirq handlers. */
+static void zero_cpu_stall_ticks(struct rcu_data *rdp)
+{
+       rdp->ticks_this_gp = 0;
+       rdp->softirq_snap = kstat_softirqs_cpu(RCU_SOFTIRQ, smp_processor_id());
+       WRITE_ONCE(rdp->last_fqs_resched, jiffies);
+}
+
 static void print_other_cpu_stall(unsigned long gp_seq)
 {
        int cpu;