Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4662304rwe; Tue, 30 Aug 2022 14:35:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5yW9+shzU1MAK3lu3h+HjW785epTgig/laDVUu4o+gHR7MP6MIk0Hr50ng9XyCK6ENBVOM X-Received: by 2002:a65:6b8a:0:b0:42b:1eca:eef1 with SMTP id d10-20020a656b8a000000b0042b1ecaeef1mr19176190pgw.205.1661895334517; Tue, 30 Aug 2022 14:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661895334; cv=none; d=google.com; s=arc-20160816; b=GEP7bQMgeFPDr4kFwIJw1XeZ41ozZR5ULS6FRUsRwtD/Thnw9hPVj3m0CoRd+Ol6BB uAI3PvD413PR66sYYjV1hsCMSclD7RAiUV0bkG6ycS8SYKw/vLX1c0GcQyl8kHlc8MBS Vsi43nucmWwBzUvjSi/ikCg78hijq+OWiEsW7oIy63HZVLOl3819WlNQ1Q+cUnbY0e8D oRQbXN3J7qwVbbGjWI9SpR9YZLa9X/QOvlZHF2L9h1uw9KQOFOmnYiJOkUdZAIxoYfiU jCRRQxxix8e9F07fq0x7RzDU1Mdru9RzGTIh7HO4tXPRPBLkBj6RmprjbHwPSg5/OOgA Vl9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=2S/gPzbn70K9n2kENTZuMHMg0rHkBn7eRQ2xitbAkvQ=; b=an1vdz52BfkfHls42JUpxNJuzc6tKzHePFUnpAVzDajhE2zpLKfMXRiBo7A98YMCQ2 RPjOqGNXJ/f+eBya6MEtuOlZDmtGE0D1gdvtleLY0OMezaWFqGY0e2du1LuomYs1qTZG B9jdKVNPJWUQxFskxFcjlwNBHYOKtx0ocf3crl5XHu21PF7D4ZMVH18kelRO+kf1CYMq 1wXi0sHbRjw5PvrkEhCwWzHZUx7QL7+feWmjqTXD31dBySDHBPMRJLCM3GG9E7m2tLmm qivvpjncZDsyDVVJu5jT/C3+0cQieMtZR5SX4hMVD/bBojhwyKs6xN7S1vneVX67/IZr uzrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=l31XDqgc; 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 l7-20020a056a0016c700b0052eed737a67si12839989pfc.381.2022.08.30.14.35.23; Tue, 30 Aug 2022 14:35:34 -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=@joelfernandes.org header.s=google header.b=l31XDqgc; 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 S230450AbiH3VMk (ORCPT + 99 others); Tue, 30 Aug 2022 17:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230309AbiH3VMh (ORCPT ); Tue, 30 Aug 2022 17:12:37 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 153C086FC8 for ; Tue, 30 Aug 2022 14:12:36 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id b9so9459486qka.2 for ; Tue, 30 Aug 2022 14:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=2S/gPzbn70K9n2kENTZuMHMg0rHkBn7eRQ2xitbAkvQ=; b=l31XDqgcVa767LbJ/esQ54hvux+TzmouIJhDZQLPDm+jHDp6aO13ixM8EB1+UP+wNd subtyvz4u5a7FNkB7FgjTmEkkK8CYQ7ZYdUbM9HEiA0rwwLz9Fq781zz5SFzmIToEhiN J3PWrV7LeUp6my/1B6xgSfEeksh8eNgTyV5U4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=2S/gPzbn70K9n2kENTZuMHMg0rHkBn7eRQ2xitbAkvQ=; b=dvAStocT73v97KVNWVdHOS4C/6GqzuMr+clxk0S1oQpHFweHODi18SkZyA9nW//zcK vpvbUHO2/OJPv2v2wf3T9RzW2Al94aTICmvKV2ZNhLEO5ZuZ8McrHfhVwbEjIVy/Vynk carpkbXHpkm/qsn6hVOimbAPzyJ5NYd9+ggoQiwDVAjry+7UKUcXTWej/a+bM9WPWNsT if5G6CGtsgo0CEgs8nmvYS7JDhEig7XGE1Wm4qWFLhy32uyZOcma0y6LtyYjrtEvofXx kuSQYRqgITDzIcHFGe8TkNyxTdPUaHH3gB7Pmv6sMLgo04OPNauIVqGfME2cta0evLgf 1GIg== X-Gm-Message-State: ACgBeo0Heu8fajHNe8Lucv76gsEJzTeXXG9qm7AP5UpHFkcY9xt2N7W3 41wlc3OlYSTAcaSyY1QEeEEMcw== X-Received: by 2002:a05:620a:2585:b0:6b6:66b2:d40c with SMTP id x5-20020a05620a258500b006b666b2d40cmr13458668qko.710.1661893955222; Tue, 30 Aug 2022 14:12:35 -0700 (PDT) Received: from [10.0.0.40] (c-73-148-104-166.hsd1.va.comcast.net. [73.148.104.166]) by smtp.gmail.com with ESMTPSA id v17-20020a05620a0f1100b006b58d8f6181sm8654958qkl.72.2022.08.30.14.12.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Aug 2022 14:12:34 -0700 (PDT) Message-ID: <98f2b194-1fe6-3cd8-36cf-da017c35198f@joelfernandes.org> Date: Tue, 30 Aug 2022 17:12:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH] tools/memory-model: Weaken ctrl dependency definition in explanation.txt Content-Language: en-US From: Joel Fernandes To: =?UTF-8?Q?Paul_Heidekr=c3=bcger?= , Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Cc: Marco Elver , Charalampos Mainas , Pramod Bhatotia , Soham Chakraborty , Martin Fink References: <20220830204446.3590197-1-paul.heidekrueger@in.tum.de> <663d568d-a343-d44b-d33d-29998bff8f70@joelfernandes.org> In-Reply-To: <663d568d-a343-d44b-d33d-29998bff8f70@joelfernandes.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLACK 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 8/30/2022 5:08 PM, Joel Fernandes wrote: > > > On 8/30/2022 4:44 PM, Paul Heidekrüger wrote: >> The current informal control dependency definition in explanation.txt is >> too broad and, as dicsussed, needs to be updated. >> >> Consider the following example: >> >>> if(READ_ONCE(x)) >>> return 42; >>> >>> WRITE_ONCE(y, 42); >>> >>> return 21; >> >> 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. >> >> Introduce a new defintion which includes the requirement for the second >> memory access event to syntactically lie within the arm of a non-loop >> conditional. >> >> 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üger >> Co-developed-by: Alan Stern >> --- >> >> @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. >> >> tools/memory-model/Documentation/explanation.txt | 7 ++++--- >> 1 file changed, 4 insertions(+), 3 deletions(-) >> >> diff --git a/tools/memory-model/Documentation/explanation.txt b/tools/memory-model/Documentation/explanation.txt >> index ee819a402b69..0bca50cac5f4 100644 >> --- a/tools/memory-model/Documentation/explanation.txt >> +++ b/tools/memory-model/Documentation/explanation.txt >> @@ -464,9 +464,10 @@ to address dependencies, since the address of a location accessed >> through a pointer will depend on the value read earlier from that >> pointer. >> >> -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, >> +else or switch statement and the condition guarding Y is either data or >> +address-dependent on X. Simple example: > > 'conditioning guarding Y' sounds confusing to me as it implies to me that the > condition's evaluation depends on Y. I much prefer Alan's wording from the > linked post saying something like 'the branch condition is data or address > dependent on X, and Y lies in one of the arms'. > > I have to ask though, why doesn't this imply that the second instruction never > executes at all? I believe that would break the MP-pattern if it were not true. About my last statement, I believe your patch does not disagree with the correctness of the earlier text but just wants to improve it. If that's case then that's fine. - Joel