Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp919717rwb; Sat, 3 Sep 2022 05:27:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR7HpGJ0nIZPVvjjqp0wpDgzDXobagZ85NGxG4WMXaBkEqHqSMOBk2DgjfnTaFGI3/tA/qIN X-Received: by 2002:a63:5d46:0:b0:41c:861:d0d2 with SMTP id o6-20020a635d46000000b0041c0861d0d2mr33133001pgm.184.1662208029657; Sat, 03 Sep 2022 05:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662208029; cv=none; d=google.com; s=arc-20160816; b=r/qj5hRWteb5iKKT8SsUTxRU1a9vfnQ6ZGuTOiuVGKZPlSNxDX4TW44nPgXKxLqjlu Gl0xdVHSmuTdZ9aIZz2BJy7ebKZ2n1KdD1mrmFHuh/tuinB2bh82dp8weSjkRb6JVD3V 7/ytdb0Eqkmg9widGdxAP/IWSe7AmIiemVeVTogXcYXrsP9azOT2HMTscrdiAhhFflGs D/u/oENvZObaszMb+vzR39Uj9zDWbN7qP2iagxaKocRxaBQIOG4+IdTgbWiIkjbdlN+5 fF9Ty/+Mp5GyghuYxj4c5C+ETYRdNcemf1CqoYxhKroQXbNelowlq5s+k7eyV8BIogmW 3Ujg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=WTHSGOgXdL1ETWQB4FmjCtq7b8+QUK7FV8+8M7WsAaQ=; b=EllDmWZoXd8oS2wKKno3oORJI9JqHGIynQ1NESB/aIndVcHQ0GOMv994J2MSl9PctS D8u+eYjUl+bwPrzTJSXSEYpnH98XyekG4S2SSmZRfRCZ6WrPFIFYs6DFjQQUnugMIWhm NWuL6JXOigRkyU1oUqXiQJ9mxDLWq55uvgWrT+JVlxiApJ/+scrqJZgApllropR1VRc3 dXz40amF3x4SgSgxp1cHU7zOotkc5ri2EGBFD04nSjK+Ez2JUcCBYS1P5lTPubBtLa3S LG+RWR3MPZVa6JMgXZv0EMTeV1leMe7QYInCZPlnvqX08hXqwiemHH4xrN+tE9PIFwHl 47jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@in.tum.de header.s=20220209 header.b=AS887YsN; 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=tum.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a170903234b00b0016d7639681dsi5034472plh.493.2022.09.03.05.26.56; Sat, 03 Sep 2022 05:27:09 -0700 (PDT) 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=@in.tum.de header.s=20220209 header.b=AS887YsN; 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=tum.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230130AbiICLln (ORCPT + 99 others); Sat, 3 Sep 2022 07:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiICLll (ORCPT ); Sat, 3 Sep 2022 07:41:41 -0400 Received: from mailout1.rbg.tum.de (mailout1.rbg.tum.de [131.159.0.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DFB453D25; Sat, 3 Sep 2022 04:41:39 -0700 (PDT) Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [IPv6:2a09:80c0:254::14]) by mailout1.rbg.tum.de (Postfix) with ESMTPS id 5E3C04D; Sat, 3 Sep 2022 13:41:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=in.tum.de; s=20220209; t=1662205296; bh=WTHSGOgXdL1ETWQB4FmjCtq7b8+QUK7FV8+8M7WsAaQ=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=AS887YsN6S7/Ti227pObQKvjit4dHOmfKaqtPMo4KgKboWFSGMTcIVOUEXtJ/tTF1 VvtJh114tguB3szieJipx4Z7tDowAjax3P1C7ZbOssuI5sIGreIToLeQjtdikoqRNM /mp83GZfkyzbLeLU+32HkyKZUUQ3f/dFkrOgVqUcQqKwS4qnZy4X0+oRLjOxCjjFRK Jp3ca3wja9qNgMCSfyPJbrZRpIJZcK6HVwUzQ/Rfkjoj9QN33hdl+6QJNkQ5OcqEJg ZSnTVMwSc/qka9HJLbdVzZtOIzMnpvet2VjbvMjrv+QaaCY2lURJA3kDBOOajXprnk WBhB5yjM0LlIQ== Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id 586EF1ADC; Sat, 3 Sep 2022 13:41:36 +0200 (CEST) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 2BBBD1ADB; Sat, 3 Sep 2022 13:41:36 +0200 (CEST) Received: from mail.in.tum.de (mailproxy.in.tum.de [IPv6:2a09:80c0::78]) by mailrelay1.rbg.tum.de (Postfix) with ESMTPS id 275D11AD9; Sat, 3 Sep 2022 13:41:36 +0200 (CEST) Received: by mail.in.tum.de (Postfix, from userid 112) id 23B3C4A01E6; Sat, 3 Sep 2022 13:41:36 +0200 (CEST) Received: (Authenticated sender: heidekrp) by mail.in.tum.de (Postfix) with ESMTPSA id 4B57F4A01CD; Sat, 3 Sep 2022 13:41:35 +0200 (CEST) (Extended-Queue-bit xtech_yq@fff.in.tum.de) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Subject: Re: [PATCH v3] tools/memory-model: Weaken ctrl dependency definition in explanation.txt From: =?utf-8?Q?Paul_Heidekr=C3=BCger?= In-Reply-To: Date: Sat, 3 Sep 2022 13:41:34 +0200 Cc: Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Michael Ellerman , LKML , linux-arch , Marco Elver , Charalampos Mainas , Pramod Bhatotia , Soham Chakraborty , Martin Fink Content-Transfer-Encoding: quoted-printable Message-Id: References: <20220902211341.2585133-1-paul.heidekrueger@in.tum.de> To: Alan Stern X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 3. Sep 2022, at 03:27, Alan Stern wrote: > On Fri, Sep 02, 2022 at 09:13:40PM +0000, Paul Heidekr=C3=BCger wrote: >> The current informal control dependency definition in explanation.txt = is >> too broad and, as discussed, needs to be updated. >>=20 >> Consider the following example: >>=20 >>> if(READ_ONCE(x)) >>> return 42; >>>=20 >>> WRITE_ONCE(y, 42); >>>=20 >>> return 21; >>=20 >> The read event determines whether the write event will be executed = "at all" >> - as per the current definition - but the formal LKMM does not = recognize >> this as a control dependency. >>=20 >> Introduce a new definition which includes the requirement for the = second >> memory access event to syntactically lie within the arm of a non-loop >> conditional. >>=20 >> Link: = https://lore.kernel.org/all/20220615114330.2573952-1-paul.heidekrueger@in.= tum.de/ >> Cc: Marco Elver >> Cc: Charalampos Mainas >> Cc: Pramod Bhatotia >> Cc: Soham Chakraborty >> Cc: Martin Fink >> Signed-off-by: Paul Heidekr=C3=BCger >> Co-developed-by: Alan Stern >=20 > Signed-off-by: Alan Stern >=20 >> --- >>=20 >> v3: >> - Address Alan and Joel's feedback re: the wording around switch = statements >> and the use of "guarding" >>=20 >> v2: >> - Fix typos >> - Fix indentation of code snippet >>=20 >> v1: >> @Alan, since I got it wrong the last time, I'm adding you as a = co-developer >> after my SOB. I'm sorry if this creates extra work on your side due = to you >> having to resubmit the patch now with your SOB if I understand = correctly, >> but since it's based on your wording from the other thread, I = definitely >> wanted to give you credit. >>=20 >> tools/memory-model/Documentation/explanation.txt | 8 +++++--- >> 1 file changed, 5 insertions(+), 3 deletions(-) >>=20 >> diff --git a/tools/memory-model/Documentation/explanation.txt = b/tools/memory-model/Documentation/explanation.txt >> index ee819a402b69..0b7e1925a673 100644 >> --- a/tools/memory-model/Documentation/explanation.txt >> +++ b/tools/memory-model/Documentation/explanation.txt >> @@ -464,9 +464,11 @@ to address dependencies, since the address of a = location accessed >> through a pointer will depend on the value read earlier from that >> pointer. >>=20 >> -Finally, a read event and another memory access event are linked by = a >> -control dependency if the value obtained by the read affects whether >> -the second event is executed at all. Simple example: >> +Finally, a read event X and another memory access event Y are linked = by >> +a control dependency if Y syntactically lies within an arm of an if >> +statement and X affects the evaluation of the if condition via a = data or >> +address dependency (or similarly for a switch statement). Simple >> +example: >>=20 >> int x, y; Hang on, shouldn't this read "a write event" instead of "another memory access event"? Control dependencies only provide ordering from READ_ONCE = to WRITE_ONCE, not from READ_ONCE to (READ | WRITE)_ONCE? Or am I missing something? Many thanks, Paul=