Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1772364rwd; Thu, 1 Jun 2023 23:05:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5lzlV4MzLfpD8IGzKbTnSXG1Y/JBJNc3cgrXzmbSl2yDZQs880GlLDE3CZoCLG/tsMkhPA X-Received: by 2002:a17:903:124d:b0:1ae:8892:7d27 with SMTP id u13-20020a170903124d00b001ae88927d27mr1580922plh.42.1685685916618; Thu, 01 Jun 2023 23:05:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685685916; cv=none; d=google.com; s=arc-20160816; b=W2pNKd/j7X1svSDlK99G9hcHjZ/LYNGAAOA2y08a4L29tCeh2Rzz59IuH4Ru1z6rll OvmAGzlbhWA99pJgQxct0Yn9VaBq5q91/ShZgDY5w/U64/T7AIZ5QXKga96xl83rbVTz SSkK5PLn8JCFM5OSS0bQyQpoeWLbHLcskbwFjCi1hcyk2Y4/rjl0hBVmgp4wysYIn/3w EFax8T+vuxvZiCLbuGcBxSu5ihSjcv7+lntwQsLo6mnnClNyMEKap1UYSb5n8QfNxpmD cH6nk6ZQotlogMJJMCClDOtd/mx24v2nKunk+qMFM+DNjb3vCoVrrMOw5tdEY3fu9akd zXqw== 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=Fe0LYyAmyzoDZVG4xkAnLflaSsVx35fArRcYkcc9reQ=; b=yxqd/8CTWESYhS6fk84ZO11mKDs3Hyr67NJfj2ya2FiFy94OfV0L0hxSrxROVz6O9l eVvJDq70yL50ADfiaLC+dI5JgGiVfew/shqnk2btvSXiloiUm87ZOvb6PQwLGyxxOsLz MaUhMAZVwxTx2wK1FOJlKhnEA9ZH+qRFDgJll2yNC/ScHePSeKxuLJ/HyhgTMtbocjj+ oZvbkcfT802C0UZMpPqdC+eQK2CzccJfaN7qcNGl5cMBRbBOvcKSUWJV8pds8fG5EhgJ fShrWKtkHE9IHND/nq+Th9nSBKOCvxsNOMCMfAZLA+tEhFWCktVg8e3pkdwnWS54bf7V ftGA== 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 la11-20020a170902fa0b00b001a65688c863si410165plb.56.2023.06.01.23.04.59; Thu, 01 Jun 2023 23:05:16 -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 S233276AbjFBFq3 (ORCPT + 99 others); Fri, 2 Jun 2023 01:46:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbjFBFq0 (ORCPT ); Fri, 2 Jun 2023 01:46:26 -0400 X-Greylist: delayed 123 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 01 Jun 2023 22:46:20 PDT Received: from mx6.didiglobal.com (mx6.didiglobal.com [111.202.70.123]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8C4A4197 for ; Thu, 1 Jun 2023 22:46:19 -0700 (PDT) Received: from mail.didiglobal.com (unknown [10.79.65.12]) by mx6.didiglobal.com (Maildata Gateway V2.8) with ESMTPS id C8862110020826; Fri, 2 Jun 2023 13:44:14 +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; Fri, 2 Jun 2023 13:44:14 +0800 Date: Fri, 2 Jun 2023 13:44:04 +0800 X-MD-Sfrom: tiozhang@didiglobal.com X-MD-SrcIP: 10.79.65.12 From: Tio Zhang To: , , CC: , , , , , , , , Subject: [PATCH v3 2/2] sched: print parent comm in sched_show_task() Message-ID: <20230602054404.GA30014@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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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\n", 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