mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
	rostedt@goodmis.org, Zqiang <qiang1.zhang@intel.com>,
	"Paul E . McKenney" <paulmck@kernel.org>
Subject: [PATCH rcu 01/23] rcu: Dump rcuc kthread status for CPUs not reporting quiescent state
Date: Mon, 20 Jun 2022 16:10:07 -0700	[thread overview]
Message-ID: <20220620231029.3844583-1-paulmck@kernel.org> (raw)
In-Reply-To: <20220620231027.GA3844372@paulmck-ThinkPad-P17-Gen-1>

From: Zqiang <qiang1.zhang@intel.com>

If the rcutree.use_softirq kernel boot parameter is disabled, then it is
possible that a RCU CPU stall is due to the rcuc kthreads being starved of
CPU time.  There is currently no easy way to infer this from the RCU CPU
stall warning output.  This commit therefore adds a string of the form "
rcuc=%ld jiffies(starved)" to a given CPU's output if the corresponding
rcuc kthread has been starved for more than two seconds.

[ paulmck: Eliminate extraneous space characters. ]

Signed-off-by: Zqiang <qiang1.zhang@intel.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
 kernel/rcu/tree_stall.h | 49 ++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 28 deletions(-)

diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 4995c078cff98..3556637768fd5 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -409,7 +409,19 @@ static bool rcu_is_gp_kthread_starving(unsigned long *jp)
 
 static bool rcu_is_rcuc_kthread_starving(struct rcu_data *rdp, unsigned long *jp)
 {
-	unsigned long j = jiffies - READ_ONCE(rdp->rcuc_activity);
+	int cpu;
+	struct task_struct *rcuc;
+	unsigned long j;
+
+	rcuc = rdp->rcu_cpu_kthread_task;
+	if (!rcuc)
+		return false;
+
+	cpu = task_cpu(rcuc);
+	if (cpu_is_offline(cpu) || idle_cpu(cpu))
+		return false;
+
+	j = jiffies - READ_ONCE(rdp->rcuc_activity);
 
 	if (jp)
 		*jp = j;
@@ -434,6 +446,9 @@ static void print_cpu_stall_info(int cpu)
 	struct rcu_data *rdp = per_cpu_ptr(&rcu_data, cpu);
 	char *ticks_title;
 	unsigned long ticks_value;
+	bool rcuc_starved;
+	unsigned long j;
+	char buf[32];
 
 	/*
 	 * We could be printing a lot while holding a spinlock.  Avoid
@@ -451,7 +466,10 @@ static void print_cpu_stall_info(int cpu)
 	delta = rcu_seq_ctr(rdp->mynode->gp_seq - rdp->rcu_iw_gp_seq);
 	falsepositive = rcu_is_gp_kthread_starving(NULL) &&
 			rcu_dynticks_in_eqs(rcu_dynticks_snap(rdp));
-	pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld %s\n",
+	rcuc_starved = rcu_is_rcuc_kthread_starving(rdp, &j);
+	if (rcuc_starved)
+		sprintf(buf, " rcuc=%ld jiffies(starved)", j);
+	pr_err("\t%d-%c%c%c%c: (%lu %s) idle=%03x/%ld/%#lx softirq=%u/%u fqs=%ld%s%s\n",
 	       cpu,
 	       "O."[!!cpu_online(cpu)],
 	       "o."[!!(rdp->grpmask & rdp->mynode->qsmaskinit)],
@@ -464,32 +482,10 @@ static void print_cpu_stall_info(int cpu)
 	       rdp->dynticks_nesting, rdp->dynticks_nmi_nesting,
 	       rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
 	       data_race(rcu_state.n_force_qs) - rcu_state.n_force_qs_gpstart,
+	       rcuc_starved ? buf : "",
 	       falsepositive ? " (false positive?)" : "");
 }
 
-static void rcuc_kthread_dump(struct rcu_data *rdp)
-{
-	int cpu;
-	unsigned long j;
-	struct task_struct *rcuc;
-
-	rcuc = rdp->rcu_cpu_kthread_task;
-	if (!rcuc)
-		return;
-
-	cpu = task_cpu(rcuc);
-	if (cpu_is_offline(cpu) || idle_cpu(cpu))
-		return;
-
-	if (!rcu_is_rcuc_kthread_starving(rdp, &j))
-		return;
-
-	pr_err("%s kthread starved for %ld jiffies\n", rcuc->comm, j);
-	sched_show_task(rcuc);
-	if (!trigger_single_cpu_backtrace(cpu))
-		dump_cpu_task(cpu);
-}
-
 /* Complain about starvation of grace-period kthread.  */
 static void rcu_check_gp_kthread_starvation(void)
 {
@@ -662,9 +658,6 @@ static void print_cpu_stall(unsigned long gps)
 	rcu_check_gp_kthread_expired_fqs_timer();
 	rcu_check_gp_kthread_starvation();
 
-	if (!use_softirq)
-		rcuc_kthread_dump(rdp);
-
 	rcu_dump_cpu_stacks();
 
 	raw_spin_lock_irqsave_rcu_node(rnp, flags);
-- 
2.31.1.189.g2e36527f23


  reply	other threads:[~2022-06-20 23:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 23:10 [PATCH rcu 0/23] RCU/context-tracking updates for v5.20 Paul E. McKenney
2022-06-20 23:10 ` Paul E. McKenney [this message]
2022-06-20 23:10 ` [PATCH rcu 02/23] rcu: Apply noinstr to rcu_idle_enter() and rcu_idle_exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 03/23] context_tracking: Remove unused context_tracking_in_user() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 04/23] context_tracking: Add a note about noinstr VS unsafe context tracking functions Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 05/23] context_tracking: Rename __context_tracking_enter/exit() to __ct_user_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 06/23] context_tracking: Rename context_tracking_user_enter/exit() to user_enter/exit_callable() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 07/23] context_tracking: Rename context_tracking_enter/exit() to ct_user_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 08/23] context_tracking: Rename context_tracking_cpu_set() to ct_cpu_track_user() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 09/23] context_tracking: Split user tracking Kconfig Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 10/23] context_tracking: Take idle eqs entrypoints over RCU Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 11/23] context_tracking: Take IRQ " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 12/23] context_tracking: Take NMI " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 13/23] rcu/context-tracking: Remove rcu_irq_enter/exit() Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 14/23] rcu/context_tracking: Move dynticks counter to context tracking Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 15/23] rcu/context_tracking: Move dynticks_nesting " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 16/23] rcu/context_tracking: Move dynticks_nmi_nesting " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 17/23] rcu/context-tracking: Move deferred nocb resched " Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 18/23] rcu/context-tracking: Move RCU-dynticks internal functions to context_tracking Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 19/23] rcu/context-tracking: Remove unused and/or unecessary middle functions Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 20/23] context_tracking: Convert state to atomic_t Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 21/23] rcu/context_tracking: Merge dynticks counter and context tracking states Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 22/23] MAINTAINERS: Add Paul as context tracking maintainer Paul E. McKenney
2022-06-20 23:10 ` [PATCH rcu 23/23] context_tracking: Interrupts always disabled for ct_idle_exit() Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220620231029.3844583-1-paulmck@kernel.org \
    --to=paulmck@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiang1.zhang@intel.com \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®