linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Lei Wen <adrian.wenl@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Lists linaro-kernel <linaro-kernel@lists.linaro.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: Is it ok for deferrable timer wakeup the idle cpu?
Date: Mon, 10 Feb 2014 16:35:34 +0100	[thread overview]
Message-ID: <20140210153530.GA21060@localhost.localdomain> (raw)
In-Reply-To: <CAKohpok7obD9LqPwLLQMOPw9fTyKg4WpwiZ8EPAgqtHSsC0fxw@mail.gmail.com>

On Mon, Feb 03, 2014 at 12:21:16PM +0530, Viresh Kumar wrote:
> Sorry was away for short vacation.
> 
> On 28 January 2014 19:20, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Thu, Jan 23, 2014 at 07:50:40PM +0530, Viresh Kumar wrote:
> >> Wait, I got the wrong code here. That's wasn't my initial intention.
> >> I actually wanted to write something like this:
> >>
> >>  -       wake_up_nohz_cpu(cpu);
> >>  +       if (!tbase_get_deferrable(timer->base) || idle_cpu(cpu))
> >>  +               wake_up_nohz_cpu(cpu);
> >>
> >> Will that work?
> 
> Something is seriously wrong with me, again wrote rubbish code.
> Let me phrase what I wanted to write :)
> 
> "don't send IPI to a idle CPU for a deferrable timer."
> 
> Probably I code it correctly this time atleast.
> 
> -       wake_up_nohz_cpu(cpu);
> +       if (!(tbase_get_deferrable(timer->base) && idle_cpu(cpu)))
> +               wake_up_nohz_cpu(cpu);

Yeah but that's racy if the target is nohz full. We may be seeing it idle whereas
it woke up lately and run in userspace tickless for a while.

> 
> > Well, this is going to wake up the target from its idle state, which is
> > what we want to avoid if the timer is deferrable, right?
> 
> Yeah, sorry for doing it for second time :(

I'm certainly not blaming you for being confused, that would be the pot calling the kettle black ;)

> 
> > The simplest thing we want is:
> >
> >            if (!tbase_get_deferrable(timer->base) || tick_nohz_full_cpu(cpu))
> >                wake_up_nohz_cpu(cpu);
> >
> > This spares the IPI for the common case where the timer is deferrable and we run
> > in periodic or dynticks-idle mode (which should be 99.99% of the existing workloads).
> 
> I wasn't looking at this problem with NO_HZ_FULL in mind. As I thought its
> only about if the CPU is idle or not. And so the solution I was
> talking about was:
> 
> "don't send IPI to a idle CPU for a deferrable timer."
> 
> But I see that still failing with the code you wrote. For normal cases where we
> don't enable NO_HZ_FULL, we will still end up waking up idle CPUs which
> is what Lei Wen reported initially.

Not with the small change I proposed above.
I'm applying it.

> 
> Also if a CPU is marked for NO_HZ_FULL and is not idle currently then we
> wouldn't send a IPI for a deferrable timer. But we actually need that, so that
> we can reevaluate the timers order again?

Right.

  reply	other threads:[~2014-02-10 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CALZhoSQZQcM0yKTw1=ZkYz3Z_3X2QxLk0vCw6gKXW55HSrVEdw@mail.gmail.com>
     [not found] ` <alpine.DEB.2.02.1401221459590.4260@ionos.tec.linutronix.de>
     [not found]   ` <CALZhoSSSOZKwDok2ZHumeZAs0R88SC6bU2BaL54U3TU6jgoaZA@mail.gmail.com>
2014-01-23  5:52     ` Is it ok for deferrable timer wakeup the idle cpu? Viresh Kumar
2014-01-23 13:35       ` Frederic Weisbecker
2014-01-23 14:20         ` Viresh Kumar
2014-01-28 13:50           ` Frederic Weisbecker
2014-02-03  6:51             ` Viresh Kumar
2014-02-10 15:35               ` Frederic Weisbecker [this message]
2014-01-29  5:27       ` Preeti Murthy
2014-01-31 16:30         ` Frederic Weisbecker
2014-02-02 16:00           ` Preeti U Murthy
2014-02-03  8:19         ` Viresh Kumar
2014-02-12 15:06       ` Frederic Weisbecker
2014-02-13  5:20         ` Viresh Kumar

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=20140210153530.GA21060@localhost.localdomain \
    --to=fweisbec@gmail.com \
    --cc=adrian.wenl@gmail.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=viresh.kumar@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).