All of lore.kernel.org
 help / color / mirror / Atom feed
From: Schspa Shi <schspa@gmail.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com
Cc: linux-kernel@vger.kernel.org, Schspa Shi <schspa@gmail.com>
Subject: [PATCH] sched: Dump stacktrace when some task failed to stop
Date: Fri, 20 May 2022 00:11:25 +0800	[thread overview]
Message-ID: <20220519161125.41144-1-schspa@gmail.com> (raw)

Some processes may not be stopped, such as workqueue workers.

Add this dump_stack to easily figure out which process caused the problems.

Before this change:

<4>[  517.545889] ------------[ cut here ]------------
<4>[  517.545901] Dying CPU not properly vacated!
<4>[  517.546366] ---[ end trace 0000000000000002 ]---
<4>[  518.546831] CPU6 enqueued tasks (2 total):
<4>[  518.546855] 	pid: 49, name: migration/6
<4>[  518.547010] 	pid: 6231, name: kworker/6:0

Signed-off-by: Schspa Shi <schspa@gmail.com>
---
 kernel/sched/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 53596842f0d8..de6b5320e4d7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -9416,7 +9416,14 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
 			continue;
 
 		printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
+		if (p != current)
+			sched_show_task(p);
 	}
+	/*
+	 * We need the stack of each cpu to analyze who is blocking the
+	 * current cpu scheduling
+	 */
+	trigger_all_cpu_backtrace();
 }
 
 int sched_cpu_dying(unsigned int cpu)
-- 
2.24.3 (Apple Git-128)


             reply	other threads:[~2022-05-19 16:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 16:11 Schspa Shi [this message]
2022-05-19 16:29 ` [PATCH] sched: Dump stacktrace when some task failed to stop Valentin Schneider
2022-05-19 16:46   ` Schspa Shi

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=20220519161125.41144-1-schspa@gmail.com \
    --to=schspa@gmail.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.