Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13235939rwl; Wed, 4 Jan 2023 05:33:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXtEAobIeStUNwHeVVCm4797Le7+VLB5nTHWZubSxu+NO28WGmLxsaHs2A1ZLSO7i9L3geq4 X-Received: by 2002:a17:907:80cb:b0:7c0:deb1:bb8a with SMTP id io11-20020a17090780cb00b007c0deb1bb8amr47892081ejc.28.1672839233456; Wed, 04 Jan 2023 05:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672839233; cv=none; d=google.com; s=arc-20160816; b=wGIu4IOpFgoCLlrG+WoWy/JBgN93Ua5CGofqAircWUwREZAWoJfC3d9+vmDqdO1Svm NaSv4NiDFmz9+Ao5n0QsjtmMjRpe603g7DkzvUeM/ZuiVvn8z92E9tvQoZamuWxIKJpl sIsS8gc1ywp4Z/CI01+SmKKfy+Pr/F6KaStt9aC/vPi+n1gTI8bMs2fEzw0YvBT482Cu 5eKuMSW34BWdDrSwc6oV1Sz2B/C2uuqL4IKh4aqTAsogv7xRp8raajp1pfnpv2i8UB2Q 4D0NJdJTK7s3kwo7/TcavFr6C/Lqg271MQ4Q4yq+B0XcBrWKgF2Hs0O5TWvi6M7222ko vsJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=RyfIJ6gjYshx31FNKwyOcXwR4Zep67IZ6ANu2M3YhZo=; b=0af/JwQv0xDNVq04DE9+ctjOxdz4S9hb0+8TU29itWR2BS/8X3HJ6nDNs/+jeXf1S7 12kgwjRkR8+/TydrjMfbmcR5LeYyS+iTsjakhaganumt2u7eEUlsEMGtlCBbe+Sdy/r8 /8BqJjm8WC7BkMBYbvQf+pxHPB5PqLxoanSjh0j7gLE5U0uG0NyFt6oPNVjsfYcSsR0T hlrY3wyyOFe3SGJjURtvHxQtIX7EACZPfhoWLmtNeS5xM8xCqDWJQ5TVr7CQw00/+9IH OH9/U4chZXOxBYKfgUC1ZtjgoTmGuCPBng6fBXG7fi88OtmWjBM0FER6uCtLdgtAvMDp JjoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=OIv0DI2T; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ae1-20020a17090725c100b00824f19f0717si27923236ejc.650.2023.01.04.05.33.39; Wed, 04 Jan 2023 05:33:53 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=OIv0DI2T; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239381AbjADNan (ORCPT + 57 others); Wed, 4 Jan 2023 08:30:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239363AbjADNaY (ORCPT ); Wed, 4 Jan 2023 08:30:24 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D67234754 for ; Wed, 4 Jan 2023 05:24:15 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C14CE3F4F6; Wed, 4 Jan 2023 13:24:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1672838653; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RyfIJ6gjYshx31FNKwyOcXwR4Zep67IZ6ANu2M3YhZo=; b=OIv0DI2TcJniSkMT5Tymcr5qs+mqxzWJHWsjBON08fDiutJDvSnRaLv6YfjvEYikBJUn4M 4KMgZ4U/kk0a0iy4N2whmVZEhl2BZNnjueBF95Nvb/ImzMaQ3sq6fLLa4Nj/TqrYmw5BGF NNvGZ3sL03vvxd+EggF6fmDDxtHA3QM= Received: from suse.cz (unknown [10.100.208.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 5F0A02C141; Wed, 4 Jan 2023 13:24:13 +0000 (UTC) Date: Wed, 4 Jan 2023 14:24:11 +0100 From: Petr Mladek To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, zyhtheonly@gmail.com, zyhtheonly@yeah.net, zwp10758@gmail.com Subject: Re: [PATCH] sched: print parent comm in sched_show_task() Message-ID: References: <20221227161400.GA7646@didi-ThinkCentre-M930t-N000> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221227161400.GA7646@didi-ThinkCentre-M930t-N000> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 On Wed 2022-12-28 00:14:00, Tio Zhang wrote: > 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. > --- 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; We need to intialized pcomm here: pcomm[0] = '\0'; Otherwise, it would include a garbage when pid_alive(p) returns false below.. > 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", It would print: .... parent:xxx flags:0000 Some people might be confused whether the flags are from the task or from the parent. A solution would be to move the parent value to another line. It would even better solve the situation when the task is not alive and we could not get information about the parent: if (pid_alive(p)) { struct parent = rcu_dereference(p->real_parent); pr_info("parent:%-15.15s ppid:%-6d\n", parent->comm, task_pid_nr(parent)); } > + free, task_pid_nr(p), ppid, pcomm, > read_task_thread_flags(p)); > > print_worker_info(KERN_INFO, p); Best Regards, Petr