Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2041585iof; Tue, 7 Jun 2022 17:54:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/ZEbCvhSgLhIbfsO5GQM2Yg1sw5+3ML+3nQQqSElu1eI+g097JYYe8JzOyWF7F85o1twN X-Received: by 2002:a17:902:d509:b0:167:6ed8:afb5 with SMTP id b9-20020a170902d50900b001676ed8afb5mr17095962plg.137.1654649658461; Tue, 07 Jun 2022 17:54:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654649658; cv=none; d=google.com; s=arc-20160816; b=FcFLj9smybhmrd5IBAme4B8g9rQo+7ybUq8qCTLZI1Okt4CX96QIZyebyPewF9Uzj/ koCYjOXzda76YOqlbRWiKc5v0Ph/X5q4TmyEVPjeEpnPAPRXWvgrztlf3kk/29tozTbh j7a98z1WdPp8segz8RFcJe4cdrTO2KtS/NqXbxFuQUoA3ZeF0lum5XLrd30ZE678RcsB slrTJYZuKzCUn3b4Sd6aEgZ4NOS9cUurRhlo9XXs6Haf0B5k7J2yuv9yf+18gchXUP0E MrF+JMYgsluPa4mK+GICpdd7xmAh+pjBcdii100VZzGHwVgotOQ7YkS+nWJHTvDmi0Ov CtjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=otaej8QVZpmgsnmnJEU5o3zsRk+IKm1vewRxUN1Qqtw=; b=qE1SMoaOisHmkXD3WCwc1a4F8/Ag6CegbjdIIBxvk6k1K5jPEbB0n7o/VCjXQSd4eo DUxkYUx5Ns99ccdQlVGvi59ngtb4NZKJEGr4QDe2SeKvyrMnjC3JqS5wh4WrEEk/Ydp5 Fv/r16S8xED8iMdktUs7JBqh5zWE/rvRrnX3/EJ2gY1XWyw+0an5b3ebRR5oydngkwnJ g7vV4CAiuLDvG4iV85vyR/NJBnoHvhBgm2z/7928B6ucWLdyczv4Ra6KXCo71Jx57gJT wdTFLEdxIwiUt7dVh2LyiZszCbmcWA9a7w3ujbDjpwtSYoG8q5sV5Yi3GIH3ISOhwgsN VGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SRh3nfHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s1-20020a056a00178100b005107e713c1dsi19611114pfg.273.2022.06.07.17.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 17:54:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SRh3nfHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4B992213294; Tue, 7 Jun 2022 17:51:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244756AbiFGNeq (ORCPT + 99 others); Tue, 7 Jun 2022 09:34:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234431AbiFGNem (ORCPT ); Tue, 7 Jun 2022 09:34:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C55AEC0E3D; Tue, 7 Jun 2022 06:34:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 628D66144C; Tue, 7 Jun 2022 13:34:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D96BC385A5; Tue, 7 Jun 2022 13:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654608879; bh=CuYxQ35fpR+VuhG0h+xJqZX2h8dcdonxjn9U1FJK+2g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SRh3nfHmEvi+TS+JUzLl5D6J6dwrs//Eibz339wIB5trml4Np5BTTCA/AKjxImPCs t9nh/FFwhbJrzxHZANLfWcq0RYa6JDUG70LR4QnaZcVlqfGMACUeFS9j0p4XeuJAfc 9IrUJa4f7Qu2AixXO8+ZxaQxW9iV/xQJYmUpCNHofAyJbfmUeLo4sAoWvb+RpBNCPZ L6FFCFwTKtqRHBcyTIAmebgomr9HwDuhPU8gR4y7Mqj5LSVFb8aE6gMaRFQbXxLmaj 5RsgF7ILxWQoIZJAfP2M20TuPXnySwkzelgoaWDRaiyrYj5PASI9/b18go1cWvu3Ri 5VQ5y9y8anpew== Date: Tue, 7 Jun 2022 14:34:33 +0100 From: Will Deacon To: Akira Yokosawa Cc: "Paul E. McKenney" , "Michael S. Tsirkin" , Alan Stern , Peter Zijlstra , Boqun Feng , Andrea Parri , Nicholas Piggin , David Howells , Daniel Lustig , Joel Fernandes , Jonathan Corbet , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [RFC PATCH -lkmm] docs/memory-barriers: Fix inconsistent name of 'data dependency barrier' Message-ID: <20220607133432.GA32701@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Sat, May 28, 2022 at 01:15:30PM +0900, Akira Yokosawa wrote: > The term "data dependency barrier", which has been in > memory-barriers.txt ever since it was first authored by David Howells, > has become confusing due to the fact that in LKMM's explanations.txt > and elsewhere, "data dependency" is used mostly for load-to-store data > dependency. > > To prevent further confusions, do the following changes: > > - substitute "address-dependency barrier" for "data dependency barrier"; > - add note on the removal of kernel APIs for explicit address- > dependency barriers in kernel release v5.9; > - add note on the section title rename; > - use READ_ONCE_OLD() for READ_ONCE() of pre-4.15 (no address- > dependency implication) in code snippets; > - fix number of CPU memory barrier APIs; > - and a few more context adjustments. > > Note: Line break cleanups are deferred to a follow-up patch. > > Reported-by: "Michael S. Tsirkin" > Signed-off-by: Akira Yokosawa > Cc: "Paul E. McKenney" > Cc: Alan Stern > Cc: Will Deacon > Cc: Peter Zijlstra > Cc: Boqun Feng > Cc: Andrea Parri > Cc: Nicholas Piggin > Cc: David Howells > Cc: Daniel Lustig > Cc: Joel Fernandes > Cc: Jonathan Corbet > --- > This is a response to Michael's report back in last November [1]. > > [1]: "data dependency naming inconsistency": > https://lore.kernel.org/r/20211011064233-mutt-send-email-mst@kernel.org/ > > In the thread, I suggested removing all the explanations of "data dependency > barriers", which Paul thought was reasonable. > > However, such removals would require rewriting the notoriously > hard-to-grasp document, which I'm not quite up to. > I have become more inclined to just substitute "address-dependency > barrier" for "data dependency barrier" considering the fact that > READ_ONCE() has an implicit memory barrier for Alpha. > > This RFC patch is the result of such an attempt. > > Note: I made a mistake in the thread above. Kernel APIs for explicit data > dependency barriers were removed in v5.9. > I confused the removal with the addition of the barrier to Alpha's > READ_ONCE() in v4.15. > > Any feedback is welcome! > > Thanks, Akira > -- > Documentation/memory-barriers.txt | 119 +++++++++++++++++------------- > 1 file changed, 67 insertions(+), 52 deletions(-) > > diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt > index b12df9137e1c..306afa1f9347 100644 > --- a/Documentation/memory-barriers.txt > +++ b/Documentation/memory-barriers.txt > @@ -52,7 +52,7 @@ CONTENTS > > - Varieties of memory barrier. > - What may not be assumed about memory barriers? > - - Data dependency barriers (historical). > + - Address-dependency barriers (historical). > - Control dependencies. > - SMP barrier pairing. > - Examples of memory barrier sequences. > @@ -187,7 +187,7 @@ As a further example, consider this sequence of events: > B = 4; Q = P; > P = &B; D = *Q; > > -There is an obvious data dependency here, as the value loaded into D depends on > +There is an obvious address dependency here, as the value loaded into D depends on > the address retrieved from P by CPU 2. At the end of the sequence, any of the > following results are possible: > > @@ -391,49 +391,53 @@ Memory barriers come in four basic varieties: > memory system as time progresses. All stores _before_ a write barrier > will occur _before_ all the stores after the write barrier. > > - [!] Note that write barriers should normally be paired with read or data > + [!] Note that write barriers should normally be paired with read- or address- > dependency barriers; see the "SMP barrier pairing" subsection. > > > - (2) Data dependency barriers. > + (2) Address-dependency barriers (historical). > > - A data dependency barrier is a weaker form of read barrier. In the case > + 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 result > of the first (eg: the first load retrieves the address to which the second > - load will be directed), a data dependency barrier would be required to > + load will be directed), an address-dependency barrier would be required to > make sure that the target of the second load is updated after the address > obtained by the first load is accessed. > > - A data dependency barrier is a partial ordering on interdependent loads > + An address-dependency barrier is a partial ordering on interdependent loads > only; it is not required to have any effect on stores, independent loads > or overlapping loads. I suppose this isn't really a comment on your patch, as I much prefer the updated terminology, but the way this section is now worded really makes it sounds like address dependencies only order load -> load, whereas they equally order load -> store. Saying that "An address-dependency barrier... is not required to have any effect on stores" is really confusing to me: the barrier should only ever be used in conjunction with an address-dependency _anyway_ so whether or not it's the barrier or the dependency giving the order is an implementation detail. Perhaps the barrier should be called a "Read-read-address-dependency barrier", an "Address-dependency read barrier" or even a "Consume barrier" (:p) instead? Dunno, Alan is normally much better at naming these things than I am. Alternatively, maybe we should be removing the historical stuff from the document altogether if it's no longer needed. We don't have any occurrences of read_barrier_depends() anymore, so why confuse people with it? Will