linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tio Zhang <tiozhang@didiglobal.com>
To: <pmladek@suse.com>, <akpm@linux-foundation.org>, <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <tiozhang@didiglobal.com>
Subject: [PATCH] kernel/hung_task: print real_parent->comm, pid in check_hung_task
Date: Thu, 24 Nov 2022 19:25:26 +0800	[thread overview]
Message-ID: <20221124112526.GA21832@didi-ThinkCentre-M930t-N000> (raw)

We can avoid a hung task by fixing the process who causes it.
But sometimes it is difficult to find out which service 
the bad process belongs to by only knowing its pid and comm.
Since userspace tools to learn who launches the bad process
do not always work when we get a hung task, 
it is helpful printing the parent by kernel.

Signed-off-by: Tio Zhang <tiozhang@didiglobal.com>
---
 kernel/hung_task.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index c71889f3f3fc..33543d27bd5c 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -89,6 +89,7 @@ static struct notifier_block panic_block = {
 
 static void check_hung_task(struct task_struct *t, unsigned long timeout)
 {
+	struct task_struct *p = t->real_parent;
 	unsigned long switch_count = t->nvcsw + t->nivcsw;
 
 	/*
@@ -129,8 +130,8 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
 	if (sysctl_hung_task_warnings) {
 		if (sysctl_hung_task_warnings > 0)
 			sysctl_hung_task_warnings--;
-		pr_err("INFO: task %s:%d blocked for more than %ld seconds.\n",
-		       t->comm, t->pid, (jiffies - t->last_switch_time) / HZ);
+		pr_err("INFO: task %s:%d, parent %s:%d blocked for more than %ld seconds.\n",
+		       t->comm, t->pid, p->comm, p->pid, (jiffies - t->last_switch_time) / HZ);
 		pr_err("      %s %s %.*s\n",
 			print_tainted(), init_utsname()->release,
 			(int)strcspn(init_utsname()->version, " "),
-- 
2.17.1


             reply	other threads:[~2022-11-24 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-24 11:25 Tio Zhang [this message]
2022-11-28 15:48 ` [PATCH] kernel/hung_task: print real_parent->comm, pid in check_hung_task Petr Mladek

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=20221124112526.GA21832@didi-ThinkCentre-M930t-N000 \
    --to=tiozhang@didiglobal.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=pmladek@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).