Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1508416rdh; Fri, 24 Nov 2023 14:59:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKW7GPsBvg+p5CGgsWhvEvqY005TN/93cin6R+6/zZIRmm0BgkTLq8jZAAetMIQn0uMDsc X-Received: by 2002:a0c:e90e:0:b0:66d:a301:e512 with SMTP id a14-20020a0ce90e000000b0066da301e512mr5698417qvo.27.1700866757352; Fri, 24 Nov 2023 14:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700866757; cv=none; d=google.com; s=arc-20160816; b=blFdBA7kp32EnFPmje7FNuB8A3Oqm4aI7dx7pMedARokl7GME8ZsFlfqDo3YHCbXYK bk3Oy5UnGlJSnzWJa65Zow4K80SDKZDSD8Bdhe9V/+hPCIY+D77xH1BQRXS4qDNG5Qmb Hg/1ovHWAyEmPBrh8FcPINJQlO0ti0ozyacmWC/gHCWd8VBukIVosVXFYb+n3xSUdPjx eoEu9XeF0uL4dTHi7m3U0knyu0H5L2Ymk4+AIzT8Aa+9gio7t+PSRa0XpgGO/UoIQLM5 Orp59FArFjT0X574J4zi++IL5dYMgnSFTpl0BINk/TdYlMpDZGxa9q/w6HnPbb3Kv4D5 BL8g== 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:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=fsUNRKviPRi/2bpG4HXRC3xEfsQXq6df6kV0Ym7LQ30=; fh=9YwDLOkAFhgnK2ZiFSq6Kc/n9deZO369Egh1K2BpiQw=; b=B6MRWKkL7rFjEJUrLiCxK/VRybh2UePZWJTlG3UKmdlouas5vErzWfd1IN+MYwLLKL OQ+bOj+a3M7tCar+X+X6iRPRMRo65jxmxMnTzaHCnWWFMUqDZfS/OuuKGgFnZavCDRKR 440OWJqZMYlVQbnwWk3pKKRPdhoSuLIqHVpuJCZEjRKhCsHNoIpZBvnmGAISBRrkLd+F EsU54s826CD/pA653PpOaqQ+IRPnnZeP2EvL1iFMZqcCKxmI35LO5OHFJpeQuh+MPktD GxI0xBb2kxuEo07f+nKe29E5rtjTgeqV6/Mai2mK2YOZd3FRDQH64wCGgH+SiMe0ua7D YP+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="etw+B/63"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id v9-20020a05620a090900b007759a519e0dsi3901764qkv.73.2023.11.24.14.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 14:59:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="etw+B/63"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8BA728261037; Fri, 24 Nov 2023 14:59:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbjKXW6v (ORCPT + 99 others); Fri, 24 Nov 2023 17:58:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjKXW6t (ORCPT ); Fri, 24 Nov 2023 17:58:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13E07170B for ; Fri, 24 Nov 2023 14:58:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A37F8C433C7; Fri, 24 Nov 2023 22:58:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700866735; bh=6JB2cmvFWNvbLTHf+R4y9qgwUrffC1tyRDmPTqkNXIE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=etw+B/63RkQEOkN3ww9VTmsbXl6RL95UORtpGz/pklCS7bf/iLZqu75A0Ewn1upqz I+9WQvDm1ZFVTW8LkTrncxRiX5PF7lwuFg0r+fACh8XBtmq/GGQUHLZWcEeiq1aSSw 10b/ANLJRbKEGKdnpMvz7vdDwTJ4VKM5dvomB9HLVNRLokrjMlTLg95IK0151ezd6V IMSPDzxJ1kW0T03QuTDNwTGDuzvf11x0wL8CQYm8MMwuDVsB09MnjoOFbm2yJoLJcn CPihLZOGYphImXMPIG9PWPMOjVeuPOnNpd32hbeita/ejg1hnLOcV6MfGJnUFPJqLh yR9OeJJltquyA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 33C03CE0BDB; Fri, 24 Nov 2023 14:58:55 -0800 (PST) Date: Fri, 24 Nov 2023 14:58:55 -0800 From: "Paul E. McKenney" To: Linus Torvalds Cc: Al Viro , linux-fsdevel@vger.kernel.org, Christian Brauner , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 02/21] coda_flag_children(): cope with dentries turning negative Message-ID: <6435833a-bdcb-4114-b29d-28b7f436d47d@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20231124060200.GR38156@ZenIV> <20231124060422.576198-1-viro@zeniv.linux.org.uk> <20231124060422.576198-2-viro@zeniv.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 24 Nov 2023 14:59:14 -0800 (PST) On Fri, Nov 24, 2023 at 01:22:19PM -0800, Linus Torvalds wrote: > On Thu, 23 Nov 2023 at 22:04, Al Viro wrote: > > > > ->d_lock on parent does not stabilize ->d_inode of child. > > We don't do much with that inode in there, but we need > > at least to avoid struct inode getting freed under us... > > Gaah. We've gone back and forth on this. Being non-preemptible is > already equivalent to rcu read locking. > > >From Documentation/RCU/rcu_dereference.rst: > > With the new consolidated > RCU flavors, an RCU read-side critical section is entered > using rcu_read_lock(), anything that disables bottom halves, > anything that disables interrupts, or anything that disables > preemption. > > so I actually think the coda code is already mostly fine, because that > parent spin_lock may not stabilize d_child per se, but it *does* imply > a RCU read lock. > > So I think you should drop the rcu_read_lock/rcu_read_unlock from that patch. > > But that > > struct inode *inode = d_inode_rcu(de); > > conversion is required to get a stable inode pointer. > > So half of this patch is unnecessary. > > Adding Paul to the cc just to verify that the docs are up-to-date and > that we're still good here. > > Because we've gone back-and-forth on the "spinlocks are an implied RCU > read-side critical section" a couple of times. Yes, spinlocks are implied RCU read-side critical sections. Even in -rt, where non-raw spinlocks are preemptible, courtesy of this: static __always_inline void __rt_spin_lock(spinlock_t *lock) { rtlock_might_resched(); rtlock_lock(&lock->lock); rcu_read_lock(); migrate_disable(); } So given -rt's preemptible spinlocks still being RCU readers, I need to explicitly call this out in the documentation. How about as shown below for a start? Thanx, Paul ------------------------------------------------------------------------ diff --git a/Documentation/RCU/rcu_dereference.rst b/Documentation/RCU/rcu_dereference.rst index 659d5913784d..2524dcdadde2 100644 --- a/Documentation/RCU/rcu_dereference.rst +++ b/Documentation/RCU/rcu_dereference.rst @@ -408,7 +408,10 @@ member of the rcu_dereference() to use in various situations: RCU flavors, an RCU read-side critical section is entered using rcu_read_lock(), anything that disables bottom halves, anything that disables interrupts, or anything that disables - preemption. + preemption. Please note that spinlock critical sections + are also implied RCU read-side critical sections, even when + they are preemptible, as they are in kernels built with + CONFIG_PREEMPT_RT=y. 2. If the access might be within an RCU read-side critical section on the one hand, or protected by (say) my_lock on the other,