Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938628AbcKOOgN (ORCPT ); Tue, 15 Nov 2016 09:36:13 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46333 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934502AbcKOOgL (ORCPT ); Tue, 15 Nov 2016 09:36:11 -0500 Date: Tue, 15 Nov 2016 06:36:06 -0800 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Josh Triplett , 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, 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 6/7] rcu: Make expedited grace periods recheck dyntick idle state Reply-To: paulmck@linux.vnet.ibm.com References: <20161114165648.GA15216@linux.vnet.ibm.com> <1479142633-15315-6-git-send-email-paulmck@linux.vnet.ibm.com> <20161114172512.bcwdy66elesds5t4@jtriplet-mobl2.jf.intel.com> <20161114173733.GJ3142@twins.programming.kicks-ass.net> <20161114181237.GM4127@linux.vnet.ibm.com> <20161115081655.GE3142@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161115081655.GE3142@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16111514-0012-0000-0000-00001125F288 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006082; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00781021; UDB=6.00376695; IPR=6.00558529; BA=6.00004883; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013333; XFM=3.00000011; UTC=2016-11-15 14:36:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16111514-0013-0000-0000-00004730D879 Message-Id: <20161115143605.GY4127@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-11-15_05:,, 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-1609300000 definitions=main-1611150260 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2739 Lines: 57 On Tue, Nov 15, 2016 at 09:16:55AM +0100, Peter Zijlstra wrote: > On Mon, Nov 14, 2016 at 10:12:37AM -0800, Paul E. McKenney wrote: > > On Mon, Nov 14, 2016 at 06:37:33PM +0100, Peter Zijlstra wrote: > > > On Mon, Nov 14, 2016 at 09:25:12AM -0800, Josh Triplett wrote: > > > > On Mon, Nov 14, 2016 at 08:57:12AM -0800, Paul E. McKenney wrote: > > > > > Expedited grace periods check dyntick-idle state, and avoid sending > > > > > IPIs to idle CPUs, including those running guest OSes, and, on NOHZ_FULL > > > > > kernels, nohz_full CPUs. However, the kernel has been observed checking > > > > > a CPU while it was non-idle, but sending the IPI after it has gone > > > > > idle. This commit therefore rechecks idle state immediately before > > > > > sending the IPI, refraining from IPIing CPUs that have since gone idle. > > > > > > > > > > Reported-by: Rik van Riel > > > > > Signed-off-by: Paul E. McKenney > > > > > > > > atomic_add_return(0, ...) seems odd. Do you actually want that, rather > > > > than atomic_read(...)? If so, can you please document exactly why? > > > > > > Yes that is weird. The only effective difference is that it would do a > > > load-exclusive instead of a regular load. > > > > It is weird, and checking to see if it is safe to convert it and its > > friends to something with less overhead is on my list. This starts > > with a patch series I will post soon that consolidates all these > > atomic_add_return() calls into a single function, which will ease testing > > and other verification. > > > > All that aside, please keep in mind that much is required from this load. > > It is part of a network of ordered operations that guarantee that any > > operation from any CPU preceding a given grace period is seen to precede > > any other operation from any CPU following that same grace period. > > And each and every CPU must agree on the order of those two operations, > > otherwise, RCU is broken. > > OK, so something similar to: > > smp_mb(); > atomic_read(); > > then? That would order, with global transitivity, against prior > operations. Maybe. The consolidation in the later patch series is a first step towards potential weakening. > > In addition, please note also that these operations are nowhere near > > any fastpaths. > > My concern is mostly that it reads very weird. I appreciate this not > being fast path code, but confusing code is bad in any form. It is the long-standing code that has been checking dyntick-idle counters for quite some time. Just applying that same code to a new use case in within the expedited grace periods, as you can see by looking a bit earlier in that same function. Thanx, Paul