Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4846241rwj; Tue, 20 Dec 2022 16:08:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5rQUOMfMaAJag9L3uk8fUU4XjcW/Jw4RP7qE4ZomXha8QJTJpRw7iosLo2xgGMuhlKpehb X-Received: by 2002:a17:90a:420f:b0:219:4793:2979 with SMTP id o15-20020a17090a420f00b0021947932979mr50049910pjg.22.1671581309345; Tue, 20 Dec 2022 16:08:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671581309; cv=none; d=google.com; s=arc-20160816; b=VzK7QV5lbPI8dqRHbMCOyOZ+8RYIqGa+mEKcMeqr4UPpFmta3xWX6ms3FKNGKK8/Nb oVhx7LPCY8hPmGAti3s9JASL5o60h+j3VOqcGk/5bjEIFsCJcc2RSaG03LHaOhuErMub KZulG1inDMqxRFcsglSryaZt/CWDcOYS6boGhUQ+moo9aD085gileIFzLd9ZANOcnL5y EeikVdfuXKQjbj16oqGH/pv5DhgeWBSrPHxn+EYiGLXgYacY/oNKgjlqSdHWBzPROsoG t/1gceoM6HUl187C8qZKpAybUCpO4xpb0/GXIQCIoUAYypLp4W/5/DV68zcCBVSPhXu/ TRhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GtML0qwGaitUp0TiRy+O4yYYdbB8tFyIG4fs8NuVCa8=; b=bgsi4SpGGDDDlBb45sSONI4/riIHevRsx8+RNtACuOYZQrFIGe2Kjg7xfvzFcCyZxJ jNqb2KNJDiE1io9lzGeaArKEea0xynXEKj7cZ+nkUjSCTjs76dbu419dVuncFQkaNOD2 Gz0cHJnvVKAPX4p9DS1lSMLLNOMkgfBOLWf3dm7EDdwBzYOr6oUeoLsSIPXpgYoZ8Laj s5BWdUAt1GlRsNqmnhmmeSI9SvsjIqclIT5VN+V9/ElaR7Hsbdzc8BP/f3d/kEYmBCKD lcJsuhomUkq8m9xJHu76syNsAuTJzax3A4Rp7megtfCaAT5yOnErQcQAhV5McxVKePbe soJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=YvSlxYAt; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rj9-20020a17090b3e8900b0020af2b9dd80si324070pjb.69.2022.12.20.16.08.20; Tue, 20 Dec 2022 16:08: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=@joelfernandes.org header.s=google header.b=YvSlxYAt; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234128AbiLTXq0 (ORCPT + 68 others); Tue, 20 Dec 2022 18:46:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbiLTXqY (ORCPT ); Tue, 20 Dec 2022 18:46:24 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C089B388F for ; Tue, 20 Dec 2022 15:46:23 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id f34so5807183lfv.10 for ; Tue, 20 Dec 2022 15:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GtML0qwGaitUp0TiRy+O4yYYdbB8tFyIG4fs8NuVCa8=; b=YvSlxYAty7ptj+47fW722mslnmYbmOMcphE/kwVArTgkcoYN9XNKCGTWjElFJPT/Et AHJmRI/6bxx9qArXwUviHg0KBXnmdQziNra7RV4bCV0LfgZmmhELJHbb1YzTWFIUwHin 8NEEy3MfYmAKKeNtERKqDBNLwPyT7iYPD1TvU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GtML0qwGaitUp0TiRy+O4yYYdbB8tFyIG4fs8NuVCa8=; b=KBSPqCqDuaG4X9gz4whZMUPPJ116hEWYP4gsGm2yDdsYfaymgxFRrcVQ6tBLBj2UuS kz+qYm9/O1zl+aKSDrJLtFuDG49P1BdnSsuPtZm9p7Pk8VITEC4Ea/Xe3bZkaSSDKQo8 F387Jq6lSwGN5fFU0O6JZukY1s4Ck3aL8Gp/2iNdP2eXyePsjE9LnphlLXaUT2zmI8zM 3PeKdt6/YCshKpRp+yJ6D910nK3bMkADC25Da9XMKpcitRpixuEdbgPXFnTrvnBj4ygv wr3K+Z03VcGTjGauPP4ir/qPapqK7wiD4S9ZtWSsH0hznsaB2+bMoRSmrI9hZhTmtRd1 9DYw== X-Gm-Message-State: ANoB5pm2IX/t1u25c3YRP3tqy2LrCxw+PZXxziBgQIYG5XtNj+z3By4v gPYJC+JewdHKBYTG+jIVFpE5ozDhYI0M/Z+G1kPZ7g== X-Received: by 2002:ac2:4347:0:b0:4a4:782a:42ac with SMTP id o7-20020ac24347000000b004a4782a42acmr31901376lfl.468.1671579982033; Tue, 20 Dec 2022 15:46:22 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20221220230521.GC26563@lothringen> From: Joel Fernandes Date: Tue, 20 Dec 2022 18:46:10 -0500 Message-ID: Subject: Re: [RFC 0/2] srcu: Remove pre-flip memory barrier To: Frederic Weisbecker Cc: Mathieu Desnoyers , linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 6:05 PM Frederic Weisbecker w= rote: > > 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 holi= days 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= =E2=80=A6 > > > > > > I strongly suspect the memory barrier after flip is useless for the s= ame > > > reasons I mentioned explaining why the barrier before the flip is use= less. > > > > > > 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 =3D=3D unlock, the= re > > 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 ? Perhaps that comment misled me. Confused, - Joel