Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1725013 > unrolled thread

Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle

Started byPeter Zijlstra <peterz@infradead.org>
First post2017-09-01 14:30 +0200
Last post2017-09-06 02:20 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle Peter Zijlstra <peterz@infradead.org> - 2017-09-01 14:30 +0200
    Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling  idle Nicholas Piggin <npiggin@gmail.com> - 2017-09-06 02:20 +0200

#1725013 — Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle

FromPeter Zijlstra <peterz@infradead.org>
Date2017-09-01 14:30 +0200
SubjectRe: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle
Message-ID<ukTfc-4tl-7@gated-at.bofh.it>
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?

> +
>  	start_critical_timings();
>  	trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
>  	rcu_idle_exit();
> -- 
> 2.13.3
> 

[toc] | [next] | [standalone]


#1727085 — Re: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle

FromNicholas Piggin <npiggin@gmail.com>
Date2017-09-06 02:20 +0200
SubjectRe: [PATCH 2/2] sched/idle: Use spin loop primitives for polling idle
Message-ID<umwet-1KB-7@gated-at.bofh.it>
In reply to#1725013
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web