From patchwork Thu Oct 5 16:53:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 148943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp443376vqb; Thu, 5 Oct 2023 10:09:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9IpSoBG7TSNuCRPqQmoWWCm/bzeb2hwf9kbyaOzsOMhtAbFSZu3zPyc8ByLhbv4iIVZDw X-Received: by 2002:a2e:8417:0:b0:2c0:afd:e7f5 with SMTP id z23-20020a2e8417000000b002c00afde7f5mr6077133ljg.9.1696525799571; Thu, 05 Oct 2023 10:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525799; cv=none; d=google.com; s=arc-20160816; b=yi1NmjizzFypseVdqtuWV/ZFk/GF6rldDT8+um1hwaU08Xgyeox0VfWawP2J4g9THT uLDlDz/ffalMHSWyO2T+qnsCQECDnHnzJwt0cHLPO4efRoBrx7AywaLCrHrxAk58/2up b70042zaZeEzQexuezPIvzW4qY/TWYpBrFjukInkMF02Nbx/G0acV4gpQnOTA5NYTjs3 ZTEfI+eGTFvlZ6oPW9WRuQ2eyeo2BhvlXrxtMTaqdp2IrQ0VZ4+/G/PhZ9DnruieWV+B leZHJn5M3Sm1qlopA+/QfV+H9r80sv9V0/5R6VlYb11gnAmTiRA77GAwi+PBzMTjLyRE Ndhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:reply-to :message-id:subject:cc:to:from:date:dkim-signature; bh=O2LkVsOUNcfNOZ7zcLJGYaf9zNORedlKx3IRt4lR1XE=; fh=ZAeClpQKVdF/lID2+PIUck9mjN5RgXLMZvjvPrAPbQc=; b=qssBh7t47BU/mLu2ISW8i7DeBpm00S2N6O8qWrPDo7fhGGQZSXAKyw0u5KfuOnRhW5 0Pghy9LDL3+FHF1IMwoJDfIRtkxqrTy3WPl6uQxpBmLYHGjz6EymwFfq6z1BX81Sjo5C sGt6yrFk8IWudmNrPDfwaoMpFpEKkAzfoT611avRWeQccZFfc5aarbQmIgGqjTYzcXFO UVkp8BzW/BeaYDL/2T0TVQldPZQt/DDeh7a+/gc8KFyDjVTbTZdWxS5n33MY6Qwq+7XF 5uYM3vQqiKxSu03vttwDQDaSvY3gzI5Dc+nqNjURVur/Jj4E6xLosjeiPEJCPJik/Q2k FixA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jLxs7RQU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x13-20020a2e9dcd000000b002be557458f3si1664320ljj.153.2023.10.05.10.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 10:09:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jLxs7RQU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9683283CF90D; Thu, 5 Oct 2023 10:09:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbjJERIu (ORCPT + 18 others); Thu, 5 Oct 2023 13:08:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjJERHw (ORCPT ); Thu, 5 Oct 2023 13:07:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB7B1FC2; Thu, 5 Oct 2023 09:53:13 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E04C4C433C7; Thu, 5 Oct 2023 16:53:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696524792; bh=QqFYej4zszOQ9dZXHQnUKqXBkmPZfqU3JS9WYFmKdmQ=; h=Date:From:To:Cc:Subject:Reply-To:From; b=jLxs7RQUwT/7fGOj6cQriRmgkLmIlXWgZAFYKosF74F9NyB3UNvErb1T/7nI/6Si9 rOa2rY9VSOZHefnUmUNYKPJIdU4kUjwP0ovsyGfGN8ujImCgY4H4nfkAV9si2htizu Z2et/xgbnU3WOpSEPrnLeRW8WlHQ2iv998MuPOq9E03EBangBojAbKvsd96brKRVh9 dMTTYS1YvFm7K721l139E0t65bYIaud8Cy5VC2gnAlCSFoJlzK8jZztudgCZM5hiF5 P5BopJk+Zu62aXB7B2waSVrYNZwTl6mml8nl6FpmncMjY4JsSjAmruuQDOiY8OTHEJ qMJKOrKBZyGqw== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 8157ACE0869; Thu, 5 Oct 2023 09:53:12 -0700 (PDT) Date: Thu, 5 Oct 2023 09:53:12 -0700 From: "Paul E. McKenney" To: 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 Subject: [PATCH memory-model] docs: memory-barriers: Add note on compiler transformation and address deps Message-ID: Reply-To: paulmck@kernel.org MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 05 Oct 2023 10:09:55 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778936236927878428 X-GMAIL-MSGID: 1778936236927878428 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 Reviewed-by: Andrea Parri 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