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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59083C4332F for ; Tue, 26 Oct 2021 07:01:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4108E610A1 for ; Tue, 26 Oct 2021 07:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234542AbhJZHEA (ORCPT ); Tue, 26 Oct 2021 03:04:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbhJZHD6 (ORCPT ); Tue, 26 Oct 2021 03:03:58 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C789AC061745; Tue, 26 Oct 2021 00:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mDE+nIrUEwp9gdh7csFA4RkAg6IIsjAzd6M9miIHAew=; b=jg8Yj9hGaOgTZKFKecfny9To3N VjgU+bk075mGrzLbby/E/7eVQjjzC7zUWiC8BTQcjnh3pcXwhVWR+cFpcvqNVOB0gp2MQD+OW6ryg Bkc9ZwdWba8opu2f5VOMDhJB8PvoUIbTAHLuAGMca9YdrzJseFymGJnMP2jmzf/fZzGFwaIRj+em4 wrH1q6AQNTz7O+tqUIYy/1idVnKnQ8F8CU5CMQxOKhp36yDhyPhvpbKuPoFcCd3PzjKC2IX90M41i w+oPAKmNEV8PVITFgv4bBpDqh7tcROWUyIeOfr2CIcZ+iTlrRuQNCAr4bnSheFspHTLcGKlXynw/a 0zMbtgAA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfGSF-00CJJG-1l; Tue, 26 Oct 2021 07:01:03 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E38AB3001BF; Tue, 26 Oct 2021 09:01:00 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id BE0FF2D80369F; Tue, 26 Oct 2021 09:01:00 +0200 (CEST) Date: Tue, 26 Oct 2021 09:01:00 +0200 From: Peter Zijlstra To: Boqun Feng Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, "Paul E . McKenney " , 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: 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: <20211025145416.698183-4-boqun.feng@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + *) > + > +{} > + > +P0(spinlock_t *s, spinlock_t *t, int *x, int *y) > +{ > + int r1; > + > + spin_lock(s); > + r1 = READ_ONCE(*x); > + spin_unlock(s); > + spin_lock(t); > + WRITE_ONCE(*y, 1); > + spin_unlock(t); > +} > + > +P1(int *x, int *y) > +{ > + int r2; > + > + r2 = smp_load_acquire(y); > + WRITE_ONCE(*x, 1); > +} > + > +exists (0:r1=1 /\ 1:r2=1)