Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4999606rwj; Tue, 20 Dec 2022 18:47:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDChjA5fuL5UMHhubCkdJRlHd8SrmHsCsRqgT22mxEdmt/yR5jE0Md7W/eafq562YtWiqh X-Received: by 2002:a05:6402:31e4:b0:462:6d7d:ab09 with SMTP id dy4-20020a05640231e400b004626d7dab09mr3695edb.38.1671590869664; Tue, 20 Dec 2022 18:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671590869; cv=none; d=google.com; s=arc-20160816; b=eo8wGRJybYVDrJdnLGG7hwbd9Kgcf0v4zgzyOKD3DKN7Kqp8ZRTb29ET8Cyp6U2GO2 wAfYCubt1IoYdHcWlIUSOFVjXPOLxNDSDnjtci9E7p54y/TLxrTDxXrLGDYOfOEcAtxJ kr6Ls5Uz1GGdzHeQYmEDnGt+riXzIFdBXqIbUovbK1uSG/804nykx0BiV5kF0W4GtTeV LAwyhovyd8YeCerqlHDOtcf9RtTILo5eOFXJnb0YpfZIofperp4Dx+Is1CictxfeFR7N 92cduxJM5FGe8CkaAawvVqWQY4iSaxG4nQjYqLyivwIkvH06F6C63afZ/sLQbRbonfgm kqSw== 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=fMhzqhqWq7UkrwtJ6ZqboyA3KFySyX0rXKAhLHPSdxI=; b=nTEJW+txlW4fO9T5cryMeo48VggwLSQwDnHGcOAsObFHFsXaGfEYKOwWkJtq92SCYz PbwRHnfdn77wH4Rz+boC93n5uiyJeljtTWn+ugMQw0Lz2DlyKLzlxmeTeSGZUWBs45pX G6dv5YiX/MsbgbyoB5MCd2i2GJC66T7fwpNfASE0LIocdXJaYmugi9kZWmhpSI2zngpC H4MXNspKQJ9gBEBXZuS9SvAuS0uQeQCnrK1ZTVTc6kXvR7AGimV62lD6Mczuhy2TQ0w+ i0qvXkDiGL0BLXD5iY3UAZWmAdH36d58EyVBxgCwHFEsioUUn15Y40fh6mpeugc2OUgE bDKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=l3utyhob; 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 x16-20020a05640226d000b0045d189ac612si3861737edd.402.2022.12.20.18.47.33; Tue, 20 Dec 2022 18:47:49 -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=l3utyhob; 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 S234210AbiLUCle (ORCPT + 70 others); Tue, 20 Dec 2022 21:41:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbiLUClb (ORCPT ); Tue, 20 Dec 2022 21:41:31 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB5FD1D0EC for ; Tue, 20 Dec 2022 18:41:30 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id c7so12727188qtw.8 for ; Tue, 20 Dec 2022 18:41:30 -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=fMhzqhqWq7UkrwtJ6ZqboyA3KFySyX0rXKAhLHPSdxI=; b=l3utyhobS6jS5RhkL2EKink3aSp7+2VybDeEXko1NcMcqStPk1+tFzxDNvKrGu8ffd LL8fxBQRBnsoL7MQz7KzDa+HJRuURIRzpjwN1XC9uFMIVcDg1emThrU2NYPk70waUUnH +QGtxyvyvOex0N1E7n/948MavKr8bQU3HUc60= 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=fMhzqhqWq7UkrwtJ6ZqboyA3KFySyX0rXKAhLHPSdxI=; b=sPJCoSvVAeB74YdPDppbiUo+iHQ4uGPd19WSYbVN7Ve/+aWyduLwhAwmm+miYnBVI3 EhMCMNb3KZ9Nu3FlWZccFk1CezqzK1cwdnTUD4hF//hrJ8D1J/SNE7277u8js1mo3O9k Fxyn2tQ3dK6LYe78VHsuvh9mq/dHHOJz2qmFy+ekiTw4M53eVqKdSMmfGRGp/r+ftnC/ 9YJKltXz8FoLASPk2Ykc0aL6mw0SQL97PJVLzMUTSn8ToccbNyXTTmXAdz1tC6nEfSl6 I+ZJzyfNL7YK4uYLJ00ZPFVMW8CYs0wHf2LmyuXjHVXnNX8MJ6UP583zYjngkvinyA1j d6MQ== X-Gm-Message-State: AFqh2krvWfiSywu/KnsZA507BJyLPKZobvTQ4jpvBbD9lEFC2gmNbfi2 hKPDzmNvir3yWbsmc074jN6Bhw== X-Received: by 2002:ac8:735a:0:b0:3a6:2170:b089 with SMTP id q26-20020ac8735a000000b003a62170b089mr6859611qtp.12.1671590489812; Tue, 20 Dec 2022 18:41:29 -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 i17-20020a05620a405100b006fcb77f3bd6sm10471535qko.98.2022.12.20.18.41.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Dec 2022 18:41:28 -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 21:41:17 -0500 Message-Id: <0B1950D8-9319-4F25-B14B-4ED949A57BE0@joelfernandes.org> References: <20221221004957.GA29021@lothringen> Cc: linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt In-Reply-To: <20221221004957.GA29021@lothringen> To: Frederic Weisbecker 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 7:50 PM, Frederic Weisbecker wro= te: >=20 > =EF=BB=BFOn 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_count= . >>=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 READER= 's > turn, but it doesn't protect against the fact that "READ idx then WRITE lo= ck[idx]" > may appear unordered from the update side POV if there is no barrier betwe= en the > scan and the flip. >=20 > If you remove the smp_mb() from the litmus test I sent, things explode. Sure I see what you are saying and it=E2=80=99s a valid point as well. Howev= er why do you need memory barrier D (labeled such in the kernel code) for th= at? You already have a memory barrier A before the lock count is read. That w= ill suffice for the ordering pairing with the addr dependency. In other words, if updater sees readers lock counts, then reader would be ma= king those lock count updates on post-flip inactive index, not the one being= scanned as you wanted, and you will accomplish that just with the mem barri= er A. So D fixes the above issue you are talking about (lock count update), howeve= r that is already fixed by the memory barrier A. But you still need D for th= e issue I mentioned (unlock counts vs flip). That=E2=80=99s just my opinion and let=E2=80=99s discuss more because I cann= ot rule out that I am missing something with this complicated topic ;-) Thanks.=