Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4908443rwj; Tue, 20 Dec 2022 17:11:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXsUaaSF/z0c9f/jQAJSn67jhuL8Z43D4GJd43Ts/Nq+hM4V2LSX8Ha9s9gMSH+XSO6LKt7v X-Received: by 2002:a17:906:71c3:b0:7c0:dd80:e95e with SMTP id i3-20020a17090671c300b007c0dd80e95emr3374728ejk.51.1671585064824; Tue, 20 Dec 2022 17:11:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671585064; cv=none; d=google.com; s=arc-20160816; b=lc5axinIMZzVMobXCiNmu7lzPlYzzgcxTDjgNIAnMwY20u3b4dmTQUgrveE8zlqPUj enyrHPj0p9jfRXh40cnL3bn2UGMCOmegYBt0CFbWtlGNpJ/uAgIecujcgX+gBnFb/FSn WulUffXTMhZQFniHuG6RZm7y04t3QJ8J+tI3pvD29ui8QVtkVpBzasC+4p6rK70pgCsw 0VAAN9TvZ3hkP+WRzl3B+qeHkaXeSYftJSoLNG0lYJDS6hGV6Z7jNJbJuGxm801nY1SM Y4cwAjHE5JuoHznzAyRzZSoaocfbeaq0z0QLqqi3n9cmTt/21TvcviUtkY/gXyEnnqfN 1ttg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9xsfdf18BCemJSCFCK2yI7t5Ym88T2oGrG7o0/TfmLQ=; b=mYuga4LMzCElSOVNxpO1ifNUefbj+qVPsC4u/Ak/5ND99p4FzKMw7Ue98WVf5wk3Xe /Qoo/krFXO7zD6Punwm9TZXSZXB6LBEkoYgTjZt57mwHkIiZdaVxmpsJcyhoWVDRGuh7 RPD60PVMKtbjPUtEfzRXD8QU94O3d9M1ZNw+w2JDLAbuc7M35PyvsSIY+5+wyvODx63S e8pNufoVQMGC9UJg+rLFrp95tzKsyVdv1ktemwzCs5tUhrN0FJQoizwpVylqBG+txsLs UoR+eL7P1yp2Mjzs+B0aMSNABfBivp8XaSRAI7Hr6BfJbYUemZk/gs1uce154Q8mQ+nb gFDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XhQPzt5Z; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ww2-20020a170907084200b0078cc8a2cf4bsi3815711ejb.614.2022.12.20.17.10.48; Tue, 20 Dec 2022 17:11:04 -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=@kernel.org header.s=k20201202 header.b=XhQPzt5Z; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234164AbiLUA1h (ORCPT + 69 others); Tue, 20 Dec 2022 19:27:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiLUA1f (ORCPT ); Tue, 20 Dec 2022 19:27:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 995C819282; Tue, 20 Dec 2022 16:27:34 -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 305746162C; Wed, 21 Dec 2022 00:27:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 077B7C433F1; Wed, 21 Dec 2022 00:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671582453; bh=QZMiVBXSoqyLx9N5rvN6rX9ub6C1WA1HR+6Nwve0IgU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XhQPzt5ZLWLgRAoiTtDiQTndEfBXw2Y+uJLrmGyktVaJSIgnc8u5hCwxgQGPeivGG cEthzGEOMxgXeOpXd7xuwRyfvx+JiS6xwh/WWL0+jAxElKHGcAQGLVVG7E+DhjU/xr hghHasgmD4sFPa1B92G7Meee/MsSt/iPle+Za45gDgx78j+n9EZHaIvO+Luq9odISE dqjxNXdJ1T/9U5NUn3LyfRTC6YP4NHe2i3WVqrPAutUuVKIVVK0ufNWkr1BF/5hnd3 zYBwBfDMpiGdWKuDWaovPsx1KwQnFwaSrX9NIN3v25ZHFsjxZSoYPMp7fFBMISOpag R+ODbPF2MW4mA== Date: Wed, 21 Dec 2022 01:27:30 +0100 From: Frederic Weisbecker To: Joel Fernandes Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [RFC 0/2] srcu: Remove pre-flip memory barrier Message-ID: <20221221002730.GA28629@lothringen> References: <6438d903-ab97-48c7-c338-9f0bc2686f94@efficios.com> <7A9876BA-C375-42A7-A5C9-FD940D2898D7@joelfernandes.org> <5bd5ee4a-710a-96bc-abe8-772b2e60f478@efficios.com> <20221220230521.GC26563@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Tue, Dec 20, 2022 at 06:46:10PM -0500, Joel Fernandes wrote: > On Tue, Dec 20, 2022 at 6:05 PM Frederic Weisbecker wrote: > > > > On Tue, Dec 20, 2022 at 07:06:57PM +0000, Joel Fernandes wrote: > > > On Tue, Dec 20, 2022 at 7:01 PM Mathieu Desnoyers > > > wrote: > > > > > > > > On 2022-12-20 13:29, Joel Fernandes wrote: > > > > > > > > > > > > > > I do want to finish my memory barrier studies of SRCU over the holidays since I have been deep in the hole with that already. Back to the post flip memory barrier here since I think now even that might not be needed… > > > > > > > > I strongly suspect the memory barrier after flip is useless for the same > > > > reasons I mentioned explaining why the barrier before the flip is useless. > > > > > > > > However, we need to double-check that we have memory barriers at the > > > > beginning and end of synchronize_srcu, and between load of "unlock" > > > > counters and load of "lock" counters. > > > > > > > > Where is the barrier at the beginning of synchronize_srcu ? > > > > > > I believe we don't need another memory barrier at the beginning of > > > synchronize_srcu() (but this part of my SRCU study is still pending > > > ;)) . The grace period guarantee (read-side critical sections don't > > > span the GP) is already enforced by the memory barrier between > > > scanning for all unlocks, and scanning for all locks (Paired with > > > corresponding memory barriers on the read-side). > > > > > > Accordingly, before we scan all locks and match lock == unlock, there > > > is an smp_mb(). Why is that not sufficient? > > > > That's not enough, you still need a barrier between the updater's pre-GP > > accesses and the scans, so that post-GP read side sees the updater's pre-GP > > accesses: > > > > > > UPDATER READER > > ------- ------ > > WRITE A WRITE srcu_read_lock > > smp_mb() //rcu_seq_snap() smp_mb() > > READ srcu_read_lock //scans READ A > > But see the comments also in srcu_readers_active_idx_check() > > * Needs to be a smp_mb() as the read side may > * contain a read from a variable that is written to before the > * synchronize_srcu() in the write side > > So that appears to be already covered. Or is your point that the scans > are not happening on the same CPU as the pre-GP writer, as scans are > happening from workqueue ? Nah I think you're right. Although I guess we still need the barrier between updater's pre-gp accesses and srcu_unlock scans... > > Perhaps that comment misled me. > > Confused, > > - Joel