Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp961184pxb; Fri, 22 Apr 2022 15:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlv+tv3tTaPW5t1DbVUIeAnxR+o452qg9fmCFZMpfMDseqq3sZkbIvvcfyL4K0NDLCSMQJ X-Received: by 2002:a05:6a00:a85:b0:506:b9e:7f43 with SMTP id b5-20020a056a000a8500b005060b9e7f43mr7135303pfl.5.1650666213981; Fri, 22 Apr 2022 15:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650666213; cv=none; d=google.com; s=arc-20160816; b=qLmCZI6vq8NJOKK3AAnOuBycBLB6WdcFEeatsSFJ1WTCyBBwvsq66CPG/2oFenYEZI r1/1LPxX6y9GKFDfMhUTxmPwpIv89kWzFFYXOzEEYU4vT+KhBcl7HXPOwIPxS7UEY77x QJk/mUscw9zioXBJig7B0RKkZCCdlGxa9x2bO7GC/mFAUH0uWyFUGK7X/Hxn1BGuWtWp KTzNRg9nT/GqTF9lDJEzrxWfr0DmpLbn36VNZqobq6bdnam6hYJogdfn7ijiG5sccT4r dsY3dHzDrbaqnfrmAv3NS477eKhCd8LLXN11QO58QrhHYGwe6aaZU9broyRJVVKTTES2 /T4g== 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:sender:dkim-signature; bh=UGK3iOLOSq8b+uW93AKentNVyqK1drmrSS6mX3tmCK4=; b=hHSbaT5uOBXRTR9EMF3CVQTHwPKxtotBMoIZvFGQrg35XEgo2Alw/EdjRQBkpQ0Qmw bo9mO1NzDSj7kv16OwMuni3vLZa83Z6S2srL9x9W0Qss4b3kIs9YBWAqphoBxL5+TsdU sAMZBE6KItssB+e8yMw1cEBNYh5d7Ge0nqVxJ0X+Yn+EaWdkXOogBawdHad7T6h0hIhL ihvD+T6idqD6IoXyKKPSEVhoz5AEzoE80pU/0bGuhfetSx3uDAuVwKPiwZ6kdPz03t+4 /OQ+dp4hEFMDggB3g7FItPcKhJroAQhG2fT2RCNrnd2iOCHltfpyTIGpVspJgCp1wYBI D2Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jREOmp2t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t185-20020a635fc2000000b00398580600aasi9255630pgb.433.2022.04.22.15.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:23:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=jREOmp2t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C25FC3D1BEE; Fri, 22 Apr 2022 13:29:03 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347575AbiDVQGV (ORCPT + 99 others); Fri, 22 Apr 2022 12:06:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357065AbiDVQGO (ORCPT ); Fri, 22 Apr 2022 12:06:14 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E475E149 for ; Fri, 22 Apr 2022 09:03:20 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id j8so11778036pll.11 for ; Fri, 22 Apr 2022 09:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UGK3iOLOSq8b+uW93AKentNVyqK1drmrSS6mX3tmCK4=; b=jREOmp2tBNoX9/1JSC70rEEUVIFeaV48CD7qYFaDgDafU4SAaf9LhxP1k+Rn6vpleM cskZCEoTYLEONhvD7sDXgIeb2ay/1zuHkkkpPeZNSbjJTGucqwNKlNwqA3EhplbzG7G4 ZRoCWXpI8nSjzPsLjVHRNaL+ul/CBEs/833AqNI7BftoMXQzaXCNU4ereRAdqn5K6AEO CvAsxDdmuZRoKIGuKOonyNOEGdtlIoLyBKZgaXs6SPBR9VyJuo+AOSSuKZi47KF9WFdf 7t6riDyt8vTj76MOUivasvnNMNXEqA2dE0lteUO1dl08saMJWervfiaLvH+0A6JLnbHP UiUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=UGK3iOLOSq8b+uW93AKentNVyqK1drmrSS6mX3tmCK4=; b=cNxj8Mqfq7xRwOmFLdnjuMK4jUpg0ppzDCeCKGjdg1hJidNFEjcw9wR1V4V6uBvX30 w3VgmWeQpaz1zjqMuemkjyxQp9EQT7bdrW/P5zLFvz24mNBgWdzC0uMpILZpS+VE+NWv wfsViJkyZUaZnmLD/C0T1qeNtcmdLNC2Zqaag1yRm+Iftg0phEhdqdrh3KDIWD33Q9G8 PRzDvwXNvsHzT9gc9IJgMXcvgrrRaDABD/4EMok1Ywi/x6vGyLRPEJ3j+jbDvmgGE6nD Rr4I49z5ee+vPZXZYtju3NiqrO8UQ9mXk9LA+lHYCYe/Jm5+DcvMVNCDMrHZebpTW9Vq iV7Q== X-Gm-Message-State: AOAM531IV5zMtv8Ao626kIYEbPUZzKJMIBsYGfOvIw8aK+mfzUAe+QVt 5DuPHjC1SRwW1wrLLz8PBsg= X-Received: by 2002:a17:902:c9d2:b0:15b:e021:8bcc with SMTP id q18-20020a170902c9d200b0015be0218bccmr4149894pld.40.1650643399714; Fri, 22 Apr 2022 09:03:19 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::5:b5ae]) by smtp.gmail.com with ESMTPSA id g17-20020a625211000000b005056a6313a7sm2927881pfb.87.2022.04.22.09.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 09:03:19 -0700 (PDT) Sender: Tejun Heo Date: Fri, 22 Apr 2022 06:03:17 -1000 From: Tejun Heo To: Imran Khan Cc: viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, ebiederm@xmission.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 01/10] kernfs: Remove reference counting for kernfs_open_node. Message-ID: References: <20220410023719.1752460-1-imran.f.khan@oracle.com> <20220410023719.1752460-2-imran.f.khan@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220410023719.1752460-2-imran.f.khan@oracle.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=no 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 Sun, Apr 10, 2022 at 12:37:10PM +1000, Imran Khan wrote: > @@ -768,15 +765,15 @@ void kernfs_drain_open_files(struct kernfs_node *kn) > if (!(kn->flags & (KERNFS_HAS_MMAP | KERNFS_HAS_RELEASE))) > return; > > - spin_lock_irq(&kernfs_open_node_lock); > on = kn->attr.open; > - if (on) > - atomic_inc(&on->refcnt); > - spin_unlock_irq(&kernfs_open_node_lock); > if (!on) > return; > > mutex_lock(&kernfs_open_file_mutex); > + if (!kn->attr.open) { > + mutex_unlock(&kernfs_open_file_mutex); > + return; > + } What if @on got freed and new one got allocated between the lockless check and the locked check? Is there a reason to keep the lockless check at all? > list_for_each_entry(of, &on->files, list) { > struct inode *inode = file_inode(of->file); Thanks. -- tejun