From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 591E7ECAAA1 for ; Mon, 12 Sep 2022 12:02:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbiILMCJ (ORCPT ); Mon, 12 Sep 2022 08:02:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229901AbiILMB2 (ORCPT ); Mon, 12 Sep 2022 08:01:28 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id D37322ED7C for ; Mon, 12 Sep 2022 05:01:05 -0700 (PDT) Received: (qmail 565827 invoked by uid 1000); 12 Sep 2022 08:01:03 -0400 Date: Mon, 12 Sep 2022 08:01:03 -0400 From: Alan Stern To: Jonas Oberhauser Cc: Joel Fernandes , Hernan Luis Ponce de Leon , Boqun Feng , Peter Zijlstra , "Paul E. McKenney" , "parri.andrea@gmail.com" , "will@kernel.org" , "npiggin@gmail.com" , "dhowells@redhat.com" , "j.alglave@ucl.ac.uk" , "luc.maranget@inria.fr" , "akiyks@gmail.com" , "dlustig@nvidia.com" , "linux-kernel@vger.kernel.org" , "linux-arch@vger.kernel.org" Subject: Re: "Verifying and Optimizing Compact NUMA-Aware Locks on Weak Memory Models" Message-ID: References: <674d0fda790d4650899e2fcf43894053@huawei.com> <34735a476c3b4913985de3403a6216bd@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <34735a476c3b4913985de3403a6216bd@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 12, 2022 at 10:13:33AM +0000, Jonas Oberhauser wrote: > As I tried to explain before, this problem has nothing to do with > stores propagating within a given time to another core. Rather it is > due to two stores to the same location happening in a surprising > order. I.e., both stores propagate quickly to other cores, but in a > surprising coherence order.And if a wmb in the code is replaced by an > mb, then this co will create a pb cycle and become forbidden. > > Therefore this hang should be observable on a hypothetical LKMM > processor which makes use of all the relaxed liberty the LKMM allows. > However according to the authors of that paper (who are my colleagues > but I haven't been involved deeply in that work), not even Power+gcc > allow this reordering to happen, and if that's true it is probably > because the wmb is mapped to lwsync which is fully cumulative in Power > but not in LKMM. Yes, that's right. On ARM64 architectures the reordering is forbidden by other multi-copy atomicity, and on PPC is it forbidden by B-cumulativity (neither of which is part of the LKMM). If I'm not mistaken, another way to forbid it is to replace one of the relaxed atomic accesses with an atomic access having release semantics. Perhaps this change will find its way into the kernel source, since it has less overhead than replacing wmb with bm. Alan