Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4647676rwe; Tue, 30 Aug 2022 14:15:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR6zsAMK11uj62qQ3bqLRlZAyMuesAsQZ9P44zW+z+g/+dGx3TQncM8rzRKDKK6xBLVCUqoB X-Received: by 2002:a17:902:7c0b:b0:174:abfc:f5 with SMTP id x11-20020a1709027c0b00b00174abfc00f5mr12555645pll.124.1661894120886; Tue, 30 Aug 2022 14:15:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661894120; cv=none; d=google.com; s=arc-20160816; b=EtE+MdW7oEbHnzYro4cF0dFN5tyJOy9ZeL8HQ9sE/5CW77JFrIrEv/0HGBScNpIXQQ dDMDUIks2AJo6MOnI2LwM3IWZ1WkjXryTykRJwLHCREjnvWM6z3yjAhGcojs3tC8iQ1C Ue+s9z1lLa6pYavbpAq6srO7Rt6LcBxrPezgM3cSRwDTahaLzrIi/lzXmz4YfZsZuzgO dsf9s1xwsOsEHylhe/HFbJUr8HJe91MFmHgW5xRAgtT3BruYNR0G3QXlXWihOEwXwpu/ BizORBtmsWOxukAfoc+ylKTE/lxgNh43rzBr+e2N5J1baDVrkUHiHp6hpBFl3fc8Avho zP4g== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=YnMPi8S/rmzftaQJdnwQOkJ/FK3B4YCgHwvUmwZNUOY=; b=PiFXOyNgeme0QLsTL0O7DTQamaa/y93kLOjsiJIiEWlOdAkfWmfDOtIMt/OAUd9KY+ ImAauUmqj3z835Bwv1eA3iVQJ4xU8DTL5mwR/neIR3Na+5tUSnrCg/a8oYc4XDXkBaid VxpHK/XTVtjtn4sNZnNzKE4a3aAaxboC0P0X3l4MooyArOOsx6pcDMNvrJCr8d89ct4b FEdWjMWXN4IZ7EgwLOk0pvylUJcr733qZNGG32Em+ianBvL/gYqDttbnQHryrZU93De0 nByvI809L+ZOHycaiGZ14HcI5uwSTIKd6pPyYqc9QXOf2wjMPqWDmpgFwi7hvD+2WghP BTiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=W1TkrN40; 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 s5-20020a632c05000000b0042b50946042si3078782pgs.830.2022.08.30.14.15.09; Tue, 30 Aug 2022 14:15:20 -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=W1TkrN40; 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 S230294AbiH3VIW (ORCPT + 99 others); Tue, 30 Aug 2022 17:08:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbiH3VIT (ORCPT ); Tue, 30 Aug 2022 17:08:19 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A36C86884 for ; Tue, 30 Aug 2022 14:08:18 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id j17so9566807qtp.12 for ; Tue, 30 Aug 2022 14:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc; bh=YnMPi8S/rmzftaQJdnwQOkJ/FK3B4YCgHwvUmwZNUOY=; b=W1TkrN40e7YmmGfiyZ9+TO2XuGUSCuaHtVqqW6ECmbsaOvBWLc7WjWn/2wAvg95xoq a/9Mfhw40R792rRpcMLWlsiujFayibkHs4KGArB7fDXRRhigmP2Zu1xV0uX97wVr8N3o jqad79DGL0xMxExjk5tab/QwmXpL7D8i/ZVR0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=YnMPi8S/rmzftaQJdnwQOkJ/FK3B4YCgHwvUmwZNUOY=; b=FCc7lzSBhiF1P1d0CkPMo6bZ7lSoNod8ykSrGPS8ChhuVFg4NFOEhKLgsaC1+vsTVj FjmR+/jCW215yX1Zh3/zNUXmUkVzrVlVITyXuR0AHqmnTAU3XCAs4qtVVkYrHWD6j5kD oF9r6tdNR9h+D5YmYcHutqnRW4CeHkBrMicLqQBW9wXNCj9CmlBg6/oq7FmNcrNwAM38 ohWNm4blflsaWJd4mYZdJ03bvC+9FNiIomdURASMeNZ7606epuV+lx2OYBDFMD8RPdIJ 1bDz07m922xDjzwEJcJp12+ZlVZ1HRCGMBPjJOqyzOezDKh0QviZLRYqeEgkzf3MzVAx rMMA== X-Gm-Message-State: ACgBeo3LkvXximfaaE2Jjc/JauPTxXc1ukDBl6fsfCW/qrLIuOjn4vCl BLoPSxm/2QxpRcSCpTnHxSX2TQ== X-Received: by 2002:a05:622a:11d6:b0:343:5e19:7488 with SMTP id n22-20020a05622a11d600b003435e197488mr16456868qtk.476.1661893697348; Tue, 30 Aug 2022 14:08:17 -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 l17-20020a37f911000000b006b629f86244sm8432968qkj.50.2022.08.30.14.08.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Aug 2022 14:08:17 -0700 (PDT) Message-ID: <663d568d-a343-d44b-d33d-29998bff8f70@joelfernandes.org> Date: Tue, 30 Aug 2022 17:08:15 -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 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> From: Joel Fernandes In-Reply-To: <20220830204446.3590197-1-paul.heidekrueger@in.tum.de> 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 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. cheers, - Joel