Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1846415rwb; Fri, 11 Nov 2022 00:58:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6TNdMFNJcWDPerubZtpy4VrKabfeX5LiGmjHD9KIw4dYBFoj78RSd5APi5jKA4uVNZ5hNe X-Received: by 2002:a17:906:c7c8:b0:78d:e7c0:a2b with SMTP id dc8-20020a170906c7c800b0078de7c00a2bmr1128567ejb.273.1668157082746; Fri, 11 Nov 2022 00:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668157082; cv=none; d=google.com; s=arc-20160816; b=DY+kF2JAelmJG8aFg7fskNHpGiAuZhG3n2+xpwV6488SxIXBrR764Mm/rSp+kXC3gG 9XIyWk2VwTELwIcv8rFbtoUzPdtLkX3/mlLjCdIKMByiaV0NxOgZeJ/zw0FShlz+mcLE iMxtTmt0olsUSsrxgS4DrTUrmOS47gWe46ys4dUf89CnNfpkxzlZyvIkZu9JWdtdmP+Q nXbGQc55pCYFAQGUw7QBf6YsEGoMt6uJfmeWlRqsNaiu509zzL9VpRFjQerirVjirQ0q CJ/1LOGBhjB+o7dfRXZON2b60xa1XxptldgF+WFDS84MYKkJqbwASEirwyxERwiwYA1U KZ2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=Uuj7jDY4tJ1jEEPYATY67pxAeiy+PLbcm/DLBkSh0d8=; b=kK4psSDQ/+wl3BYwr8D4y0XpY0/IMysblm4ZO6TQ/wRVVjvdCr2shSO6m6Tprw8LT1 y5xh0l10L2P4s/k/LDY6Yroj5V46WuomIoYWEfoI8OewXWFOaKnm52Qrie7IvC4KtBTi XkS9mgxc7aeKJ+6DUvVYHIXAHFl4sBv3xjeTSxR6RXhkNWAzfA5OEvr2fkIzHzvnj+Ze M+eStjFxaMVXq8o5R+QGa2SEyFFdCVb/kS9IEoVnRGlTAfFdbfZH+ScQchfawGCqp8F7 LUIvhryUCBxtL0JnDboAg+nx1gtP5nc2/UfmAP2/5YhyDJqPpr8C2PFVYb8yzPLz3YpH 29YA== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a056402521600b00443e3fe60a0si1754194edd.622.2022.11.11.00.57.40; Fri, 11 Nov 2022 00:58:02 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233037AbiKKI1K (ORCPT + 92 others); Fri, 11 Nov 2022 03:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232774AbiKKI1I (ORCPT ); Fri, 11 Nov 2022 03:27:08 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC529F58 for ; Fri, 11 Nov 2022 00:27:05 -0800 (PST) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N7sDc3dqBzJnZw; Fri, 11 Nov 2022 16:24:00 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 16:27:03 +0800 Received: from [10.174.179.24] (10.174.179.24) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 16:27:03 +0800 Subject: Re: [PATCH] kobject: hide illegible sysfs warning of kobject_del() To: Greg Kroah-Hartman References: <20221111065807.3278713-1-liushixin2@huawei.com> CC: "Rafael J. Wysocki" , From: Liu Shixin Message-ID: Date: Fri, 11 Nov 2022 16:27:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.24] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 2022/11/11 14:26, Greg Kroah-Hartman wrote: > On Fri, Nov 11, 2022 at 02:58:07PM +0800, Liu Shixin wrote: >> Some consumers do not care whether kobject_add() succeed or failed such as >> irqdesc. They call kobject_del() all the time even if kobject_add() failed. >> Then kernel will report some illegible sysfs warning like this: >> >> 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 > Why not fix the caller here? Is that somehow not possible? The caller should be freed by kobject_put() if kobject_add() failed. But in fact, the failure does not affect the function of the caller. So the caller do not call kobject_put() Immediately. If want to fix the caller, we can check konj->state_in_sysfs before call kobject_del(). This way has no difference with check kobj->state_in_sysfs in kobject_del(). By the way, I'm not sure how many callers have this problem. So I think it's better to fix in kobject_del(). thanks, > > thanks, > > greg k-h > . >