Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp709843rwb; Fri, 13 Jan 2023 03:19:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXu1BpylwH3LfdYKCeP1IXY8YJSS0otAnY5Wl/b+6gpuWOxRH35CFPQ7c8X6n9JQQH2RKEVw X-Received: by 2002:a05:6a20:3c93:b0:b0:c30:5819 with SMTP id b19-20020a056a203c9300b000b00c305819mr123603999pzj.1.1673608766393; Fri, 13 Jan 2023 03:19:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673608766; cv=none; d=google.com; s=arc-20160816; b=eztsheXuen/tUuWVNvDR1fjOXgWcfzvavlol4aOYkAsJeq7XUl/S0p2NyKNnUKjBo0 AMhl7tQFBY0YdF8vNRetoE+52CDBWho/ln2vSq+Vm7m8PXVSzHhD5O3ieNKtd0j/Qrkv QdlSbjyxE11QrG2ja2hc2VJBeEsPccOyofK6UhTXR/Jh/m12vjrmE0pXeveXYFISwHpH ibdWGm2BZ5c6FpATcTW91ep/EqjxLCoctuFlYpSJfTk6ykxmfQhskiYs7R1TBKD/dVPd VcxNDrgmOegoaqhzhuIbZPqJYyXKWXIE8spTe5Vl2awRFc6f2Mlq9UtjjE82QZW7NuPI jWxg== 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=vSeGLo/6MjQf1Y0hpWNapngY12GMpi375moMWVTYS+Q=; b=YDgCDve1Npl23EycuN+bCfN7KiGrxtHoeLMouBPRdTDGgf5FGjBfWw/bukqggaxJuX qGLpngXg+Cp+QIDT9miuwxkSD98xxZ3qq+12tuuMx9WcNS32ByDoVYp1UHyjvmB75s3e 10uiiVn0WT9vByPg9+YIOjd3mClXHMJCmASaD6hkpriuZAH4yTzQxK9xxElNwXA+gdfK Iwsjt5r+JhRGRrrRI6mUrqCAKXYFowDooNxVQIQcWto+oPAdD4Wfl9VjcNH7Ep1xVfbF 5oOY19HsT2EG5MvoidflYJB4HPgoSxHyuJGwTQLAyjhmg2VTGc7vmRvgYZIkNvGxbQi8 zxaA== 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 f2-20020a63de02000000b00478d123065bsi19684207pgg.402.2023.01.13.03.19.19; Fri, 13 Jan 2023 03:19:26 -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 S240980AbjAMK7S (ORCPT + 53 others); Fri, 13 Jan 2023 05:59:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241576AbjAMK6q (ORCPT ); Fri, 13 Jan 2023 05:58:46 -0500 Received: from mx6.didiglobal.com (mx6.didiglobal.com [111.202.70.123]) by lindbergh.monkeyblade.net (Postfix) with SMTP id CC90459F9A for ; Fri, 13 Jan 2023 02:54:28 -0800 (PST) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx6.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id 4A6A611069780C; Fri, 13 Jan 2023 18:54:25 +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; Fri, 13 Jan 2023 18:54:24 +0800 Date: Fri, 13 Jan 2023 18:54:13 +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: <20230113105413.GA30243@didi-ThinkCentre-M930t-N000> Mail-Followup-To: yu.c.chen@intel.com, pmladek@suse.com, zyhtheonly@gmail.com, linux-kernel@vger.kernel.org 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. Also, we move the parent info to a following new line. It would better solve the situation when the task is not alive and we could not get information about the parent. Signed-off-by: Tio Zhang --- kernel/sched/core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cb2aa2b54c7a..5be3f476ee5b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -8853,7 +8853,6 @@ SYSCALL_DEFINE2(sched_rr_get_interval_time32, pid_t, pid, void sched_show_task(struct task_struct *p) { unsigned long free = 0; - int ppid; if (!try_get_task_stack(p)) return; @@ -8865,14 +8864,16 @@ void sched_show_task(struct task_struct *p) #ifdef CONFIG_DEBUG_STACK_USAGE free = stack_not_used(p); #endif - ppid = 0; + pr_cont(" stack:%-5lu pid:%-5d flags:0x%08lx\n", + free, task_pid_nr(p), read_task_thread_flags(p)); + 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); + + pr_info("parent:%-15.15s ppid:%-6d", parent->comm, task_pid_nr(parent)); + } 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)); print_worker_info(KERN_INFO, p); print_stop_info(KERN_INFO, p); -- 2.17.1