All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"linaro-kernel@lists.linaro.org" <linaro-kernel@lists.linaro.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] sched: fix clear NOHZ_BALANCE_KICK
Date: Tue, 4 Jun 2013 13:53:37 +0200	[thread overview]
Message-ID: <20130604115335.GC14973@somewhere> (raw)
In-Reply-To: <20130604111510.GO8923@twins.programming.kicks-ass.net>

On Tue, Jun 04, 2013 at 01:15:10PM +0200, Peter Zijlstra wrote:
> On Tue, Jun 04, 2013 at 12:26:22PM +0200, Frederic Weisbecker wrote:
> > @@ -1393,8 +1392,12 @@ static void sched_ttwu_pending(void)
> >  
> >  void scheduler_ipi(void)
> >  {
> > -	if (llist_empty(&this_rq()->wake_list) && !got_nohz_idle_kick()
> > -	    && !tick_nohz_full_cpu(smp_processor_id()))
> > +	int cpu = smp_processor_id();
> > +	bool idle_kick = got_nohz_idle_kick(cpu);
> 
> This puts an unconditional atomic instruction in the IPI path. 
>  if (test) clear();
> is lots cheaper, esp. since most IPIs won't have this flag set.

Agreed but I'm a bit worried about ordering:

CPU 0                                           CPU 1

test_and_set_bit(nohz_kick, CPU 1)              scheduler_ipi
smp_send_reschedule(CPU 1)                      if (test_and_clear_bit(nohz_kick))
                                                   do_something

I'm not sure what base guarantee we have with ordering against raw IPIs such as the
the scheduler ipi. But unless both IPI trigger and IPI receive imply a full barrier
(or just IPI receive implies read barrier, it seems that's all we need), we need
test_and_set_bit() or smp_rmb()/smp_mb__before_clear_bit() && smp_mb__after_clear_bit().

> 
> > +
> > +	if (!(idle_kick && idle_cpu(cpu))
> > +	    && llist_empty(&this_rq()->wake_list)
> > +	    && !tick_nohz_full_cpu(cpu)
> 
> What's with this weird operator first split style?

Yeah ugly, I'll fix.

> 
> >  		return;
> >  
> >  	/*
>   
> > +enum idle_balance_type {
> > +	IDLE_BALANCE = 1,
> > +	IDLE_NOHZ_BALANCE = 2,
> > +};
> 
> You might want to update the rq->idle_balance assignment in
> scheduler_tick() to make sure it uses the right value (it does now, but
> there's nothing stopping people from changing the values).

Agreed!

Thanks.

  reply	other threads:[~2013-06-04 11:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 15:23 [PATCH] sched: fix clear NOHZ_BALANCE_KICK Vincent Guittot
2013-06-03 22:48 ` Frederic Weisbecker
2013-06-04  8:21   ` Vincent Guittot
2013-06-04  9:36     ` Peter Zijlstra
2013-06-04 10:26       ` Frederic Weisbecker
2013-06-04 11:11         ` Vincent Guittot
2013-06-04 11:19           ` Frederic Weisbecker
2013-06-04 11:48             ` Vincent Guittot
2013-06-04 14:44               ` Frederic Weisbecker
2013-06-04 15:29                 ` Vincent Guittot
2013-06-05 13:31                   ` Frederic Weisbecker
2013-06-04 11:15         ` Peter Zijlstra
2013-06-04 11:53           ` Frederic Weisbecker [this message]
2013-06-04  9:56     ` Frederic Weisbecker

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=20130604115335.GC14973@somewhere \
    --to=fweisbec@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.