Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3392907rwl; Tue, 27 Dec 2022 08:28:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXugezvSpZbKLpBQrGAJtnsRCRuUz0XWWsi613aWumjkc0Kk8bCo7lsK/nqPEXshbRpuJY1I X-Received: by 2002:a05:6402:360f:b0:474:47ce:ee8e with SMTP id el15-20020a056402360f00b0047447ceee8emr19318164edb.30.1672158504315; Tue, 27 Dec 2022 08:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672158504; cv=none; d=google.com; s=arc-20160816; b=ezA/GIpRYiYctBxroA3oYBrMUgBP47RyQipYxLTf1J5wqtbx2ju10LmPJh/giLBR7p LHfSv/l4Kgkzqe+4R83zomvsvxjCleCsA/vpQ3UerUtyjuATf43EIL/+0SixNnSFyUvP w6K6pF1xj5Czm+kPmZZs8VzSqDCBCYsJvVx8fq8I7VzaiSmPwIa5oDl0uLJ5NBt1CySE F21iwyYzQMye/POqZKzsixkVP5wBNtn2z6X5/v1DMvqqVwWppoJM2y+Ozx+rl4s8LW2a Dgrsf1KIxedRG6YJ5ci6BXnQMGp7k3ctd+GtxzsfazMNvqKUhGJvu7oFWUyg9Gmsmhew Y90g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :mail-followup-to:message-id:subject:cc:to:from:date; bh=7cnJhsivzXyG9fXObNFRMlj3QfGR/fzd4J/WnbthD/s=; b=OwUbJ0ry0KZMjm3T/EtZoqIgCPkP7fGVLanqWduN9x+eT487ErBkoBF7zxS73xiLf0 sorFM+M/PJCHaDK0COmnIkg827uurP2k6PkAGZGHO6jvj0HbsOBMYvA4JXi6sW/lboaS zpdZKuks+B8FIZBccT93uL9tvlZbrn/ZSQ/Qn7CVApf6UMDVW34QcF5306C6q03XRdFy gO2htUpV3Z2v5cbFECy9X1orKoU+CHqISdgYIxlggqGNOOBABbcRt50mfGUpOjPTFM03 eAL4vGT4d8ouzGyM+uxxaG0OPNIo6+9eR0WY+r/dbyqGftpKZ4QruW2v6griHYsEZynA Nmuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a056402524b00b0047c0eb653e6si11916588edd.247.2022.12.27.08.28.08; Tue, 27 Dec 2022 08:28:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229911AbiL0QOZ (ORCPT + 66 others); Tue, 27 Dec 2022 11:14:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229588AbiL0QOX (ORCPT ); Tue, 27 Dec 2022 11:14:23 -0500 Received: from mx6.didiglobal.com (mx6.didiglobal.com [111.202.70.123]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 16F1DCDC for ; Tue, 27 Dec 2022 08:14:21 -0800 (PST) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx6.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id A20A511002B812; Wed, 28 Dec 2022 00:14:17 +0800 (CST) Received: from didi-ThinkCentre-M930t-N000 (10.79.64.101) by ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 28 Dec 2022 00:14:17 +0800 Date: Wed, 28 Dec 2022 00:14:00 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: Tio Zhang To: , , , CC: , , , , Subject: [PATCH] sched: print parent comm in sched_show_task() Message-ID: <20221227161400.GA7646@didi-ThinkCentre-M930t-N000> Mail-Followup-To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, pmladek@suse.com, zyhtheonly@gmail.com, zyhtheonly@yeah.net, zwp10758@gmail.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.79.64.101] X-ClientProxiedBy: ZJY03-PUBMBX-01.didichuxing.com (10.79.71.12) To ZJY02-ACTMBX-02.didichuxing.com (10.79.65.12) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Tio Zhang --- kernel/sched/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cb2aa2b54c7a..6f4aef0fed58 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[TASK_COMM_LEN]; if (!try_get_task_stack(p)) return; @@ -8867,11 +8868,13 @@ void sched_show_task(struct task_struct *p) #endif ppid = 0; rcu_read_lock(); - if (pid_alive(p)) + if (pid_alive(p)) { ppid = task_pid_nr(rcu_dereference(p->real_parent)); + get_task_comm(pcomm, rcu_dereference(p->real_parent)); + } rcu_read_unlock(); - pr_cont(" stack:%-5lu pid:%-5d ppid:%-6d flags:0x%08lx\n", - free, task_pid_nr(p), ppid, + pr_cont(" stack:%-5lu pid:%-5d ppid:%-6d parent:%-15.15s flags:0x%08lx\n", + free, task_pid_nr(p), ppid, pcomm, read_task_thread_flags(p)); print_worker_info(KERN_INFO, p); -- 2.17.1