Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5151854rwj; Tue, 20 Dec 2022 21:38:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLh6MtL6oe8l2aWiruy0eMmas3mY6NH4ljWvhGg97gDoPXH00qws3Czw6sh9TFwsVGlQcf X-Received: by 2002:a17:907:8b89:b0:7c1:6f86:eeb with SMTP id tb9-20020a1709078b8900b007c16f860eebmr310273ejc.7.1671601137046; Tue, 20 Dec 2022 21:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671601137; cv=none; d=google.com; s=arc-20160816; b=PGPwBOO75EYuUGm6ihtJCZSIUskpLzgbSrRYQ6nbHmBAjzDL5zjaVYKdQB8oVP69Xr gFNZdSdv6b5BMl2gfA1pP6JHHYQ5svBhYbZ6s2tjjgACZid5XjwA+J0cyjPUKzFy/3aC EEUdrrK/A8MONEyr65pv50SvNBG9fcOYAkTl8RpergVT3i/OumJxn0sDrjKXxBiadmDL OOZXD/Pl9Zzb674PjN73ngQvScgwkoslu3PU+mtn2Dpzama6UXrva6EHPhmfmlQgSPXu Mp14eIjxlE8Ng2zVSJ4XipAxPVZeybpYlK67b8gBcsR+nPGjmaADirMrbKbo4hTEtraE yQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=TCgpNOZquvWN/9Ttvx6v+EBz7WzNJvsJWIJuT0Mli4o=; b=mV0EK7IrqJ9RemSR9hWjHFkpAjOxDt8aqUnY7Y8BjVbC7PKaKzV7aKupe1qdkyV+Be YNhYfKCx48bU5mFTjFfGcaR6hnCPRK8RpF+YoewRlSDnYexsaRcfTnjO40c8Ke/yTBlH LlF4rgmePUAwJoVaGkLmNsIxMunbRWv+JK4EN8ygWGfSioonuarj19PURd2u/mv9b+aY Ll27MeyhMADhxj4mxCXxT7JqFpGoq0G+yLIMYS9MM3DhnmDGvAPv52Va28ArOlGt/5sP HkmiqMFJv/3tVMhwDHrui4yrRUB/Kfp7NdNq+3XmzS+fJiagd9nC/nhRD9Mn1rJJl5qU mTvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=rsydt148; 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 nc7-20020a1709071c0700b00836ecced351si3459050ejc.380.2022.12.20.21.38.38; Tue, 20 Dec 2022 21:38:57 -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=rsydt148; 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 S234395AbiLUE0a (ORCPT + 69 others); Tue, 20 Dec 2022 23:26:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbiLUE00 (ORCPT ); Tue, 20 Dec 2022 23:26:26 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE2A8F03D for ; Tue, 20 Dec 2022 20:26:24 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id d13so9595281qvj.8 for ; Tue, 20 Dec 2022 20:26:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=TCgpNOZquvWN/9Ttvx6v+EBz7WzNJvsJWIJuT0Mli4o=; b=rsydt1487DQ+I36CTrPO9KN4tP5ytKwJD9mZbgEOkURy38DZoBqVFTo8J7Cr8nll8s huS0jz1y88YJVXoI06pAUoqTPxYiKPJlI1kDGDe6rV14henfbVsolzaxgq3ETm1Ia8tk XO4ugVh72EGwTa+BW87vcpOvfB0lDbb27iUkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TCgpNOZquvWN/9Ttvx6v+EBz7WzNJvsJWIJuT0Mli4o=; b=fqrd7L6F5r/8TNEDwHGNqwEdxu8Z6Ktx9jEhVs9pBWrRRr3sUQLhD5kkSTGXEYS5Bg qft8lXt18FkoDBZt3P4rUU1EP3Apj1cgKtSkTUa12vzk6yi/SB+Z/I6BDC0hHPlWmNCh 0Bwi/YuC48x+8Mo66McQqGqaAnBqp+fNNpqKNYAN0n49gV+5JwE8XUUU6aBn4T3NKvx1 IfDOj1Xyw9BmjyiGngsM0Clfiapgwmn8t9yKcRb3a+v+QWT+PCJGMkjzeViTT38e0qgG 04wkFMcYcWzUacAcCP3ipscEAQE0ZkR9u3Ri5+PdHnsNM5vxyvmGCMy34PqBV5FLbSa2 +R2A== X-Gm-Message-State: AFqh2krxQPfQX6yw+mPHBi4nhdVErdomWmDtHBhM2eblvBPM2/WX9nQN XyOd4dbIALaC7C6OHilYKkBSgH3wBqPyjPOcRPA= X-Received: by 2002:a0c:ed34:0:b0:4d8:42df:19d7 with SMTP id u20-20020a0ced34000000b004d842df19d7mr176862qvq.36.1671596783841; Tue, 20 Dec 2022 20:26:23 -0800 (PST) Received: from smtpclient.apple (c-98-249-43-138.hsd1.va.comcast.net. [98.249.43.138]) by smtp.gmail.com with ESMTPSA id dm36-20020a05620a1d6400b006bbc3724affsm10030526qkb.45.2022.12.20.20.26.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Dec 2022 20:26:23 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Joel Fernandes Mime-Version: 1.0 (1.0) Subject: Re: [RFC 0/2] srcu: Remove pre-flip memory barrier Date: Tue, 20 Dec 2022 23:26:12 -0500 Message-Id: <6BD506EA-77D2-4AC9-87A5-C8781594CF0F@joelfernandes.org> References: Cc: Frederic Weisbecker , linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt In-Reply-To: To: Mathieu Desnoyers X-Mailer: iPhone Mail (20B101) 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 Dec 20, 2022, at 10:43 PM, Mathieu Desnoyers wrote: >=20 > =EF=BB=BFOn 2022-12-20 19:58, Frederic Weisbecker wrote: >>> On Wed, Dec 21, 2022 at 01:49:57AM +0100, Frederic Weisbecker wrote: >>> On Tue, Dec 20, 2022 at 07:15:00PM -0500, Joel Fernandes wrote: >>>> On Tue, Dec 20, 2022 at 5:45 PM Frederic Weisbecker wrote: >>>> Agreed about (1). >>>>=20 >>>>> _ In (2), E pairs with the address-dependency between idx and lock_cou= nt. >>>>=20 >>>> But that is not the only reason. If that was the only reason for (2), >>>> then there is an smp_mb() just before the next-scan post-flip before >>>> the lock counts are read. >>>=20 >>> The post-flip barrier makes sure the new idx is visible on the next READ= ER's >>> turn, but it doesn't protect against the fact that "READ idx then WRITE l= ock[idx]" >>> may appear unordered from the update side POV if there is no barrier bet= ween the >>> scan and the flip. >>>=20 >>> If you remove the smp_mb() from the litmus test I sent, things explode. >> Or rather, look at it the other way, if there is no barrier between the l= ock >> scan and the index flip (E), then the index flip can appear to be written= before the >> lock is read. Which means you may start activating the index before you f= inish >> reading it (at least it appears that way from the readers pont of view). >=20 > Considering that you can have pre-existing readers from arbitrary index ap= pearing anywhere in the grace period (because a reader can fetch the > index and be preempted for an arbitrary amount of time before incrementing= the lock count), the grace period algorithm needs to deal with the fact tha= t a newcoming reader can appear in a given index either before or after the f= lip. >=20 > I don't see how flipping the index before or after loading the unlock/lock= values would break anything (except for unlikely counter overflow situation= s as previously discussed). If you say unlikely, that means it can happen some times which is bad enough= ;-). Maybe you mean impossible. I would not settle for anything less than k= eeping the memory barrier around if it helps unlikely cases, but only D does= help for the theoretical wrapping/overflow issue. E is broken and does not e= ven help the theoretical issue IMO. And both D and E do not affect correctne= ss IMO. Anyway in all likelihood, I will be trying to remove E completely and clarif= y docs on D in the coming weeks. And also try to drop the size of the counte= rs per our discussions Thanks. >=20 > Thanks, >=20 > Mathieu >=20 > --=20 > Mathieu Desnoyers > EfficiOS Inc. > https://www.efficios.com >=20