Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4511374rwb; Sat, 21 Jan 2023 13:35:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXtrPYC/99VahgEEyTCI2Yj5MZrPIf0/tOwznQf19JnvRjAT1nb1Y1z361xvYZFaBwWgVnT0 X-Received: by 2002:a05:6a20:4c15:b0:b8:4fcc:ff70 with SMTP id fm21-20020a056a204c1500b000b84fccff70mr19472818pzb.33.1674336934263; Sat, 21 Jan 2023 13:35:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674336934; cv=none; d=google.com; s=arc-20160816; b=biRa6tqm80n8ugZBmnd3VpvuqDQAv03sSsqEn/+zDVQPqN9+OCfbnOrlT3jSbxaPV7 sAG0+p4T0Nx4vwwoHjLMVZtlQDypYte4Ti+xFRcWaLhz8Zns8wZsV75ICrLdY6DtKc1g 1HMy3vZFFlRFTndB3hmyz/AAIDyjT/VqxA0dHJlu9z8zeTaiCfraXP9Xvs0mz78eBjF/ qol4ccd+8Qu7Tq2C3XKqicvTnsUsif93IpY4EZB285TnrdRVubhIYVpZV1tSoHnOFgTB An77LLmxbdyxJ9fkeG9D2ajXtoocI8IhOEep2zFOt2RQHV0ccGtN/QZDO5akgeLvVOl5 X4wQ== 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; bh=YfDGobGFpkYAd4dRPGFWQAh6mzhWliexOBR25vZylBI=; b=sm2OlmytgU8pZwEbQeXVPoBuFZ6skMeqZBDUwoOIIHXIFfD09h8THCiVq7/j9P2vZl bF2BDRATdDqOcxvHJFkXXlPYAFN/nP+HpJvBCTsYs8preXMwZjLgPUvWE5tvpkuSbgTd q65twY/qsv+54MJx95bafrPq65Gh6avO7aQnY7ETAc+2BM6bcaU+ZEHlaR2ugs5aHmtg i0cHtk8DIuC//eAzh3XJVCsTLT203AJWb0Zc8L/uajcV6gj4H7OKZnGr182JPbE4XM38 EhdyUnUqRQkjKJ2Gma3e7b3uRRRd3/7P8nlV1ToDTgMldBHfTX6fM7wHlsxIUxI/aFSR /vVQ== ARC-Authentication-Results: i=1; mx.google.com; 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 d20-20020a63f254000000b004786f5e24f9si47386163pgk.94.2023.01.21.13.35.26; Sat, 21 Jan 2023 13:35:34 -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; 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 S229669AbjAUVDn (ORCPT + 52 others); Sat, 21 Jan 2023 16:03:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjAUVDm (ORCPT ); Sat, 21 Jan 2023 16:03:42 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id AE5061F5EA for ; Sat, 21 Jan 2023 13:03:39 -0800 (PST) Received: (qmail 77227 invoked by uid 1000); 21 Jan 2023 16:03:38 -0500 Date: Sat, 21 Jan 2023 16:03:38 -0500 From: Alan Stern To: "Paul E. McKenney" Cc: Jonas Oberhauser , Andrea Parri , Jonas Oberhauser , Peter Zijlstra , will , "boqun.feng" , npiggin , dhowells , "j.alglave" , "luc.maranget" , akiyks , dlustig , joel , urezki , quic_neeraju , frederic , Kernel development list Subject: Re: Internal vs. external barriers (was: Re: Interesting LKMM litmus test) Message-ID: References: <20230119001147.GN2948950@paulmck-ThinkPad-P17-Gen-1> <0fae983b-2a7c-d44e-8881-53d5cc053f09@huaweicloud.com> <20230119184107.GT2948950@paulmck-ThinkPad-P17-Gen-1> <64b48a7b-624c-26bd-be9b-0522fc490b28@huaweicloud.com> <20230121184032.GF2948950@paulmck-ThinkPad-P17-Gen-1> <20230121201026.GH2948950@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230121201026.GH2948950@paulmck-ThinkPad-P17-Gen-1> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no 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 Sat, Jan 21, 2023 at 12:10:26PM -0800, Paul E. McKenney wrote: > On Sat, Jan 21, 2023 at 02:56:57PM -0500, Alan Stern wrote: > > > > Anyway, the operational model says the litmus test can succeed as > > > > follows: > > > > > > > > P0 P1 P2 > > > > --------------------- ---------------------- ------------------------- > > > > Widx2=srcu_down_read() > > > > Wrel p2=1 > > > > Ry=0 > > > > Wy=1 > > > > synchronize_srcu() starts > > > > ... idx2, p2, and y propagate to all CPUs ... > > > > Time t1 > > > > Widx1=srcu_down_read() > > > > Wrel p1=1 > > > > ,,, idx1 and p1 propagate to all CPUs ... > > > > Racq p1=1 > > > > srcu_up_read(idx2) > > > > synchronize_srcu() ends > > > > Wx=1 > > > > Rx=1 > > > > Racq p2=1 > > > > Ridx2=idx1 > > > > srcu_up_read(idx1) > > > > > > > > (The final equality in P0 is allowed because idx1 and idx2 are both > > > > random numbers, so they might be equal.) > > > > > > This all makes sense to me. > > > > > > > Incidentally, it's worth pointing out that the algorithm Paul described > > > > will forbid this litmus test even if you remove the while loop and the > > > > read of idx2 from P0. > > Sorry, what I said may not have been clear. I meant that even if you > > remove the while loop and read of idx2 from P0, your algorithm will > > still not allow idx1 = idx2 provided everything else is as written. > > If synchronize_srcu() has flipped ->srcu_idx by the time that P0's > srcu_down_read() executes, agreed. Otherwise, Widx1 and Widx2 might > well be equal. But idx1 and idx2 are equal, we can't have both P0 reads x=1 and P1 reads y=0 -- not even if P0 doesn't wait until it reads p2=1. If you don't see why, I'll send an explanation. Alan