From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751576AbdAPLWu (ORCPT ); Mon, 16 Jan 2017 06:22:50 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58959 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751230AbdAPLWs (ORCPT ); Mon, 16 Jan 2017 06:22:48 -0500 Date: Mon, 16 Jan 2017 03:22:39 -0800 From: "Paul E. McKenney" To: Josh Triplett Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, dvhart@linux.intel.com, fweisbec@gmail.com, oleg@redhat.com, bobby.prani@gmail.com Subject: Re: [PATCH tip/core/rcu 1/6] rcu: Abstract the dynticks momentary-idle operation Reply-To: paulmck@linux.vnet.ibm.com References: <20170114085406.GA19052@linux.vnet.ibm.com> <1484384085-19444-1-git-send-email-paulmck@linux.vnet.ibm.com> <20170116073951.ipupoxcjnv42dwop@x> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170116073951.ipupoxcjnv42dwop@x> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17011611-0004-0000-0000-0000114C0E17 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006443; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000199; SDB=6.00808330; UDB=6.00393660; IPR=6.00585690; BA=6.00005059; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013933; XFM=3.00000011; UTC=2017-01-16 11:22:45 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17011611-0005-0000-0000-00007C336F17 Message-Id: <20170116112239.GL5238@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-01-16_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701160173 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 15, 2017 at 11:39:51PM -0800, Josh Triplett wrote: > On Sat, Jan 14, 2017 at 12:54:40AM -0800, Paul E. McKenney wrote: > > This commit is the first step towards full abstraction of all accesses to > > the ->dynticks counter, implementing the previously open-coded atomic add > > of two in a new rcu_dynticks_momentary_idle() function. This abstraction > > will ease changes to the ->dynticks counter operation. > > > > Signed-off-by: Paul E. McKenney > > This change has an additional effect not documented in the commit > message: it eliminates the smp_mb__before_atomic and > smp_mb__after_atomic calls. Can you please document that in the commit > message, and explain why that doesn't cause a problem? The trick is that the old code used the non-value-returning atomic_add(), which does not imply ordering, hence the smp_mb__before_atomic() and smp_mb__after_atomic() calls. The new code uses atomic_add_return(), which does return a value, and therefore implies full ordering in and of itself. How would you like me to proceed? Thanx, Paul > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -281,6 +281,19 @@ static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { > > #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ > > }; > > > > +/* > > + * Do a double-increment of the ->dynticks counter to emulate a > > + * momentary idle-CPU quiescent state. > > + */ > > +static void rcu_dynticks_momentary_idle(void) > > +{ > > + struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks); > > + int special = atomic_add_return(2, &rdtp->dynticks); > > + > > + /* It is illegal to call this from idle state. */ > > + WARN_ON_ONCE(!(special & 0x1)); > > +} > > + > > DEFINE_PER_CPU_SHARED_ALIGNED(unsigned long, rcu_qs_ctr); > > EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr); > > > > @@ -300,7 +313,6 @@ EXPORT_PER_CPU_SYMBOL_GPL(rcu_qs_ctr); > > static void rcu_momentary_dyntick_idle(void) > > { > > struct rcu_data *rdp; > > - struct rcu_dynticks *rdtp; > > int resched_mask; > > struct rcu_state *rsp; > > > > @@ -327,10 +339,7 @@ static void rcu_momentary_dyntick_idle(void) > > * quiescent state, with no need for this CPU to do anything > > * further. > > */ > > - rdtp = this_cpu_ptr(&rcu_dynticks); > > - smp_mb__before_atomic(); /* Earlier stuff before QS. */ > > - atomic_add(2, &rdtp->dynticks); /* QS. */ > > - smp_mb__after_atomic(); /* Later stuff after QS. */ > > + rcu_dynticks_momentary_idle(); > > break; > > } > > } > > -- > > 2.5.2 > > >