Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13304954rwl; Wed, 4 Jan 2023 06:27:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwrh9tXPojwqyw/tltghdjs0Hrfc+Nw2nDi3m3BAGVJco2XupXTyNy7fYXk96FmcObNTco X-Received: by 2002:a17:907:d08d:b0:7aa:76a:fb3 with SMTP id vc13-20020a170907d08d00b007aa076a0fb3mr46036484ejc.66.1672842421053; Wed, 04 Jan 2023 06:27:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672842421; cv=none; d=google.com; s=arc-20160816; b=PyaA1mbC0iHrIRQgitCDcleQhYScA/kFyxDugd2OxFWIfAb6mV9Bv04HPcekKCYsgk kOwQrwANY+5Esm3igIfEcAKZyPQt6gMyDFDNCqf/gxaRFqdZjECofa7NF1KarI2nt7ZC s3Sc5h7DiNZd1alGwm+i3o7lEWFxievAXJNPOoQu0GM8i8KGIqSCV5GD6VWWwckEZn9M 1bFvIGQIub5wyyKWz57LjTnoia0ZpA/IKpyEl3OwjP/2eOV0fcS+Lqfeh8TKQeagFmwD 7NE9gBlfkJgbuddKPbN4LoFvrCCVkFYs+xT0YI5ZZRuJazIsrzzMdZdVyqPcohNIi4sG aY3Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=a05lvaNmtUMU+F8+Adl3Kvy4FXL1d+7IfQjFWRQ1ulg=; b=sphVy+9s7MSh503N6TQg4OEB7wq9AC+68GKhIPxQMbgD5zk+71lzikj26MoatPC0a+ URiYK4Je/ZkyEKVRTCJ06WSkfa8gecpbBK9nY26A9iQfLqaHqIQTRCyJvf7Y0/rEmsID vKDJ7cHuiP4q9JLPulHTGsV7hi5KGvDD3hK2K5I6RdafC1vmYs+dcY/b7ldltHCYP6Sz KajdWxJdeioySAZyW1LPHsPFfH6kdosYWXvIhhun1R/7M8Za7umJBsAqdrPW5xiIUQ2I 8U6cJN2YMLx9LA85iZ+u0iDxlCSju87YZtQxlNsBupW3Bwzg3h33ECWEbn0QJIPkiLXR zznQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=lALfakv0; 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 gt9-20020a1709072d8900b007aecd8912ecsi32656152ejc.21.2023.01.04.06.26.47; Wed, 04 Jan 2023 06:27:01 -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=lALfakv0; 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 S234676AbjADNk5 (ORCPT + 57 others); Wed, 4 Jan 2023 08:40:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234103AbjADNky (ORCPT ); Wed, 4 Jan 2023 08:40:54 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71AE238A7 for ; Wed, 4 Jan 2023 05:40:53 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0867C3F068; Wed, 4 Jan 2023 13:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1672839652; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a05lvaNmtUMU+F8+Adl3Kvy4FXL1d+7IfQjFWRQ1ulg=; b=lALfakv0KQ6G0zuzJKNDNew4Q9KqAkf2JgFlpyZT8YGG/cV//wVHIslY3AuZHBkm97ODvy anx2tqWhE5GPZnbkK48sCbZWTpaFhmgO70oO+leYu7YLr5PcSedAG2ZvNwZRyJYLA///Ry mTwJ95lSD7RkqXpEXGYCbJO9z625kMY= 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 D99732C141; Wed, 4 Jan 2023 13:40:51 +0000 (UTC) Date: Wed, 4 Jan 2023 14:40:49 +0100 From: Petr Mladek To: =?utf-8?B?5byg5YWD54Ca?= Cc: Chen Yu , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 2023-01-04 01:51:30, 张元瀚 wrote: > Hi Chen, > Thanks for your advice! > > > Maybe struct task_struct *parent = rcu_dereference(p->real_parent); > > and use parent directly to get its pid and comm? > > Yes! It is good to write this way. > > > Maybe off-topic, what if the parent is a kernel thread/worker? It might > have extra > > name information such as kthread->full_name or worker->desc according to > proc_task_name(). > > I'm not quite sure if it is necessary to fetch that extra information since > our sched_show_task() prints p->comm ourselves. > But, assuming we get the parent's name in the same way we get > proc_task_name(), there are some new issues I'd like to discuss. I suggest to keep it simple and just print "parent->comm". Especially, we should avoid taking any lock. shed_show_task() might be called when there already is a deadlock on the system. I guess that it even can be called from NMI. For example, see print_worker_info(). It uses copy_from_kernel_nofault() to be safe without taking any lock. Best Regards, Petr