Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp507903rdb; Fri, 6 Oct 2023 09:40:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsC8hTrZ7H62ELgWhhc6iHnAwsC8N/lu6lSEluRSHJ9Yjq2AVOryLNKCk21lg0vWZ3F4Zs X-Received: by 2002:a05:6358:90e:b0:143:63ae:cc76 with SMTP id r14-20020a056358090e00b0014363aecc76mr8783392rwi.11.1696610416802; Fri, 06 Oct 2023 09:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696610416; cv=none; d=google.com; s=arc-20160816; b=CEsz7kiSqwagA3cpOT8raORmmirvlKFUmgqHPZPC3Kd+Ch9+4XgmI82HIDAX8BknQG WXfAQdGzGH66QKEPNzjS+foRpOdYD9wiDjRpiwFBLU+Nvbu8TXZG4WbDURZEzZsvF09F yyPKs1/6d25fYBWPnFvOk163ch6SxU+1YmR3dUcxnH0OlES/Ri9BHdl9M+CWm1Q3JJsw 7lKrkv95v+qTo6Kcvsn5McTsU6tDJQmlwFUg16eEUX1jNeDHti24F8+H79H+0hKPovH7 ZyA3VnnT9WKGGJvbIfGN30GXX3hvi3b33oq20DV+BrTsD2uY5pMJK/RidChNcTpTYoP2 vdvA== 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:subject:user-agent:mime-version:date:message-id; bh=QfAo64G6SM630PwCit3OEfh6Pc+HVF9RAVJwt45cP0s=; fh=Q4jY9dZGYP9q7kn93eJ0mESrNqPutMFF9RJEqeF/tDs=; b=Qpn0Ia96RT37hpC2JLG0H6q6YdlmxDiNtYMCNfu5d8MJzeIlT9afNeRtubRhMcTUNr ucoeK4U1/zMGBfFdX2W6m2beh6H/dFXWQM9AWjdiwtmvPlyX7Jzu06ALRXRWH+qVxf6m MO14qqsvQTSbuNkwIWZOjio+n+pBuEpfM6aVX8bB/S3hLMkUlKQECEKc/be9K6zq2s+h e8qkQiH0AKiwk/FZ9rk50qv/zXetBCJBB402KyXwi9Cwl35BADOV2vujYfDjmDMrFPZX 2CnOhq/GKyPngwoqLjFLCM0XvyjJsSr3feKQ1sXBfNRrrsKYNWG25py/P4FRGehQOZCX TerQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 202-20020a6300d3000000b00578c9144910si4095549pga.410.2023.10.06.09.40.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 09:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 745288142DBC; Fri, 6 Oct 2023 09:40:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232496AbjJFQkA (ORCPT + 99 others); Fri, 6 Oct 2023 12:40:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232807AbjJFQj7 (ORCPT ); Fri, 6 Oct 2023 12:39:59 -0400 Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81D14C2; Fri, 6 Oct 2023 09:39:57 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.18.147.228]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4S2DNF5kL1z9ylcZ; Sat, 7 Oct 2023 00:27:09 +0800 (CST) Received: from [10.45.145.231] (unknown [10.45.145.231]) by APP1 (Coremail) with SMTP id LxC2BwBHn5A4OCBlj9m1AQ--.6636S2; Fri, 06 Oct 2023 17:39:32 +0100 (CET) Message-ID: <4110a58a-8db5-57c4-2f5a-e09ee054baaa@huaweicloud.com> Date: Fri, 6 Oct 2023 18:39:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH memory-model] docs: memory-barriers: Add note on compiler transformation and address deps To: paulmck@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org Cc: Alan Stern , Andrea Parri , Will Deacon , Peter Zijlstra , Boqun Feng , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , Akira Yokosawa , Daniel Lustig , Joel Fernandes , Jonathan Corbet References: From: Jonas Oberhauser In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: LxC2BwBHn5A4OCBlj9m1AQ--.6636S2 X-Coremail-Antispam: 1UD129KBjvJXoWxWr15WF4fAryUKFWrAFWDArb_yoW5CF47pr WfKr13tFZrJr12kw1UAw17AryjyFZ5CF43Gr9F9r1kurn09r1FyrnxKr48uFyDC395AryU ZrZ0yws8Zw1DAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv2b4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxV AFwI0_Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lFIxGxcIEc7CjxVA2Y2ka0xkIwI1lc7I2V7IY0VAS 07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_ WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E3s1lIxAIcVC2z280aVAF wI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa 7IU13rcDUUUUU== X-CM-SenderInfo: 5mrqt2oorev25kdx2v3u6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RCVD_IN_SBL_CSS,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 06 Oct 2023 09:40:11 -0700 (PDT) Hi Paul, The "more up-to-date information" makes it sound like (some of) the information in this section is out-of-date/no longer valid. But after reading the sections, it seems the information is valid, but discusses mostly the history of address dependency barriers. Given that the sepcond part  specifically already starts with a disclaimer that this information is purely relevant to people interested in history or working on alpha, I think it would make more sense to modify things slightly differently. Firstly I'd remove the "historical" part in the first section, and add two short paragraphs explaining that - every marked access implies a address dependency barrier - address dependencies considered by the model are *semantic* dependencies, meaning that a *syntactic* dependency is not sufficient to imply ordering; see the rcu file for some examples where compilers can elide syntactic dependencies Secondly, I'd not add the disclaimer to the second section; there's already a link to rcu_dereference in that section ( https://github.com/torvalds/linux/blob/master/Documentation/memory-barriers.txt#L634 ), and already a small text explaining that the section is historical. Best wishes, jonas Am 10/5/2023 um 6:53 PM schrieb Paul E. McKenney: > The compiler has the ability to cause misordering by destroying > address-dependency barriers if comparison operations are used. Add a > note about this to memory-barriers.txt in the beginning of both the > historical address-dependency sections and point to rcu-dereference.rst > for more information. > > Signed-off-by: Joel Fernandes (Google) > Signed-off-by: Paul E. McKenney > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > index 06e14efd8662..d414e145f912 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -396,6 +396,10 @@ Memory barriers come in four basic varieties: > > > (2) Address-dependency barriers (historical). > + [!] This section is marked as HISTORICAL: For more up-to-date > + information, including how compiler transformations related to pointer > + comparisons can sometimes cause problems, see > + Documentation/RCU/rcu_dereference.rst. > > An address-dependency barrier is a weaker form of read barrier. In the > case where two loads are performed such that the second depends on the > @@ -556,6 +560,9 @@ There are certain things that the Linux kernel memory barriers do not guarantee: > > ADDRESS-DEPENDENCY BARRIERS (HISTORICAL) > ---------------------------------------- > +[!] This section is marked as HISTORICAL: For more up-to-date information, > +including how compiler transformations related to pointer comparisons can > +sometimes cause problems, see Documentation/RCU/rcu_dereference.rst. > > As of v4.15 of the Linux kernel, an smp_mb() was added to READ_ONCE() for > DEC Alpha, which means that about the only people who need to pay attention