Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4921036rwj; Tue, 20 Dec 2022 17:23:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtWyZQBALh/71GCT55M/Q9+5swh0BCFZBHHvNx8LhEb2Ko9LHWTe0KNdW0D8igJPUfUyyJt X-Received: by 2002:a17:902:dac2:b0:188:bf3b:4c28 with SMTP id q2-20020a170902dac200b00188bf3b4c28mr228468plx.18.1671585806352; Tue, 20 Dec 2022 17:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671585806; cv=none; d=google.com; s=arc-20160816; b=wXXX238YbGk87QfiQRSgfAUArzpPUi4d1/OsBgL/2V2cAI4aYu+75CJ2vBKcIyhcUv 3ssKweRLUbJZ8j3/A1K6nrDyfgEmhFNHYXa8AYi9k/NavcGze48CKoGdjvHqjAZgtOVQ 9LbTgstkqtKrK5ey1jSX2MNssySqp5vDsPW/igEOWjfdD3cy2fW98fKAeezYed+m7whe MRsL5TCWK0s5sWt8/ucvvWmIm5v4QtzxQOoY+ViQIu0j4RrUYCfmOqAI6Jj24L7tQ43m qhz8AUrn7xHsdynoMSZlEFYFGL4MgnW/RqesuI9EaEOv5aatmTzveR4GtI6yy24O1i9y BfWQ== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=PC4cqyqRTruV+1xOsA2kyXFd+uuK4nxa+q12dbQ5emY=; b=i1OXbYQFIc4UuCKphnCdB0VNbGGOmv3Jpr/StCIx0uYIhRN3Kx+bRJZtzhQaP3WpJM 5S/sRTtGug2kP/rT5uBnntcpZWJZgaZhiDGdfT81OH+h39+1vNUIIK8H47ffQgXiqa9/ SUIFmuiVVRZAk0BFA5FPX6LKrlNUfr7gQibDijle+W00oir9LS2Hgd31YdbdCm5cIsWL cHNwvQ8q522AB3UTTaMbqojymPfLwmWhAMGC2+QMG7UHqBiPbyQ1Eq/deCp/9CUy1yO9 FsSQ5CY6ufkAp51fbqtbSk+s03nQ+3jCUuKf8fw7AIApYKzmMbl6vaVObQeJI3CsqQeN UwOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AaA8qaOS; 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 t10-20020a170902a5ca00b0019111dd056asi9999153plq.338.2022.12.20.17.23.15; Tue, 20 Dec 2022 17:23:26 -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=AaA8qaOS; 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 S234376AbiLUA7G (ORCPT + 69 others); Tue, 20 Dec 2022 19:59:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbiLUA7F (ORCPT ); Tue, 20 Dec 2022 19:59:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C4189FC6; Tue, 20 Dec 2022 16:59:03 -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 ams.source.kernel.org (Postfix) with ESMTPS id 48E9EB81ADB; Wed, 21 Dec 2022 00:59:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EF67C433EF; Wed, 21 Dec 2022 00:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671584340; bh=Jjg3RuhlIBepTZq0rBQOcgcpTBE7WewrQRtghSQ2uL8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AaA8qaOSDsMfK2V9fqLnfIRZ28z+cut/Qwn0MRRmmlo0s8vtSVfVtPZB/63WNmDzF YUv7whEYRqqDPymuCacyBNWj3dG2CQSFWat5TLO6HNopSAgzjjDY/jyFlhwBBBgkPZ XcKecfEebzJQ54Sh0kbKkUkpYjrHuyMrOIgMeoKzIYRCWQxuMDApSKlXqWlPx8tu3Y 2xSHxU5A8epYj6ZdRftFf5JhLqZ8EzfKY28lD8ebtj97WZGP8JwdIiPSIr+DhBnFAM uTC0NclOXLxFU664aC5M3czn4xlnCkmU4mrHd9bG3I6JEBWbnBgYIQKvjX/8h+UdPL D3HyTNzEdPgTA== Date: Wed, 21 Dec 2022 01:58:58 +0100 From: Frederic Weisbecker To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Subject: Re: [RFC 0/2] srcu: Remove pre-flip memory barrier Message-ID: <20221221005858.GA29316@lothringen> References: <20221220140714.GB22763@lothringen> <20221220224459.GA25175@lothringen> <20221221004957.GA29021@lothringen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221221004957.GA29021@lothringen> 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 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). > > > > > _ In (2), E pairs with the address-dependency between idx and lock_count. > > > > 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. > > 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 lock[idx]" > may appear unordered from the update side POV if there is no barrier between the > scan and the flip. > > 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 lock 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 finish reading it (at least it appears that way from the readers pont of view).