Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp630225imm; Fri, 8 Jun 2018 02:37:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKaWhUN4BEBoVVRtKLsH/o4r42cJCZQvlWAt1PSBseFiuIXlyw0wVwoz+azRGvE9iG16F9f X-Received: by 2002:a17:902:8212:: with SMTP id x18-v6mr5828851pln.357.1528450652574; Fri, 08 Jun 2018 02:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528450652; cv=none; d=google.com; s=arc-20160816; b=BBwx81Mcvq8ZAOnrk94N/8K/4wf9iB1mVRYhjWeeRn61Cj980bAiAyYPGTdzJUHNiL GPUv+LtFhDhy6BYkM3fOzWP93vgsneFShLdD0qiGd5nCkV1XfSphLVrmQnlt42FCIePt r7pi3ASr2exrvPvRZ0Mkh9kiVRpqW7VQy3jZy+avHr0LlK9i2kL5VGHudOVgE0iUZu0v OuLjGmMIaO7dfFoSwVaxrYxczIlJGQsUadW/mYM7NMYUIlAsP8TOvTDUCYP2P370XesV 2JYvvlJGk9naQZs6lh+Xsyperyzwb/APJmWeSND0VhXRgssn4ENg/C7xMD75RengGUrb pkGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=2rR/SRH58VBuyJptnk4ieQLCgFhfC3sGHKO0f0ERspU=; b=p8IB/zRWFI/bhxdQ1BxfOQ10kC34G0csXaGamJwAT2sh1irkqj7uLtciWQylY3eBSm otxTKei9QRMENKJI2I+Dp4csHsNUvseNwRvCUEfI9aZJAY5Zl2LGLUGpFl0L6MobRC7g 0dEV0/iW82l19ho6xmVjqgzeniGumqHSAM8yPGfhOoOotQ8jCJ2rrghFBZCBPOfYfsz3 gCHwU8tz+zyM+hoSyFa4LDe48oWPt9OsS3aNxWkM2zZCDkWQ/FjTo9Ha7IzXTs0gZbxP VynvHdOOx87Ov2BqKIRi+wbE4x3tBTGOu/IlNS7Rcwmhxq+dOdDBNZEmcGNffWrLTZTE AN0w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p4-v6si16518901pfg.329.2018.06.08.02.37.18; Fri, 08 Jun 2018 02:37:32 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752662AbeFHJgn (ORCPT + 99 others); Fri, 8 Jun 2018 05:36:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54444 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752061AbeFHJgl (ORCPT ); Fri, 8 Jun 2018 05:36:41 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w589TV7A137599 for ; Fri, 8 Jun 2018 05:36:41 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jfp4aawjc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 08 Jun 2018 05:36:40 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 8 Jun 2018 05:36:40 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 8 Jun 2018 05:36:37 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w589abgV7012720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 Jun 2018 09:36:37 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5D32FB205F; Fri, 8 Jun 2018 06:38:06 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35DBAB2064; Fri, 8 Jun 2018 06:38:06 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.80.209.72]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 Jun 2018 06:38:06 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id A283A16C62F9; Fri, 8 Jun 2018 02:38:26 -0700 (PDT) Date: Fri, 8 Jun 2018 02:38:26 -0700 From: "Paul E. McKenney" To: Andrea Parri Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Jonathan Corbet Subject: Re: [PATCH] doc: Update synchronize_rcu() definition in whatisRCU.txt Reply-To: paulmck@linux.vnet.ibm.com References: <1528365717-7213-1-git-send-email-andrea.parri@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1528365717-7213-1-git-send-email-andrea.parri@amarulasolutions.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18060809-0072-0000-0000-0000036A55EB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009150; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000265; SDB=6.01043909; UDB=6.00534503; IPR=6.00822964; MB=3.00021528; MTD=3.00000008; XFM=3.00000015; UTC=2018-06-08 09:36:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18060809-0073-0000-0000-000048499427 Message-Id: <20180608093826.GT3593@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-08_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806080110 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 07, 2018 at 12:01:57PM +0200, Andrea Parri wrote: > The synchronize_rcu() definition based on RW-locks in whatisRCU.txt > does not meet the "Memory-Barrier Guarantees" in Requirements.html; > for example, the following SB-like test: > > P0: P1: > > WRITE_ONCE(x, 1); WRITE_ONCE(y, 1); > synchronize_rcu(); smp_mb(); > r0 = READ_ONCE(y); r1 = READ_ONCE(x); > > should not be allowed to reach the state "r0 = 0 AND r1 = 0", but > the current write_lock()+write_unlock() definition can not ensure > this. Remedies this by inserting an smp_mb__after_spinlock(). > > Suggested-by: Paul E. McKenney > Signed-off-by: Andrea Parri Queued for review, thank you! Thanx, Paul > Cc: Paul E. McKenney > Cc: Josh Triplett > Cc: Steven Rostedt > Cc: Mathieu Desnoyers > Cc: Lai Jiangshan > Cc: Jonathan Corbet > --- > Documentation/RCU/whatisRCU.txt | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt > index a27fbfb0efb82..86a54ff911fc2 100644 > --- a/Documentation/RCU/whatisRCU.txt > +++ b/Documentation/RCU/whatisRCU.txt > @@ -586,6 +586,7 @@ It is extremely simple: > void synchronize_rcu(void) > { > write_lock(&rcu_gp_mutex); > + smp_mb__after_spinlock(); > write_unlock(&rcu_gp_mutex); > } > > @@ -607,12 +608,15 @@ don't forget about them when submitting patches making use of RCU!] > > The rcu_read_lock() and rcu_read_unlock() primitive read-acquire > and release a global reader-writer lock. The synchronize_rcu() > -primitive write-acquires this same lock, then immediately releases > -it. This means that once synchronize_rcu() exits, all RCU read-side > -critical sections that were in progress before synchronize_rcu() was > -called are guaranteed to have completed -- there is no way that > -synchronize_rcu() would have been able to write-acquire the lock > -otherwise. > +primitive write-acquires this same lock, then releases it. This means > +that once synchronize_rcu() exits, all RCU read-side critical sections > +that were in progress before synchronize_rcu() was called are guaranteed > +to have completed -- there is no way that synchronize_rcu() would have > +been able to write-acquire the lock otherwise. The smp_mb__after_spinlock() > +promotes synchronize_rcu() to a full memory barrier in compliance with > +the "Memory-Barrier Guarantees" listed in: > + > + Documentation/RCU/Design/Requirements/Requirements.html. > > It is possible to nest rcu_read_lock(), since reader-writer locks may > be recursively acquired. Note also that rcu_read_lock() is immune > -- > 2.7.4 >