Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3253916rwb; Sat, 12 Nov 2022 02:05:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf4uhvhI1/1zPPu5s4+COkiuwxVkyjf9m/bryzZzFyauvLwvN0Ys05VDj9QBfTsxMy+pmzH+ X-Received: by 2002:a05:6402:c09:b0:462:6b8e:1ddb with SMTP id co9-20020a0564020c0900b004626b8e1ddbmr4733706edb.276.1668247529180; Sat, 12 Nov 2022 02:05:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668247529; cv=none; d=google.com; s=arc-20160816; b=hbM9YNEZMbL7D23B4pParAW6d1uyObN8m6jN1h/rxPwuD6JqS9plAwdSBFWqsOsO6w t8Zhq8Bi8+7ezytRfEDYon+kTBAvdSvlrzYL332ypR3KT00rjcZAG0JVJ58nZknRxWKE mQF4cGy1YC7c/bPpU5cpv5PovBMQWOiJ4LxPv5qhJzV6zgxbG4sVhj4MNvpYRnCI2dWz 9vTocU7fixK2J+Em3GyNub4PBlZq0a7jL4fwRTA28NCeKAdcFD78eZYgzS9zLRvMf2/5 QMZACz7+MCeQM94sMIjd1YsqQvPKeRTsDqI7tCXw6Fh1QUGcEFrtp1yRaeysVRTXY6+z Jd7A== 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:cc:to:from:date:dkim-signature; bh=U8TmTQexTdUCjTDFiD4o7ZFZBHz3NqegEtV9EqxRaxY=; b=w/XI2C+9TyGe6U2M0V1nchqU6jvVtlbQYy82OAIRcydxN8CoHmdTsszwOm+ttXXhl9 n9/8ItnNCvwhpWQa0+a4M4PzSfvPCbPun0mvFx3KMzQ+Q8neVI5RTd34mvZfcxjjuE5P adWyTpwarYEuWA880f62ndusQm7wcfKuj6LDhg+StmEdqROr9kFicghb35wYfV44LCm0 LJw4E6yX+cKr+YmAmGSbhQClrPkoJ4JfkFuQc6xq8i8qTz19dwa+8G9hqQJwOXuDnUUq bNFneIDjxiIHKTx/0zTRHCR6ivbP6zJEl6QH9kviJMlHD7aaZaaotd+WZViNeePM4Q4g oVew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=swyT4o2z; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa22-20020a1709076d1600b0078d99e20b68si4482181ejc.715.2022.11.12.02.05.06; Sat, 12 Nov 2022 02:05:29 -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=@linuxfoundation.org header.s=korg header.b=swyT4o2z; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234787AbiKLJeX (ORCPT + 90 others); Sat, 12 Nov 2022 04:34:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234683AbiKLJeV (ORCPT ); Sat, 12 Nov 2022 04:34:21 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F6E140D8 for ; Sat, 12 Nov 2022 01:34:20 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A85A4609EB for ; Sat, 12 Nov 2022 09:34:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88390C433D6; Sat, 12 Nov 2022 09:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1668245659; bh=65exbud4oDHB8q1YGgMYLfLKD5iC+Ky9YXJn0Mhqr04=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=swyT4o2zFxp9yX7LQ6kGrOCZEhw690k8I8hvkpIUK94p8JaN0qKiAs5xlcBxOa0br ju4+bhRxTv4TabkqGzCA9mCCi22DUaG84JOq4l9tw9ElPfGE1qGKlS7OvyPI02jlgr 2ygXrK24Zn2y4YFJnu8yWDbi8fVSwgm8fou1U9us= Date: Sat, 12 Nov 2022 10:34:16 +0100 From: Greg Kroah-Hartman To: Liu Shixin Cc: Thomas Gleixner , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH] genirq/irqdesc: hide illegible sysfs warning of kobject_del() Message-ID: References: <20221112093939.616270-1-liushixin2@huawei.com> <137bd5cc-0be9-6228-82e2-a75b53e5a2ae@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <137bd5cc-0be9-6228-82e2-a75b53e5a2ae@huawei.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Sat, Nov 12, 2022 at 05:19:50PM +0800, Liu Shixin wrote: > > > On 2022/11/12 16:59, Greg Kroah-Hartman wrote: > > On Sat, Nov 12, 2022 at 05:39:39PM +0800, Liu Shixin wrote: > >> If irq_sysfs_add() failed, system will report a warning but don't call > >> kobject_put() to release the descriptor. > > I can not parse this sentance :( > irq_sysfs_add() call kobject_add(). If kobject_add() failed, will print "Failed to add kobject for irq". > But not call kobject_put(). Then fix that. > >> Then in irq_sysfs_del(), we continue to call kobject_del(). In such > >> situation, kobject_del() will complains about a object with no parent > >> like this: > > Then we should not be calling irq_sysfs_del() if the call failed. That > > is the real fix here. > If so, should I add a variable to record whether kobject has alreadly added or not? The code itself knows what just failed, handle the error case there properly. > >> kernfs: can not remove 'actions', no directory > >> WARNING: CPU: 0 PID: 277 at fs/kernfs/dir.c:1615 kernfs_remove_by_name_ns+0xd5/0xe0 > >> [...] > >> Call Trace: > >> > >> remove_files.isra.0+0x3f/0xb0 > >> sysfs_remove_group+0x68/0xe0 > >> sysfs_remove_groups+0x41/0x70 > >> __kobject_del+0x45/0xc0 > >> kobject_del+0x2a/0x40 > >> free_desc+0x44/0x70 > >> irq_free_descs+0x5d/0x90 > >> [...] > >> > >> Use kobj->state_in_sysfs to check whether kobject is added succeed. And > >> if not, we should not call kobject_del(). > > That does not describe what you are doing here at all. > Sorry, I forget to update... > > > >> Signed-off-by: Liu Shixin > >> --- > >> kernel/irq/irqdesc.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c > >> index a91f9001103c..a820d96210d4 100644 > >> --- a/kernel/irq/irqdesc.c > >> +++ b/kernel/irq/irqdesc.c > >> @@ -300,10 +300,11 @@ static void irq_sysfs_del(struct irq_desc *desc) > >> /* > >> * If irq_sysfs_init() has not yet been invoked (early boot), then > >> * irq_kobj_base is NULL and the descriptor was never added. > >> + * And the descriptor may be added failed. > >> * kobject_del() complains about a object with no parent, so make > >> * it conditional. > >> */ > >> - if (irq_kobj_base) > >> + if (irq_kobj_base && desc->kobj.parent) > > How would the parent be NULL? Parent devices always stick around until > > the child is removed, otherwise something is really wrong here. You > > should never have to look at the parent. > irq_sysfs_add() call kobject_add(). If kobject_add() failed, the parent will be NULL. > You can find the same check of kobj->parent in cpuid_cpu_offline(). And it is wrong there as well. Do not copy bad patterns please. thanks, greg k-h