Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp549439rwe; Fri, 26 Aug 2022 09:38:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR7++UagHMiDHyx3e4GIrJnOKgXOaLQitPhFcryGcKw9krwmRfUNe3cEQ0AxiBD0S+cX3Jek X-Received: by 2002:a17:906:3bd2:b0:731:3f03:1697 with SMTP id v18-20020a1709063bd200b007313f031697mr6186845ejf.289.1661531900343; Fri, 26 Aug 2022 09:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661531900; cv=none; d=google.com; s=arc-20160816; b=Z4KAu30eVw0lGsGfZ3G/bkPu5FcUPFvi6j9g6eC5ASG5nw8DGU/JWOstHJHjuKLkgA RDsKjF3YxtuSfQEPuB2Xuj+HB82equ9Gn7msyxI7jwomqUvb/+R6FRKgRlwAgqCavR0q iVHuy54zfQUnh1TNPfiUaiKzfzg65VUlEA7xmzx8co79WKYJLGHyQl77RSo8KzGq9BQA uE+Yhu2O7SSXQcVRA6Ki29gVKY77oWbxuSTUrPzM5UgTw8zk2I5Srr3L5ivI6yujDiq2 kjjUfjNz97Na3FT6r5XvKCyGHzURudoErpxUQguPtvY2OqdNsG6Sn+VjWzrBeHmNUAWn EzRw== 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:message-id:subject:cc :to:from:date:feedback-id:dkim-signature; bh=VncAiJs3fU8NB8r44n3zEWCd5Faxj89/Rf22hgTlUOo=; b=DM355G6NNcs8+vI+lPttxVh7roSKcohJbwZ85srWMpiU3olK8jO98IuWAQ9d2BWO5u x9FH6Ksg2p34wl4ZPt9R6aZhsSf0pMVFuQxH++l+viEv7QiIenIM787wCNTX9x2pg9sl kkMcje+V/XJdL9RFLpi5bctV+m/uUE+RICKhOcKv3MKj/+PEMweRCbOw/XQ4FYZcOcj+ 9RxSZD4a6j+47np/2GLKwZM1xqpPC6WO/iy6mGQ/vC/iJpYWOwyVgHzK62WaUKPNo8zb gViz5poEkxysVWUzgMQ28AS/Q9nJzDNBo3l329v7RjJ03kZxACSq6mn/sv7vjzcOjE7x Xq5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GdcFrVcX; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs6-20020a1709072d0600b0073da4a0f01csi1921575ejc.743.2022.08.26.09.37.54; Fri, 26 Aug 2022 09:38:20 -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=@gmail.com header.s=20210112 header.b=GdcFrVcX; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344712AbiHZQWF (ORCPT + 99 others); Fri, 26 Aug 2022 12:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344718AbiHZQVy (ORCPT ); Fri, 26 Aug 2022 12:21:54 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B9E3DDB46; Fri, 26 Aug 2022 09:21:50 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id c20so1605410qtw.8; Fri, 26 Aug 2022 09:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:from:to:cc; bh=VncAiJs3fU8NB8r44n3zEWCd5Faxj89/Rf22hgTlUOo=; b=GdcFrVcX0tHzJNMmPnJBh29Eu8eXvtnc/nk0jaZpfSm8VtTybgkKuR6+zFcXkJT1uc mzsIyw8/Z/hOswnVNh6XLU3zkJpWiFHedDEKZnwtw4H3XH4d400iYNiclA1P4Agy3X0v ymEyP0Afa5ZNttzFwaz2EH4gB6RqRQ1EQkWDtQGAxoLASAvcVomWoFLBT+R/R8cCJNVp 9LweW/FnJ0tkG+1s1ZjVdLJUYRNVFbfrHNjsG9QoX/EUEUHYhwIt8H6BrGCLH36trmHi DsWeFMYMALbfQQuE7SxzO+H2DcLTEjJk0TEDN+ivnH+xhmQkWJU8k1rWK9r9Ppmf0Tlm 69ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:x-gm-message-state:from:to:cc; bh=VncAiJs3fU8NB8r44n3zEWCd5Faxj89/Rf22hgTlUOo=; b=WXPDLzlg7CKYDp4Tg/rFBxNxvJazh6nUt2q9WxSPb7s5XcBkjFhppNKbI/6dMGWRiW M6aG7rs2BAvtE4Nndd7aeDV9Jr0g2FE4jk3oEQCiQUv6Yj9EHgiPAPPmZMiCbbyWLLcL wAACNvN9Zl4NW+bi17C+hkF/OHi//NnChxyhYp+OPQilCpuEW9n55cJOic/TEd+LAC70 W38mUd/Pd5dfaHeVVwfXh8b3P1wMhqEgYsdsPdxTzWhVMCP+y/k0J8qKWBLfwvcNwNA0 9oEIQnaqVnR9hl6dAA274JgRQX3gZB23TIUFrMhZGUspNtK1r9YLEAzZ7Z4QroMNfNbP bPvA== X-Gm-Message-State: ACgBeo1ujj462yNFoXkiUMt4GkiaI2HrajrkmsBEhAJpy4DkikCphYZ0 raBCjaT4crHXC5iyWkWlpFw= X-Received: by 2002:ac8:5a4b:0:b0:344:92b0:9d88 with SMTP id o11-20020ac85a4b000000b0034492b09d88mr440238qta.284.1661530909785; Fri, 26 Aug 2022 09:21:49 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id i13-20020a05620a248d00b006baed8f3a2esm15640qkn.103.2022.08.26.09.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 09:21:49 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailauth.nyi.internal (Postfix) with ESMTP id A28F027C005A; Fri, 26 Aug 2022 12:21:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 26 Aug 2022 12:21:48 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdejhedgleelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtkeertddttddunecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhepleeggfehieeggfevveeuvdfgledtkeethedvveejffdugfevtdevudej heeljedtnecuffhomhgrihhnpegrrhigihhvrdhorhhgpdhgihhthhhusgdrtghomhenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhn odhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejje ekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihigmhgvrdhn rghmvg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 26 Aug 2022 12:21:47 -0400 (EDT) Date: Fri, 26 Aug 2022 09:21:03 -0700 From: Boqun Feng To: "Paul E. McKenney" Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com, will@kernel.org, peterz@infradead.org, 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: 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: <20220826124812.GA3007435@paulmck-ThinkPad-P17-Gen-1> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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. > Translate one of their litmus test into a runnable one (there is a typo in it): C queued-spin-lock (* * P0 is lock-release * P1 is xchg_tail() * P2 is lock-acquire *) {} P0(int *x, atomic_t *l) { WRITE_ONCE(*x, 1); atomic_set_release(l, 1); } P1(int *x, atomic_t *l) { int val; int new; int old; val = atomic_read(l); new = val + 2; old = atomic_cmpxchg_relaxed(l, val, new); } P2(int *x, atomic_t *l) { int r0 = atomic_read_acquire(l); int r1 = READ_ONCE(*x); } exists (2:r0=3 /\ 2:r1=0) According to LKMM, the exist-clause could be triggered because: po-rel; coe: rfe; acq-po is not happen-before in LKMM. Alan actually explain why at a response to a GitHub issue: https://github.com/paulmckrcu/litmus/issues/11#issuecomment-1115235860 (Paste Alan's reply) """ As for why the LKMM doesn't require ordering for this test... I do not believe this is related to 2+2W. Think instead in terms of the LKMM's operational model: The store-release in P0 means that the x=1 write will propagate to each CPU before the y=1 write does. Since y=3 at the end, we know that y=1 (and hence x=1 too) propagates to P1 before the addition occurs. And we know that y=3 propagates to P2 before the load-acquire executes. But we _don't_ know that either y=1 or x=1 propagates to P2 before y=3 does! If the store in P1 were a store-release then this would have to be true (as you saw in your tests), but it isn't. In other words, the litmus test could execute with the following temporal ordering: P0 P1 P2 ---------- --------- ---------- Write x=1 Write y=1 [x=1 and y=1 propagate to P1] Read y=1 Write y=3 [y=3 propagates to P2] Read y=3 Read x=0 [x=1 and y=1 propagate to P2] (Note that when y=1 propagates to P2, it doesn't do anything because it won't overwrite the coherence-later store y=3.) It may be true that none of the architectures supported by Linux will allow this outcome for the test (although I suspect that the PPC-weird version _would_ be allowed if you fixed it). At any rate, disallowing this result in the memory model would probably require more effort than would be worthwhile. Alan """ The question is that whether we "fix" LKMM because of this, or we mention explicitly this is something "unsupported" by LKMM yet? Regards, Boqun > Thoughts? > > Thanx, Paul