Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3797362rwl; Mon, 27 Mar 2023 20:53:20 -0700 (PDT) X-Google-Smtp-Source: AK7set9T+2ig3qsNrNdyxppYxFFl/+6Q5tY4q+sharlTs+MYokt4UlUfj0zUM4U7s1rw2b4btItC X-Received: by 2002:a17:906:1950:b0:921:54da:831c with SMTP id b16-20020a170906195000b0092154da831cmr21113223eje.31.1679975600651; Mon, 27 Mar 2023 20:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679975600; cv=none; d=google.com; s=arc-20160816; b=uSFpH0EIBAObDdeae9xmR0RwVIg3x4nO0ye9TsuFxA9I8Xu7Zt7Ount7xKB/QbLqx9 AdQZR/S60ndR5oZ4yzB/glM5dP23NAZtCbc01zKsXmTQnugCsI+PGAdpAEyv5LeeHhhi vuXD/j8vbtazHV5UjLjnHV3Ya2ObKhPfoearW2o3Qy56L41j9dqrOEig8LrhVEFzYOoE 643+qJ0d1nOXDLn4a49LI1OF37kWX2/3roswo1gVE6Z2g63iCHY2H6cUrV54igKoV0YM vrY0FNxHHz86PHrozaXHjVJxzhz8KZjIGP/uYuCR9RvL0VvNhVroVFA49QwUiEC+WRPn HJaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:mail-followup-to:message-id:subject:cc:to:from:date; bh=k8GLYikijt9xl/kSjWBdDoorA0Ltu862yQ+xtOfzAtQ=; b=xt6I+gVmHJYvb28QoD11yjrlpdmeM+Su+P52eTus94RlJ99BoOxuyQmxroBpc1rPrA PnC9lzL0+Ee7QS73FI3h1dtC3XA11ADyRozsgM9JJZiuq65mOdfBr7+JLbcKicqJoWkY 24N0MyQFSRiCisSXYoGWidZdeP0q9kJkl0GQHo3aCv5PGNu0AkOjuvJYpzT9SAf3X0f5 FHeuNRUtBF8y5vNnUIbJYA9uxKQ2QyaTevjH7h5wjGTvjCnzqwzzGlN3lNRwKoGX3UK1 BYuQkLwEAr8G2JxoaxguDvCmDUz9ZliFeNH4ZPFJXfi3R/HEazd6U+Ub94MySlKqEim6 1krg== 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 g22-20020a056402181600b005022535d848si8529268edy.2.2023.03.27.20.52.56; Mon, 27 Mar 2023 20:53:20 -0700 (PDT) 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 S232429AbjC1DrP (ORCPT + 99 others); Mon, 27 Mar 2023 23:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229878AbjC1DrN (ORCPT ); Mon, 27 Mar 2023 23:47:13 -0400 X-Greylist: delayed 122 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 27 Mar 2023 20:47:11 PDT Received: from mx6.didiglobal.com (mx6.didiglobal.com [111.202.70.123]) by lindbergh.monkeyblade.net (Postfix) with SMTP id C0B6F171F for ; Mon, 27 Mar 2023 20:47:11 -0700 (PDT) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx6.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id E13641100D962F; Tue, 28 Mar 2023 11:45:06 +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.2507.21; Tue, 28 Mar 2023 11:45:06 +0800 Date: Tue, 28 Mar 2023 11:44:59 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: Tio Zhang To: , , CC: , , , , , , , , Subject: [PATCH v3] sched: print parent comm in sched_show_task() Message-ID: <20230328034438.GA8421@didi-ThinkCentre-M930t-N000> Mail-Followup-To: pmladek@suse.com, yu.c.chen@intel.com, akpm@linux-foundation.org, juri.lelli@redhat.com, mingo@redhat.com, peterz@infradead.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, zyhtheonly@gmail.com, zwp10758@gmail.com, zyhtheonly@yeah.net MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: 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=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 be better to 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 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index cb2aa2b54c7a..d8fd35684d6c 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,19 @@ 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)); + } else { + pr_info("parent:unknown ppid:\n"); + } 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