Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp778792rwe; Fri, 26 Aug 2022 14:29:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ZnnGUrMiiaVgvsLkmAsGJ8vvwVItyBmD6jIFY4LU2sKwVN3Nk5HuRBlZHqWJWpteydmNM X-Received: by 2002:a17:90b:1c8f:b0:1fb:9d43:8ecf with SMTP id oo15-20020a17090b1c8f00b001fb9d438ecfmr6552421pjb.160.1661549376106; Fri, 26 Aug 2022 14:29:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661549376; cv=none; d=google.com; s=arc-20160816; b=xDv39J+NRr82bHAsv/MBDCON2nhJCMsClDo9G/SkVdQrdQfrm6/MRhS78eaXHur45r c9K/x4mY3kF3IgP/2dR1OO+BvboNh8Vh+s5LhnFCaT1roc1h+lKs1Em2KJINblVktY4u 9UqA44pWyPcwmSW3Ifn9NNaNuqo0kw0URoMz7sfD12KXnSrCVt9q+LdVycSlIR22RTgI qekM/z2+gmVuKpdmlyU59xk97VBHeWCoYPBZkFQiqgqBn8670NMw9qk0PPpctZOcuyn/ nUBq3EustWMPYi/QFQ/pupTljDL3/ut0iRrKdfpDvCTGpPDkO8tnPCp4vLhWd0Q67I6j BzVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=L6s2VWaBZ4UYqejIaxDxjpLja6FHb6m0w1GlAfe7mCc=; b=oCJ7LWo1Kn48tjs7tUbXUWHSIH0sQFswDCsQI5uw8z4HCmaQfnWs3yIKGsPuikznWP Z24D1JZV6T9X6cS+u2wG4sxT2Lwu8GFmvjghM4Q9xY75NDc0BstFuZeB17cs+KZ28YzC HEwWQtxHxGw0k0DQQbEiTcZJucE2vYnQUCBT1lCnbv9jVCrscmTCpPssuo1iqspCW94Q 7T8izowQW3Zg/Atj9a+nZIJk5ep+LEtk2C6D2mmSvdar+mL4NqK2cFLE1xDlPVRN4ZkH aCJVek7FP/B1bSDmB+kzPXxSb0fr5JLvfDIGSkMViT60sm0WYOX9fGWhiwR7pVYd6/rI vVPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WzvjOA2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r68-20020a632b47000000b00419f8572858si2602720pgr.755.2022.08.26.14.29.23; Fri, 26 Aug 2022 14:29:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WzvjOA2N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344957AbiHZUmZ (ORCPT + 99 others); Fri, 26 Aug 2022 16:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344593AbiHZUmY (ORCPT ); Fri, 26 Aug 2022 16:42:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB8D9DAEE0; Fri, 26 Aug 2022 13:42:22 -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 ams.source.kernel.org (Postfix) with ESMTPS id 9C66CB83221; Fri, 26 Aug 2022 20:42:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C7C0C433D6; Fri, 26 Aug 2022 20:42:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661546540; bh=5QuSkUmaKWexF2MmBKhwt0FWI8W3Sck/sz2XxbNZMc8=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=WzvjOA2NbQiRFl3tV5Hlw0izO0TQVlYe1Kdn+Q3QuKfVRpHvXSjxScso3z0BroCY0 8kLIq520S8hTl2fKqUozFY533FRmWi1HQpCAipF2dAS87GCxeF0VbHvlAFyEjFUFsn wFhT38ILizUz5jrfjvtojmaxrvqlMl0fGQ0A1JXfU9oLCjBiVupxYvc9ixdNg18Tm9 8gx1COwQlWgzU8ZQnfxp4mvkRzPwuKX3TZsfmaodQIsoL4dGV098iz9XS8S9CuXEd9 434AGO+dQZ0XQgvC2flEsTovlzhAbZG3o3b9VjAEvqUuAXi2HhQJMVFGCxhVb0XI7A hGavGChrL2G/Q== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B86085C03F3; Fri, 26 Aug 2022 13:42:19 -0700 (PDT) Date: Fri, 26 Aug 2022 13:42:19 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: Peter Zijlstra , parri.andrea@gmail.com, will@kernel.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org, 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: <20220826204219.GX6159@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220826124812.GA3007435@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Fri, Aug 26, 2022 at 01:10:39PM -0400, Alan Stern wrote: > On Fri, Aug 26, 2022 at 06:23:24PM +0200, Peter Zijlstra wrote: > > On Fri, Aug 26, 2022 at 05:48:12AM -0700, Paul E. McKenney wrote: > > > Hello! > > > > > > I have not yet done more than glance at this one, but figured I should > > > send it along sooner rather than later. > > > > > > "Verifying and Optimizing Compact NUMA-Aware Locks on Weak > > > Memory Models", Antonio Paolillo, Hern?n Ponce-de-Le?n, Thomas > > > Haas, Diogo Behrens, Rafael Chehab, Ming Fu, and Roland Meyer. > > > https://arxiv.org/abs/2111.15240 > > > > > > The claim is that the queued spinlocks implementation with CNA violates > > > LKMM but actually works on all architectures having a formal hardware > > > memory model. > > > > > > Thoughts? > > > > So the paper mentions the following defects: > > > > - LKMM doesn't carry a release-acquire chain across a relaxed op > > That's right, although I'm not so sure this should be considered a > defect... > > > - some babbling about a missing propagation -- ISTR Linux if stuffed > > full of them, specifically we require stores to auto propagate > > without help from barriers > > Not a missing propagation; a late one. > > Don't understand what you mean by "auto propagate without help from > barriers". > > > - some handoff that is CNA specific and I've not looked too hard at > > presently. > > > > > > I think we should address that first one in LKMM, it seems very weird to > > me a RmW would break the chain like that. > > An explicitly relaxed RMW (atomic_cmpxchg_relaxed(), to be precise). > > If the authors wanted to keep the release-acquire chain intact, why not > use a cmpxchg version that has release semantics instead of going out of > their way to use a relaxed version? > > To put it another way, RMW accesses and release-acquire accesses are > unrelated concepts. You can have one without the other (in principle, > anyway). So a relaxed RMW is just as capable of breaking a > release-acquire chain as any other relaxed operation is. > > > Is there actual hardware that > > doesn't behave? > > Not as far as I know, although that isn't very far. Certainly an > other-multicopy-atomic architecture would make the litmus test succeed. > But the LKMM does not require other-multicopy-atomicity. My first attempt with ppcmem suggests that powerpc does -not- behave this way. But that surprises me, just on general principles. Most likely I blew the litmus test shown below. Thoughts? Thanx, Paul ------------------------------------------------------------------------ PPC MP+lwsyncs+atomic "LwSyncdWW Rfe LwSyncdRR Fre" Cycle=Rfe LwSyncdRR Fre LwSyncdWW { 0:r2=x; 0:r4=y; 1:r2=y; 1:r5=2; 2:r2=y; 2:r4=x; } P0 | P1 | P2 ; li r1,1 | lwarx r1,r0,r2 | lwz r1,0(r2) ; stw r1,0(r2) | stwcx. r5,r0,r2 | lwsync ; lwsync | | lwz r3,0(r4) ; li r3,1 | | ; stw r3,0(r4) | | ; exists (1:r1=1 /\ 2:r1=2 /\ 2:r3=0) ------------------------------------------------------------------------ $ ./ppcmem -model lwsync_read_block -model coherence_points MP+lwsyncs+atomic.litmus ... Test MP+lwsyncs+atomic Allowed States 9 1:r1=0; 2:r1=0; 2:r3=0; 1:r1=0; 2:r1=0; 2:r3=1; 1:r1=0; 2:r1=1; 2:r3=1; 1:r1=0; 2:r1=2; 2:r3=0; 1:r1=0; 2:r1=2; 2:r3=1; 1:r1=1; 2:r1=0; 2:r3=0; 1:r1=1; 2:r1=0; 2:r3=1; 1:r1=1; 2:r1=1; 2:r3=1; 1:r1=1; 2:r1=2; 2:r3=1; No (allowed not found) Condition exists (1:r1=1 /\ 2:r1=2 /\ 2:r3=0) Hash=b7cec0e2ecbd1cb68fe500d6fe362f9c Observation MP+lwsyncs+atomic Never 0 9