Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2285693iof; Wed, 8 Jun 2022 01:26:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWDrRD4SCGRH1PyxTPcyRZBT8/Up502AXUDjxCGa7YqXYWa+pnxfPlSOb08+cz0koOV98a X-Received: by 2002:a17:90a:c90d:b0:1e2:c96b:5337 with SMTP id v13-20020a17090ac90d00b001e2c96b5337mr58852966pjt.42.1654676789672; Wed, 08 Jun 2022 01:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676789; cv=none; d=google.com; s=arc-20160816; b=Jh50KlZj74UvCPTm76Hc72KR+fwNQMb778lSNb1OfBXpo0DdrUvchIJzo1Z74DE6D3 hM2mFGgVaYY3asN6u8hnsQXkpRbIuFqMIQiXzFqn0rE7mtGLeTeiOVuUIs1g5dKIRMbY OOsHbRiteoiz6YPZgcJLhCWrI5d10hb8MjhmOIVU7LsQrABLvr6IBBf5CtdnbHvzG0kS RXnclNf1v81Y9Za+9xHRpVAGg6rcW3syjSwtP5OE5cZ/ionR2RRQPo6lDETZXGMmcaku QdZKaSKK/5eplO9fPZGX5+cq3JRPSakA1wdnIWMpaGKMvbh24UQChxuguyD5+QOg3RNk 8NKA== 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=qeGk0uHM1MEBKnnaIOerMEbRB5WBgqbjWAmmj8SYnio=; b=xTeQhHUa5ZQmrinf6l4Pkw7xrDAJuLQDZF0UVM6oAplDsLx9+J/vljq1g8C3Fukz2O 19ZaemP8SZL1SjX7unjY6lqjOXq+NCXPmTc7JHNz81zrSdYzYbwsn5OvNYX6eUiIQgye izcP1Jkuq+i7/TdgqrXVxh6zZZ3rkxFeVcN6ugLqro9IaMiye7bQThV6HmwpgZYe7lyv mdmH8553kP1t0DJcFJsMXTvNmWLA4f1BPqc27pK33FBlqd627WKy5zRycmTIpv85+guA 5gmsIQNYFcyu4D4Gr3vZyYiHMbFwioIF52gv78pHawceGsLOrgxCDNNlYVP9uxg6Z2Vk 1O3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=C0oG22Cu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 125-20020a630283000000b003fcc8ec5d62si24078379pgc.275.2022.06.08.01.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:26:29 -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=@gmail.com header.s=20210112 header.b=C0oG22Cu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18D2C38DBF; Wed, 8 Jun 2022 00:56:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233231AbiFHFFZ (ORCPT + 99 others); Wed, 8 Jun 2022 01:05:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234121AbiFHFEc (ORCPT ); Wed, 8 Jun 2022 01:04:32 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BA93221899; Tue, 7 Jun 2022 19:00:53 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id f9so5912645plg.0; Tue, 07 Jun 2022 19:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=qeGk0uHM1MEBKnnaIOerMEbRB5WBgqbjWAmmj8SYnio=; b=C0oG22CuP15MdIWo7qMhyoFFD5M6fPB0LwZW9YWE5m2ze1PXDgSFhrc7MIjieiUT4/ JjXtWgPkXYyDeElLjn40R+rZUhphkM0gPnh6VlZSBIxTEBciQcRkSobiBD2qWA8QQQv+ uwXb9VyiI01NVt+iXGh+mlJcxZCJQMkPaCA0iYLlXS+R5f7v5mHCPIm+PPalRSKp5jj9 WAM+B+3bt4q3WpMxKoiJKYDDFRCZasU2dvC66/X04ut4PQcwfOzyE2B1hPrYeBP2+9lp EZ8rqITL1wJcSbZ3IDa2VdCbck3W3Mnc1js6jaLgzSAyRJEW2NuqrcVACoZzh7f9nijK j8rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=qeGk0uHM1MEBKnnaIOerMEbRB5WBgqbjWAmmj8SYnio=; b=lzjqfG4R4hiHyf7Dkf6ruD5FpQgwDSRjubISNfEQmRu0IjKOrtH30p2VixqDn4BtP2 8XwDn9irqOK6Y9OQ0fP/8WaN4hN6Nv/UGzvsluonS2OJeRjvEZtZGlU6LBHRJpEqkJFI Awc5ZH9PtAXBSd2fYZ+N/2U/fOQLOfosg3E4KDzReh+izThBtZukcnjoGpPonod6PIjz eRJV1SqXVRatnB6kHdUFx5g7C53lcjaerPexSF4OorljeneCUk4FUeBk4f4QaRT3SGOV nLNIeWc+BSbya9IAWvb2YHWc4gnzBdWRNFbVo7zvVMz9RoF8QB2h8AJxHR7xN6qSl3aO yYQw== X-Gm-Message-State: AOAM531N0JUVJCowcHBs3+6i8+UVKLt4iXz8vf1odqUKyqKx9O6WogEC ElGoXXV1+B/BhaY7I2KcvII= X-Received: by 2002:a17:902:b689:b0:167:8b69:d1a7 with SMTP id c9-20020a170902b68900b001678b69d1a7mr8744102pls.156.1654653652768; Tue, 07 Jun 2022 19:00:52 -0700 (PDT) Received: from [192.168.11.5] (KD106167171201.ppp-bb.dion.ne.jp. [106.167.171.201]) by smtp.gmail.com with ESMTPSA id n36-20020a635924000000b003faebbb772esm14154869pgb.25.2022.06.07.19.00.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 07 Jun 2022 19:00:52 -0700 (PDT) Message-ID: Date: Wed, 8 Jun 2022 11:00:46 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC PATCH -lkmm] docs/memory-barriers: Fix inconsistent name of 'data dependency barrier' Content-Language: en-US To: Alan Stern , Will Deacon Cc: "Paul E. McKenney" , "Michael S. Tsirkin" , 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, Akira Yokosawa References: <20220607133432.GA32701@willie-the-truck> From: Akira Yokosawa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 Thank you Alan and Will for your comments! On Tue, 7 Jun 2022 10:34:08 -0400, Alan Stern wrote: > On Tue, Jun 07, 2022 at 02:34:33PM +0100, Will Deacon wrote: >> 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. > >> 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. I tried to address this in one of the hunk: +[!] The title of this section was renamed from "DATA DEPENDENCY BARRIERS" +to prevent developer confusion as "data dependencies" usually refers to +load-to-store data dependencies. +While address dependencies are observed in both load-to-load and load-to- +store relations, address-dependency barriers concern only load-to-load +situations. I'd appreciate if you could come up with some improvement here for a non-RFC v1 patch in a week or so. >> 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. > > It would be more accurate to say that address-dependency barriers are > not _needed_ for load->store ordering because the dependencies > themselves already provide this ordering (even on Alpha). > >> 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. > > Well, "load-load-address-dependency barrier" would be okay as a generic > name, albeit unwieldy. Note however that on Alpha -- the only > architecture to need these barriers -- they aren't anything special; the > actual instruction is the equivalent of an ordinary smp_rmb(). (Please > correct me if my memory about this is wrong.) > > So in principle you could simply call them "read memory barriers" while > pointing out the need for special use on demented architectures where > address dependencies do not guarantee load->load ordering. > >> 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? > > How about relegating discussion of these barriers to a special > "historical" or "niche architecture" section of the document? In a > separate patch, of course. Another option would be to add a section on "Ordering guarantees by dependencies", and explain three variants: address, data, and control. We have only "control dependencies" section at the moment and uses "data dependency" without properly defining it. Address dependencies are special in that they can provide load-to-load ordering guarantees as well as those of load-to-store. Alpha doesn't provide these guarantees at the architecture level, hence the implicit address-dependency barrier in READ_ONCE(). Also, IIUC, arm64's READ_ONCE() is promoted to acquire-load when LTO is enabled. It is to cope with the possible (but not observed yet) transformation of address dependencies into control dependencies, which can't provide load-to-load ordering guarantees. These points can be added later in memory-barriers.txt, but I'm afraid I might not be up to such involved changes. Thanks, Akira > > Alan > >