Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1892458ybv; Fri, 14 Feb 2020 07:49:05 -0800 (PST) X-Google-Smtp-Source: APXvYqx6wI0NbjbE9yraf9/7zQwugxhIZTLuhrfluyQEKaHcFDxmKb4xI6hq5TfqW71Wg8BorUNB X-Received: by 2002:aca:ebc3:: with SMTP id j186mr2231085oih.15.1581695345555; Fri, 14 Feb 2020 07:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581695345; cv=none; d=google.com; s=arc-20160816; b=esSjZc/5FReEwszJKP4rL4rgziq7dSkvLkhlh5F2p1NsXRS8fNmlRrh3a8Nu2QaaeS YIi0k5sLXPoAmN/i0l07QGUsnPlNUmr38AAH+t8aCS7QflBzg1DoZ2H3LPC8xIUb4OUa W17qA3g/TVf25OzaVqWVNNX9K84wtHsvycDH+4fYOCwZdyKqoYjKqaa8Ptm9wvnkmPew qbke2UoIzzjjH0xVweAewM77MZfCt3k5W0MgPgTwaSoJSobcoYMGrqneSgSB8xinJCQX /xr4LKjh3gJbLYM3fkr/Z47QDm3138PWHFPgWrm6HjXvqcxwQ1Y7w0IC3A18ASfat+Wj FKYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=5pIqfilDUzalN+LKiebIDKysyYzj7oFpp4d/Ty2AAHk=; b=nJPy6QvcPGIYwnL2CWS/jh6SdOBbC82VimPx/ZlWuCymy27epOXEQ0OazgnJtDmg3L aP6oFH81ZJUIvviBHzLhvlXvrnr0GsWvGVC0UBNJAcls1pOQaODkzcVXC5Hgj2sYe2KJ bVW31kdTzTN/96pAjtjBScZHhoW5brSLxcitWLLyJgAVyuj40iD9EldVWpKfOGQ7PTKt DGgLlCT93QXovstjOZqanMu8B0YBGp9OmvgP7TKoOOj9+P1qohBKvCIylcElmJAxfr6A G4GRsHUUo0P8JOTFoGgAXLYoGrcb1OMVJSxHruBElnIjEKTLkq1Suu81QUyiW3/Cr6BB myqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d22si3026708oti.316.2020.02.14.07.48.53; Fri, 14 Feb 2020 07:49:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729258AbgBNPru (ORCPT + 99 others); Fri, 14 Feb 2020 10:47:50 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:39786 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728911AbgBNPrt (ORCPT ); Fri, 14 Feb 2020 10:47:49 -0500 Received: (qmail 3175 invoked by uid 2102); 14 Feb 2020 10:47:48 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 14 Feb 2020 10:47:48 -0500 Date: Fri, 14 Feb 2020 10:47:48 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Boqun Feng cc: linux-kernel@vger.kernel.org, Andrea Parri , Will Deacon , Peter Zijlstra , Nicholas Piggin , David Howells , Jade Alglave , Luc Maranget , "Paul E. McKenney" , Akira Yokosawa , Daniel Lustig , Jonathan Corbet , , Subject: Re: [RFC 2/3] tools/memory-model: Add a litmus test for atomic_set() In-Reply-To: <20200214040132.91934-3-boqun.feng@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Feb 2020, Boqun Feng wrote: > We already use a litmus test in atomic_t.txt to describe the behavior of > an atomic_set() with the an atomic RMW, so add it into the litmus-tests > directory to make it easily accessible for anyone who cares about the > semantics of our atomic APIs. > > Signed-off-by: Boqun Feng > --- > .../Atomic-set-observable-to-RMW.litmus | 24 +++++++++++++++++++ > tools/memory-model/litmus-tests/README | 3 +++ > 2 files changed, 27 insertions(+) > create mode 100644 tools/memory-model/litmus-tests/Atomic-set-observable-to-RMW.litmus I don't like that name, or the corresponding sentence in atomic_t.txt: A subtle detail of atomic_set{}() is that it should be observable to the RMW ops. "Observable" doesn't get the point across -- the point being that the atomic RMW ops have to be _atomic_ with respect to all atomic store operations, including atomic_set. Suggestion: Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus, with corresponding changes to the comment in the litmus test and the entry in README. Alan > diff --git a/tools/memory-model/litmus-tests/Atomic-set-observable-to-RMW.litmus b/tools/memory-model/litmus-tests/Atomic-set-observable-to-RMW.litmus > new file mode 100644 > index 000000000000..4326f56f2c1a > --- /dev/null > +++ b/tools/memory-model/litmus-tests/Atomic-set-observable-to-RMW.litmus > @@ -0,0 +1,24 @@ > +C Atomic-set-observable-to-RMW > + > +(* > + * Result: Never > + * > + * Test of the result of atomic_set() must be observable to atomic RMWs. > + *) > + > +{ > + atomic_t v = ATOMIC_INIT(1); > +} > + > +P0(atomic_t *v) > +{ > + (void)atomic_add_unless(v,1,0); > +} > + > +P1(atomic_t *v) > +{ > + atomic_set(v, 0); > +} > + > +exists > +(v=2) > diff --git a/tools/memory-model/litmus-tests/README b/tools/memory-model/litmus-tests/README > index 681f9067fa9e..81eeacebd160 100644 > --- a/tools/memory-model/litmus-tests/README > +++ b/tools/memory-model/litmus-tests/README > @@ -2,6 +2,9 @@ > LITMUS TESTS > ============ > > +Atomic-set-observable-to-RMW.litmus > + Test of the result of atomic_set() must be observable to atomic RMWs. > + > CoRR+poonceonce+Once.litmus > Test of read-read coherence, that is, whether or not two > successive reads from the same variable are ordered. >