Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1901188pxb; Thu, 28 Oct 2021 12:13:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhXVSPt5bAQXQs5IkuwuYBvcTwEpq+iKeFg6pVbzSc27lEO/UgDtukRAUIRvp9QLAx3DRG X-Received: by 2002:a05:6a00:b46:b0:47b:f401:d76a with SMTP id p6-20020a056a000b4600b0047bf401d76amr6036968pfo.47.1635448384235; Thu, 28 Oct 2021 12:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635448384; cv=none; d=google.com; s=arc-20160816; b=Lj3IIBvyv3JX4CuG0MEF36vMUiX2bO2yE7zs1D916iQH03sjF3hlTmelQEOOZ9a+He gM48zvmmGeH63dk/eo27l9tmrzdCrOvH2VzV9HLSjXXuSh6Efc1W6TjcwMww8mgU+6xt EhcKUjp05W65SpR9QsqKzdp+uQDdf/2SbbR4O7Cq9SHyp7FZmciqDwtEDgD8klTHZ/nR TeRbULPh6bOSQmKL49JAhlUq2oRckCjWKqVt4aSBwaVuO2BBgIsrZt4HTxq3fo9DQXZb zGStNZSSjSj+/wzsbErz5f88II9E5A7xzlN0rhFN9WJcYR2pHDnjtxo1J1BCuEMrJa0l kO+w== 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-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=GzKoAnY+lAO2yph2MYHhtHpEGbo4za2Y4Z3yv+5skvM=; b=twUgrIqlnAfDBmgfsgF7gL0ngHmic1hEvvkYok6Q6gegiWzqwqYVtg9iNrm/zRl5Ib zt5CAiIxhLkLS3xqnPC6/9y1iuOQOln8Pv2kbsEhwkCfg0xXRTAfP5i1YKsaC52XD22F GYQtoJjHpsbtsIe6hSTr2yM0ViVJqBtR9TcDu8eCQIz+r3s0gLu6ZsSelcEpxzODmnMM hWwx6KmmXrjp3thgFgu7c04aARJJGIqknvSCkGsEm7A6y5JhSyl9KVY5J5W2hbFntXM0 85hMQomGj31oYFnagimhnFgH6yPDcc4LBk8NIlcwph5Fecdc5xKh8z84WcmgVMgaGvsR Lc3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HuMoPLFu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a189si2017249pgc.311.2021.10.28.12.12.50; Thu, 28 Oct 2021 12:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HuMoPLFu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbhJ1TN7 (ORCPT + 99 others); Thu, 28 Oct 2021 15:13:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:34738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbhJ1TN5 (ORCPT ); Thu, 28 Oct 2021 15:13:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7BA8610CA; Thu, 28 Oct 2021 19:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635448289; bh=PBuQUDyQPItfI5/5GVVGaXD+Rn5Sly4yCrQif0PrqlU=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=HuMoPLFuILwiid1xm1mrLz2zD6xlvto5BTk17vS/eL8DEAE6RXXWpMpPLwK7cuan7 nTKGEsWdYloKHMADLnBw4uzqrW7zSz+VZV732wep1gy6xEitRJPK+aFmayaddwjTkg oJxd+bLniRISMaaHM/bPRFUDRduIYZBzUD2/fgq/KE07hyOGnNT4+B5RcH52N+13oP PV7UGvq8eLWYuEAkA4lLzgYpWGYnjrTUVRri6uzdK6A6ByODKo6HVGxA88PjSqvcwU 6llKeBBaxTZgaXs8yWPA87Xnre6e3qQZgMDiaNCIVx5uS4FypTwWXJ5PArGmz2z3QF FNNcL3WgV5wjg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 288E05C04B3; Thu, 28 Oct 2021 12:11:29 -0700 (PDT) Date: Thu, 28 Oct 2021 12:11:29 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Boqun Feng , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, Dan Lustig , Will Deacon , Linus Torvalds , Alexander Shishkin , Peter Anvin , Andrea Parri , Ingo Molnar , Vince Weaver , Thomas Gleixner , Jiri Olsa , Arnaldo Carvalho de Melo , Stephane Eranian , palmer@dabbelt.com, paul.walmsley@sifive.com, mpe@ellerman.id.au, Jonathan Corbet , Alan Stern Subject: Re: [RFC v2 3/3] tools/memory-model: litmus: Add two tests for unlock(A)+lock(B) ordering Message-ID: <20211028191129.GJ880162@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20211025145416.698183-1-boqun.feng@gmail.com> <20211025145416.698183-4-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 26, 2021 at 09:01:00AM +0200, Peter Zijlstra wrote: > On Mon, Oct 25, 2021 at 10:54:16PM +0800, Boqun Feng wrote: > > diff --git a/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus b/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus > > new file mode 100644 > > index 000000000000..955b9c7cdc7f > > --- /dev/null > > +++ b/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus > > @@ -0,0 +1,33 @@ > > +C LB+unlocklockonceonce+poacquireonce > > + > > +(* > > + * Result: Never > > + * > > + * If two locked critical sections execute on the same CPU, all accesses > > + * in the first must execute before any accesses in the second, even if > > + * the critical sections are protected by different locks. > > One small nit; the above "all accesses" reads as if: > > spin_lock(s); > WRITE_ONCE(*x, 1); > spin_unlock(s); > spin_lock(t); > r1 = READ_ONCE(*y); > spin_unlock(t); > > would also work, except of course that's the one reorder allowed by TSO. I applied this series with Peter's Acked-by, and with the above comment reading as follows: +(* + * Result: Never + * + * If two locked critical sections execute on the same CPU, all accesses + * in the first must execute before any accesses in the second, even if the + * critical sections are protected by different locks. The one exception + * to this rule is that (consistent with TSO) a prior write can be reordered + * with a later read from the viewpoint of a process not holding both locks. + *) Thank you all! Thanx, Paul