From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C27BC46467 for ; Wed, 4 Jan 2023 13:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239311AbjADNk6 (ORCPT ); Wed, 4 Jan 2023 08:40:58 -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: 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