lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230119110642.GA6463@didi-ThinkCentre-M930t-N000>
Date:   Thu, 19 Jan 2023 19:06:42 +0800
From:   Tio Zhang <tiozhang@...iglobal.com>
To:     <pmladek@...e.com>, <yu.c.chen@...el.com>
CC:     <juri.lelli@...hat.com>, <mingo@...hat.com>,
        <peterz@...radead.org>, <vincent.guittot@...aro.org>,
        <linux-kernel@...r.kernel.org>, <tiozhang@...iglobal.com>,
        <zyhtheonly@...il.com>, <zwp10758@...il.com>, <zyhtheonly@...h.net>
Subject: [PATCH v2] sched: print parent comm in sched_show_task()

Knowing who the parent is might be useful for debugging.
For example, we can sometimes resolve kernel hung tasks by stopping
the person who begins those hung tasks.
With the parent's name printed in sched_show_task(),
it might be helpful to let people know which "service" should be operated.
Also, we move the parent info to a following new line while keeping the
original line the same.
And we would print "parent:unknown         ppid:<NULL>"
when the task is not alive.

Signed-off-by: Tio Zhang <tiozhang@...iglobal.com>
---
 kernel/sched/core.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cb2aa2b54c7a..5690a5700f9e 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8854,6 +8854,7 @@ void sched_show_task(struct task_struct *p)
 {
 	unsigned long free = 0;
 	int ppid;
+	char *pcomm = NULL;
 
 	if (!try_get_task_stack(p))
 		return;
@@ -8867,13 +8868,22 @@ void sched_show_task(struct task_struct *p)
 #endif
 	ppid = 0;
 	rcu_read_lock();
-	if (pid_alive(p))
-		ppid = task_pid_nr(rcu_dereference(p->real_parent));
+	if (pid_alive(p)) {
+		struct task_struct *parent = rcu_dereference(p->real_parent);
+
+		ppid = task_pid_nr(parent);
+		pcomm = parent->comm;
+	}
 	rcu_read_unlock();
 	pr_cont(" stack:%-5lu pid:%-5d ppid:%-6d flags:0x%08lx\n",
 		free, task_pid_nr(p), ppid,
 		read_task_thread_flags(p));
 
+	if (!ppid)
+		pr_info("parent:unknown         ppid:<NULL>\n");
+	else
+		pr_info("parent:%-15.15s ppid:%-6d\n", pcomm, ppid);
+
 	print_worker_info(KERN_INFO, p);
 	print_stop_info(KERN_INFO, p);
 	show_stack(p, NULL, KERN_INFO);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ