Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756173AbdGKSJk (ORCPT ); Tue, 11 Jul 2017 14:09:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50987 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755947AbdGKSJi (ORCPT ); Tue, 11 Jul 2017 14:09:38 -0400 Date: Tue, 11 Jul 2017 11:09:31 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Frederic Weisbecker , Christoph Lameter , "Li, Aubrey" , Andi Kleen , Aubrey Li , tglx@linutronix.de, len.brown@intel.com, rjw@rjwysocki.net, tim.c.chen@linux.intel.com, arjan@linux.intel.com, yang.zhang.wz@gmail.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v1 00/11] Create fast idle path for short idle periods Reply-To: paulmck@linux.vnet.ibm.com References: <1499650721-5928-1-git-send-email-aubrey.li@intel.com> <20170710084647.zs6wkl3fumszd33g@hirez.programming.kicks-ass.net> <20170710144609.GD31832@tassilo.jf.intel.com> <20170710164206.5aon5kelbisxqyxq@hirez.programming.kicks-ass.net> <20170710172705.GA3441@tassilo.jf.intel.com> <20170711094157.5xcwkloxnjehieqv@hirez.programming.kicks-ass.net> <20170711160926.GA18805@lerouge> <20170711163422.etydkhhtgfthpfi5@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170711163422.etydkhhtgfthpfi5@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17071118-0048-0000-0000-000001C1349B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007350; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00886122; UDB=6.00442291; IPR=6.00666272; BA=6.00005468; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016181; XFM=3.00000015; UTC=2017-07-11 18:09:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17071118-0049-0000-0000-000041D98AD4 Message-Id: <20170711180931.GP2393@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-07-11_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-1706020000 definitions=main-1707110292 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3362 Lines: 92 On Tue, Jul 11, 2017 at 06:34:22PM +0200, Peter Zijlstra wrote: > On Tue, Jul 11, 2017 at 06:09:27PM +0200, Frederic Weisbecker wrote: > > > > > - tick_nohz_idle_enter costs 7058ns - 10726ns > > > > - tick_nohz_idle_exit costs 8372ns - 20850ns > > > > > > Right, those are horrible expensive, but skipping them isn't 'hard', the > > > only tricky bit is finding a condition that makes sense. > > > > Note you can statically disable it with nohz=0 boot parameter. > > Yeah, but that's bad for power usage, nobody wants that. > > > > See Mike's patch: https://patchwork.kernel.org/patch/2839221/ > > > > > > Combined with the above, and possibly a better condition, that should > > > get rid of most of this. > > > > Such a patch could work well if the decision from the scheduler to not stop the tick > > happens on idle entry. > > > > Now if sched_needs_cpu() first allows to stop the tick then refuses it later > > in the end of an idle IRQ, this won't have the desired effect. As long as ts->tick_stopped=1, > > it stays so until we really restart the tick. So the whole costly nohz machinery stays on. > > > > I guess it doesn't matter though, as we are talking about making fast idle entry so the > > decision not to stop the tick is likely to be done once on idle entry, when ts->tick_stopped=0. > > > > One exception though: if the tick is already stopped when we enter idle (full nohz case). And > > BTW stopping the tick outside idle shouldn't be concerned here. > > > > So I'd rather put that on can_stop_idle_tick(). > > Mike's patch much predates the existence of that function I think ;-) But > sure.. > > > > > > > > - totally from arch_cpu_idle_enter entry to arch_cpu_idle_exit return costs > > > > 9122ns - 15318ns. > > > > --In this period, rcu_idle_enter costs 1985ns - 2262ns, rcu_idle_exit costs > > > > 1813ns - 3507ns > > > > > > Is that the POPF being painful? or something else? > > > > Probably that and the atomic_add_return(). > > I got properly lost in the RCU machinery. It wasn't at all clear to me > if rcu_eqs_enter_common() was a slow-path function or not. It is called on pretty much every transition to idle. > Also, RCU_FAST_NO_HZ will make a fairly large difference here.. Paul > what's the state of that thing, do we actually want that or not? If you are battery powered and don't have tight real-time latency constraints, you want it -- it has represent a 30-40% boost in battery lifetime for some low-utilization battery-powered devices. Otherwise, probably not. > But I think we can at the very least do this; it only gets called from > kernel/sched/idle.c and both callsites have IRQs explicitly disabled by > that point. > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 51d4c3acf32d..dccf2dc8155a 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -843,13 +843,8 @@ static void rcu_eqs_enter(bool user) > */ > void rcu_idle_enter(void) > { > - unsigned long flags; > - > - local_irq_save(flags); With this addition, I am all for it: RCU_LOCKDEP_WARN(!irqs_disabled(), "rcu_idle_enter() invoked with irqs enabled!!!"); If you are OK with this addition, may I please have your Signed-off-by? Thanx, Paul > rcu_eqs_enter(false); > - local_irq_restore(flags); > } > -EXPORT_SYMBOL_GPL(rcu_idle_enter); > > #ifdef CONFIG_NO_HZ_FULL > /** >