Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1373538ybf; Thu, 27 Feb 2020 09:43:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyTquLoHI0dOfECDoQyfdBGDRfcxfGgsxwwrQwNoXTeAxYarJQqiui7iFRTviK0xBRFXxkV X-Received: by 2002:a54:4085:: with SMTP id i5mr137089oii.17.1582825413481; Thu, 27 Feb 2020 09:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582825413; cv=none; d=google.com; s=arc-20160816; b=Rd+cKbNx7eT7ymd/lC+nMbdn2lM+vebqweX8W/bH3mDodHLnpjH4phz2iETsc44SvJ IOc/rzc+iv4SM9Spn1MOZKgfYfcIAOug3o1Stw+jlcf+TFVTGCSUqHx3Wa06QzhvR2/q Oz7zhqAY3fqDvxsHLevKmq5xqJ0qew5qgnXOzvKA/lrilYKk7+RCtwowPp81s/GTabPp LqLy/wP/uMppfO/TtJlbVIxGKCHbZD51VhmIFl50os7B6pmiVLa+YrGrepWVP81G1Mwx LqW09J3QJlNodYqnVwOZA/IJj5w6XImlq8oY/hDjWOiNMlH2vEmo8FW75OTCOma49xO6 RFqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=BMqi7wNVy74Epfw3/CXCjxssZh8rP45fbaF8FqplbtM=; b=jQKWUG4d4KyEBS+7WRN5eLD8Pz6B39e0A3638/D0UADaHVoQok8bO+WHkByRuyvrT6 SXzHLfMcAkE5qhRm3qI5z8OnI2n9f8JmJ6qUfAznFq4z5uu7VJpWzxlP6bpWGhqAOS9W 4HKg2pCzukquaqIFEY/H+OM5dPca4UcVNF81j0RbZ0Ng2IJ+XoCpPW5ldoZ5Bxy8eZNz uIb7Cj0PwkvySZLmfZDx52fKbFKxqvX/Leh6HIBWIS4ijpy+8ASx4lzBiKuz2nV/hT5x CTsYyoJMobH43hJrYdTs24e6FUUVWBVS+H4cu8VTpaFpb2JOzYqR8dvwWGhLnNfg7dXl iTYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TSB4IyoU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18si3160724ots.317.2020.02.27.09.43.20; Thu, 27 Feb 2020 09:43:33 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TSB4IyoU; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730407AbgB0RnO (ORCPT + 99 others); Thu, 27 Feb 2020 12:43:14 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33920 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729548AbgB0RnO (ORCPT ); Thu, 27 Feb 2020 12:43:14 -0500 Received: by mail-wr1-f66.google.com with SMTP id z15so4539625wrl.1; Thu, 27 Feb 2020 09:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BMqi7wNVy74Epfw3/CXCjxssZh8rP45fbaF8FqplbtM=; b=TSB4IyoUJM+7SNxWfQHNWp8SqiXLs/3NwcS1pRcGPyEE+D7ZuwgScsLS7CtdvbMVdO VIxaPM83TNRCvMEMOXMAQ+BlQ6eapIXMfBKGpy7VEZyGYbykb6iVJfF0Z2DIUqMSTyFK HKOxhaOABj9VHS1ug6APUjjZuE8ZUWftGDf/WNk9nMEIEVInQBJgQ2RRCoarqsoZbHrs +caPNlVvfTCXQTeRuxQUVmZEVmCH6ISoqqH3h5Bcp5oVWwzZzAbn4RM49ylcI5hKHC2e NZ9gsxnem8Q6PWNKTPVqxB3AdJDeYmj6CQujbXfVlRMncQ0LKHG8tyM1DjoUCRuQp5+Y t8cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BMqi7wNVy74Epfw3/CXCjxssZh8rP45fbaF8FqplbtM=; b=JDwPgJMACTlh9kVll0OvtymAlK1AmXk9zn+uslEdH6TcbsAoZgDII7chqyCqBQuBPy LodSS3PD1NCsQAdAXKNbRHuiO1cXUWenjXnEF//Uc/wh3j/fBafe8ek3/3yDwXrsuqJ4 Ee8qwbmq8KNcEF5JLPqqyPUGyC8MGCwvxFP1sJfsmboYr+x6htKpWTl1wRaoGbeU4Pqf QaUwLropsf/voOjRGPNuSokX7ZJhmEQUeDXlLsQlbQD4++HgDT23Zg6DAvMTSEDBHtw/ bHWUm4IAaAF+/C2q7DUTY3bEZ7RJfAjOADWKxzvrOOdGGP3T+YKCHUsMrFLWbPhLuRGl F34Q== X-Gm-Message-State: APjAAAW3vZlJ3ylPauKyEc+QgkYcoL9xVI/jN+O5jCTuFsarw13JU1PK mi/cQVIqeUe20oHMigBYj8E= X-Received: by 2002:a5d:56ca:: with SMTP id m10mr6155698wrw.313.1582825391327; Thu, 27 Feb 2020 09:43:11 -0800 (PST) Received: from andrea (ip-213-220-200-127.net.upcbroadband.cz. [213.220.200.127]) by smtp.gmail.com with ESMTPSA id d13sm9014648wrc.64.2020.02.27.09.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 09:43:09 -0800 (PST) Date: Thu, 27 Feb 2020 18:43:04 +0100 From: Andrea Parri To: Boqun Feng Cc: linux-kernel@vger.kernel.org, Alan Stern , 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 , linux-arch@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v3 4/5] Documentation/locking/atomic: Add a litmus test for atomic_set() Message-ID: <20200227174304.GA11666@andrea> References: <20200227004049.6853-1-boqun.feng@gmail.com> <20200227004049.6853-5-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200227004049.6853-5-boqun.feng@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 27, 2020 at 08:40:48AM +0800, 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 Nit: s/Atomic-set-observable-to-RMW/Atomic-RMW-ops-are-atomic-WRT-atomic_set > + > +(* > + * 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); Nit: spaces after commas > +} > + > +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); > -- > 2.25.0 >