Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1315612ybf; Thu, 27 Feb 2020 08:38:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyuq9wBPOo+16xdXVDYshj3Mdg5+VuptixIZvTGsAKpvU+ROK0HFzmOxfe1J/xHULhplwz1 X-Received: by 2002:aca:c515:: with SMTP id v21mr4270513oif.60.1582821523226; Thu, 27 Feb 2020 08:38:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582821523; cv=none; d=google.com; s=arc-20160816; b=BkXb2cgoh6KWc/ILQLqlwyF65pDwEvPmD7GdPk1xjGS2UyPZKZrvF3rrMcO+t98KGR e1lFCqS6wl6kJ+aSQU/sUOK4SSzePTi09JxqZ85tRZ2wLU0Y9183VtIgA9y5K6VSKM7s G4N4tGLZPfUpbRJ9ytNW4VlNXocpNX/ubDKnRa9VhWTd4iRW7cRIL9anFd/s9PHRCq/Q 4yM1J20UZkNeu0t+t/GYbIQVh1aKKgDz2RRHf3g4d+cVVTq7EgwTZyMFp3MJZc4NQGIQ HDl4exHTTFfm+Q2B6GQqm7kMDOolZH3GARuqcmA1yk49h/Bec1duZUweYWrSjI3DHG9L ZFzw== 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=p+CugC1rh+tEEEoDcWnMmqnW4xuswHgdV8eeW3CU2jg=; b=ZDjyYN51g4Im79sIxiNxo2pcbbq0Rb3N9Js0D7lEAUiqKoFeYmxFLY1ZhC5Rv9Ebgk n3Mhn/++1nBPImywDCx/wbmJvNorWHXb8H1ny99yEXgsuupB4fdW5lfRXLGsEeazeIyb s2CRvzWIRJnRUeXABAKVS25UcJKNJxEXVvYnLzZ8BCq4oDWqOdj+Ur/F9rVwmkn65r77 NE13WzArBv56Qji47ZzGdBMKnEfcyN/WsiRNJXTpr4Yv9VLaonh9HTNOLei6yxR38Pgs LYZ1awVJrs/kL55L7wiHgi4Amc9KJO2u1DljoKLBgGgBUCJDvNUFNMLtXrDzs25bT/ex lZ/w== 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 m19si1961827otq.40.2020.02.27.08.38.30; Thu, 27 Feb 2020 08:38:43 -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 S1730194AbgB0Qha (ORCPT + 99 others); Thu, 27 Feb 2020 11:37:30 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:38936 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1730046AbgB0Qha (ORCPT ); Thu, 27 Feb 2020 11:37:30 -0500 Received: (qmail 3400 invoked by uid 2102); 27 Feb 2020 11:37:29 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 27 Feb 2020 11:37:29 -0500 Date: Thu, 27 Feb 2020 11:37:29 -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 , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Greg Kroah-Hartman , Jonathan Cameron , , Subject: Re: [PATCH v3 4/5] Documentation/locking/atomic: Add a litmus test for atomic_set() In-Reply-To: <20200227004049.6853-5-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 Thu, 27 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 atomic-tests > directory to make it easily accessible for anyone who cares about the > semantics of our atomic APIs. > > Additionally, change the sentences describing the test in atomic_t.txt > with better wording. > > Signed-off-by: Boqun Feng > --- > ...c-RMW-ops-are-atomic-WRT-atomic_set.litmus | 24 +++++++++++++++++++ > Documentation/atomic-tests/README | 7 ++++++ > Documentation/atomic_t.txt | 6 ++--- > 3 files changed, 34 insertions(+), 3 deletions(-) > create mode 100644 Documentation/atomic-tests/Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus > > diff --git a/Documentation/atomic-tests/Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus b/Documentation/atomic-tests/Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus > new file mode 100644 > index 000000000000..5dd7f04e504a > --- /dev/null > +++ b/Documentation/atomic-tests/Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus > @@ -0,0 +1,24 @@ > +C Atomic-set-observable-to-RMW This line needs to match the filename. Aside from that, Acked-by: Alan Stern > + > +(* > + * Result: Never > + * > + * Test that atomic_set() cannot break the atomicity of 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/Documentation/atomic-tests/README b/Documentation/atomic-tests/README > index ae61201a4271..a1b72410b539 100644 > --- a/Documentation/atomic-tests/README > +++ b/Documentation/atomic-tests/README > @@ -2,3 +2,10 @@ This directory contains litmus tests that are typical to describe the semantics > of our atomic APIs. For more information about how to "run" a litmus test or > how to generate a kernel test module based on a litmus test, please see > tools/memory-model/README. > + > +============ > +LITMUS TESTS > +============ > + > +Atomic-RMW-ops-are-atomic-WRT-atomic_set.litmus > + Test that atomic_set() cannot break the atomicity of atomic RMWs. > diff --git a/Documentation/atomic_t.txt b/Documentation/atomic_t.txt > index ceb85ada378e..67d1d99f8589 100644 > --- a/Documentation/atomic_t.txt > +++ b/Documentation/atomic_t.txt > @@ -85,10 +85,10 @@ smp_store_release() respectively. Therefore, if you find yourself only using > the Non-RMW operations of atomic_t, you do not in fact need atomic_t at all > and are doing it wrong. > > -A subtle detail of atomic_set{}() is that it should be observable to the RMW > -ops. That is: > +A note for the implementation of atomic_set{}() is that it must not break the > +atomicity of the RMW ops. That is: > > - C atomic-set > + C Atomic-RMW-ops-are-atomic-WRT-atomic_set > > { > atomic_t v = ATOMIC_INIT(1); >