mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle
Date: Wed, 6 Sep 2017 10:15:01 +1000	[thread overview]
Message-ID: <20170906101501.487fd7d5@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20170901122454.zkrkr5b2pe7ajiuy@hirez.programming.kicks-ass.net>

On Fri, 1 Sep 2017 14:24:54 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> On Sun, Aug 20, 2017 at 07:25:02PM +1000, Nicholas Piggin wrote:
> > Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> > ---
> >  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 <linux/stackprotector.h>
> >  #include <linux/suspend.h>
> >  #include <linux/livepatch.h>
> > +#include <linux/processor.h>
> >  
> >  #include <asm/tlb.h>
> >  
> > @@ -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

  reply	other threads:[~2017-09-06  0:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-20  9:25 [PATCH 0/2] start using spin primitives in sched and locking Nicholas Piggin
2017-08-20  9:25 ` [PATCH 1/2] locking: Use spin primitives for busy loops Nicholas Piggin
2017-09-01 12:23   ` Peter Zijlstra
2017-09-06  0:08     ` Nicholas Piggin
2017-08-20  9:25 ` [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle Nicholas Piggin
2017-09-01 12:24   ` Peter Zijlstra
2017-09-06  0:15     ` Nicholas Piggin [this message]
2017-09-01  4:01 ` [PATCH 0/2] start using spin primitives in sched and locking Nicholas Piggin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170906101501.487fd7d5@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome