From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754603AbdIFAPT (ORCPT ); Tue, 5 Sep 2017 20:15:19 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:37384 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753756AbdIFAPP (ORCPT ); Tue, 5 Sep 2017 20:15:15 -0400 X-Google-Smtp-Source: ADKCNb4WUox+vKJ0BuooWUHiLR154t1c+dV+DYo75IQu3p+dEF9oU9x+VAgGFX4hjLv1cxsi6fnppw== Date: Wed, 6 Sep 2017 10:15:01 +1000 From: Nicholas Piggin To: Peter Zijlstra Cc: Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle Message-ID: <20170906101501.487fd7d5@roar.ozlabs.ibm.com> In-Reply-To: <20170901122454.zkrkr5b2pe7ajiuy@hirez.programming.kicks-ass.net> References: <20170820092502.6812-1-npiggin@gmail.com> <20170820092502.6812-3-npiggin@gmail.com> <20170901122454.zkrkr5b2pe7ajiuy@hirez.programming.kicks-ass.net> Organization: IBM X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Sep 2017 14:24:54 +0200 Peter Zijlstra wrote: > On Sun, Aug 20, 2017 at 07:25:02PM +1000, Nicholas Piggin wrote: > > Signed-off-by: Nicholas Piggin > > --- > > kernel/sched/idle.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c > > index 6c23e30c0e5c..b884980da8ef 100644 > > --- a/kernel/sched/idle.c > > +++ b/kernel/sched/idle.c > > @@ -11,6 +11,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > > > @@ -64,9 +65,13 @@ static noinline int __cpuidle cpu_idle_poll(void) > > trace_cpu_idle_rcuidle(0, smp_processor_id()); > > local_irq_enable(); > > stop_critical_timings(); > > + > > + spin_begin(); > > while (!tif_need_resched() && > > (cpu_idle_force_poll || tick_check_broadcast_expired())) > > - cpu_relax(); > > + spin_cpu_relax(); > > + spin_end(); > > Do we want at least one tif_need_resched() check before we drop into low > prio mode? Well we've already done one to get here. My thinking is once we decide to go idle, get there as fast as we can and avoid too much icache and branches etc as we're going down. Admittedly the existing cpu_relax code does a check first, but the difference there is that it can make such a check without adding extra code. It's more difficult for spin_begin/spin_end to do the same, so I don't want to add extra junk that other CPUs don't need. I don't think it will hurt powerpc. Thanks, Nick