Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp3506414rwj; Mon, 19 Dec 2022 20:24:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXupbLFEXneojYFGLSoJYgDDBIsMMNvf1DuzI/x5nWYgFMT13NyAAOvX8if2Tjlj+PFwXWgV X-Received: by 2002:a05:6a21:78a2:b0:af:e893:fa52 with SMTP id bf34-20020a056a2178a200b000afe893fa52mr20317226pzc.22.1671510257287; Mon, 19 Dec 2022 20:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671510257; cv=none; d=google.com; s=arc-20160816; b=n5lRzr8jSSBWbU2fVlG7oJxN/iTXiG+S6fBuF/nmNhhRNHnp4FiugjyGJ0BhVY7lDM HQuVKhmVwVUhT6L9KuksGOWGwxTA+xRVJ8gYNXt9k3HlNUCWTgRZ+HWtNlGlSgeAjSq6 AEd8PgIPnbHHvbzSYEQpgeI5JOaewaihgo8OAfZPHcNbs77PkfQTLf5BK5Ia+gRISlC+ qg00mENRnouREDGNPYggRg6fzZivlrUGU8Fs0RDcqxCn+CVD+XBj/zyKevlPlqSBoyWH CLLCQV76O52ODPWnz1V1z7AE8O0oTX3MonGXJcObSqLLZUbyFoGrdWRvac3E4bnS6RMI z8Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=qDu+2HB9LCelBr6OwQ3TS8ifZcPH8YwgroAjWq1C00k=; b=tw6lxU8YhB9wpe+nZRlDbpwXvqqiOIhED0ktXfwSyFeZlwJcrdl6McaguAijOtO01A Zg4hTZxTYt6MXVATBcHafAbudXHM6BwGnvC1WnPhGwRp9ZC6VcHPejlC4uxWpF41R5Wf yJmd27KNZkzJPNNx6AruSWxAOvURTqF1f9sIFEr+vOSkbQnBv/0LZdibyLgu5XayE0yY PvWWHgJqIJLxGdHqMn49AHzYJccoobgTuB0GAdaz20tI9rmVb26BZF+BuaVeB6SPmJiT lfXllDFuUtBMvFSAe44bigd3n+pj2ff6/SDmEhmTXiYTkc3cgof6k2NqTpJk7FqUe+q9 Og5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Y86xtdv3; 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 h18-20020a63c012000000b0048118aa6359si13076208pgg.309.2022.12.19.20.24.07; Mon, 19 Dec 2022 20:24:17 -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=Y86xtdv3; 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 S232951AbiLTEHf (ORCPT + 70 others); Mon, 19 Dec 2022 23:07:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbiLTEHc (ORCPT ); Mon, 19 Dec 2022 23:07:32 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC54558B for ; Mon, 19 Dec 2022 20:07:30 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id j4so16844368lfk.0 for ; Mon, 19 Dec 2022 20:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=qDu+2HB9LCelBr6OwQ3TS8ifZcPH8YwgroAjWq1C00k=; b=Y86xtdv3XMJ+nN6oow1JLrJgBuF3civOC/ytVGb1nq+LnnsmCdw6yZQ1wsodZHZu+h ln3X2He+1mz1o7S8y46L4rQlGaYaBQ3m+ZhGRpa0x2Dr6YQUhUY/Or9zntk/NTPI0NQ4 QIH1W0OWhRa+DH724vkVR9Fb504i+gqDmStIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=qDu+2HB9LCelBr6OwQ3TS8ifZcPH8YwgroAjWq1C00k=; b=vlVFECtqjRVuD02MYWn567P8Fmh/RtXoEIwRTYcssoCfAjtU3uu5W74yW9/t6CP47c qc7AMUD6EVHsRfP8mPzDXe6bEcuXcZUV0IMwLKWI24nwer76vInEenoqR+B7hFBiRlq/ Sb4jTMQwXXeJEKRdIGwNtUPfvUFvYtLzpTQ+5ZIKckU62J3touolb7NbLfvgAo+sxXmP MznNHozERLuXSeTzS72ovcpgZ8J9PROPpbimZ27MvfGdLEDLnl7BcrB3GIw4gesAFQ13 vmFlJnRKgGFDx2NOQwSVOVH1aWxfjFmr5n9LogPhzlYGjlaPiBNA72xHgbLr0KaJmF4y tERQ== X-Gm-Message-State: ANoB5pl6odnYXjGc3YPMOzedfIN1ad0m/6Vwm+nYH16nS0o/v8ODDXWP UNMO44dAcRSnJ8dSYn8UHcyR5Y4XNvTKBOuaiRqcs/txEEDmfbJJrQ0= X-Received: by 2002:a05:6512:224c:b0:4b5:ad89:8174 with SMTP id i12-20020a056512224c00b004b5ad898174mr3579330lfu.84.1671509248402; Mon, 19 Dec 2022 20:07:28 -0800 (PST) MIME-Version: 1.0 References: <20221218191310.130904-1-joel@joelfernandes.org> In-Reply-To: <20221218191310.130904-1-joel@joelfernandes.org> From: Joel Fernandes Date: Mon, 19 Dec 2022 23:07:17 -0500 Message-ID: Subject: Re: [RFC 0/2] srcu: Remove pre-flip memory barrier To: linux-kernel@vger.kernel.org Cc: Josh Triplett , Lai Jiangshan , Mathieu Desnoyers , "Paul E. McKenney" , rcu@vger.kernel.org, Steven Rostedt Content-Type: text/plain; charset="UTF-8" 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=unavailable 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 Sun, Dec 18, 2022 at 2:13 PM Joel Fernandes (Google) wrote: > > Hello, I believe the pre-flip memory barrier is not required. The only reason I > can say to remove it, other than the possibility that it is unnecessary, is to > not have extra code that does not help. However, since we are issuing a fully > memory-barrier after the flip, I cannot say that it hurts to do it anyway. > > For this reason, please consider these patches as "informational", than a > "please merge". :-) Though, feel free to consider merging if you agree! > > All SRCU scenarios pass with these, with 6 hours of testing. > > thanks, > > - Joel > > Joel Fernandes (Google) (2): > srcu: Remove comment about prior read lock counts > srcu: Remove memory barrier "E" as it is not required And litmus tests confirm that "E" does not really do what the comments say, PTAL: Test 1: C mbe (* * Result: sometimes * Does previous scan see old reader's lock count, if a new reader saw the new srcu_idx? *) {} P0(int *lockcount, int *srcu_idx) // updater { int r0; r0 = READ_ONCE(*lockcount); smp_mb(); // E WRITE_ONCE(*srcu_idx, 1); } P1(int *lockcount, int *srcu_idx) // reader { int r0; WRITE_ONCE(*lockcount, 1); // previous reader smp_mb(); // B+C r0 = READ_ONCE(*srcu_idx); // new reader } exists (0:r0=0 /\ 1:r0=1) (* Bad outcome. *) Test 2: C mbe2 (* * Result: sometimes * If updater saw reader's lock count, was that reader using the old idx? *) {} P0(int *lockcount, int *srcu_idx) // updater { int r0; r0 = READ_ONCE(*lockcount); smp_mb(); // E WRITE_ONCE(*srcu_idx, 1); } P1(int *lockcount, int *srcu_idx) // reader { int r0; int r1; r1 = READ_ONCE(*srcu_idx); // previous reader WRITE_ONCE(*lockcount, 1); // previous reader smp_mb(); // B+C r0 = READ_ONCE(*srcu_idx); // new reader } exists (0:r0=1 /\ 1:r1=1) (* Bad outcome. *) thanks, - Joel > > kernel/rcu/srcutree.c | 10 ---------- > 1 file changed, 10 deletions(-) > > -- > 2.39.0.314.g84b9a713c41-goog >