From: Rik van Riel <riel@redhat.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Doug Smythies <dsmythies@telus.net>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Viresh Kumar <viresh.kumar@linaro.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
"Chen, Yu C" <yu.c.chen@intel.com>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Arto Jantunen <viiru@iki.fi>, Len Brown <lenb@kernel.org>
Subject: Re: [PATCH] cpuidle: use high confidence factors only when considering polling
Date: Fri, 18 Mar 2016 21:53:31 -0400 [thread overview]
Message-ID: <1458352411.14723.55.camel@redhat.com> (raw)
In-Reply-To: <CAJZ5v0hLAiVoEn0PbVo++UDrXvizYC0EeAoqj8drS3GR5mQTig@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4969 bytes --]
On Fri, 2016-03-18 at 23:56 +0100, Rafael J. Wysocki wrote:
> On Fri, Mar 18, 2016 at 10:35 PM, Rik van Riel <riel@redhat.com>
> wrote:
> >
> > On Fri, 18 Mar 2016 11:32:28 -0700
> > "Doug Smythies" <dsmythies@telus.net> wrote:
> >
> > >
> > > Energy:
> > > Kernel 4.5-rc7-rjw10-rvr6: 55864 Joules
> > >
> > > Trace data (very crude summary):
> > > Kernel 4.5-rc7-rjw10-rvr5: ~3049 long durations at high CPU load
> > > (idle state 0)
> > > Kernel 4.5-rc7-rjw10-rvr5: ~183 long durations at high, but less,
> > > CPU load (not all idle state 0)
> > This is a bit of a big hammer, but since the polling loop already
> > uses
> > full CPU power anyway, this could be harmless, and solve your
> > problem.
> >
> > ---8<---
> >
> > Subject: cpuidle: break out of idle polling loop after HLT
> > threshold
> >
> > Staying in the poll loop can be beneficial for workloads that
> > wake back up very, very quickly, but staying in the poll loop
> > for too long can waste a lot of power.
> >
> > Break out of the idle polling loop if the system has spent more
> > time in the loop than the threshold for entering the next power
> > saving mode.
> >
> > The poll loop uses full CPU power already, so this will not
> > increase the power use of the poll loop.
> >
> > Signed-off-by: Rik van Riel <riel@redhat.com>
> > ---
> > drivers/cpuidle/driver.c | 21 ++++++++++++++++++++-
> > 1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
> > index 389ade4572be..a5dfeafd243f 100644
> > --- a/drivers/cpuidle/driver.c
> > +++ b/drivers/cpuidle/driver.c
> > @@ -181,10 +181,29 @@ static void __cpuidle_driver_init(struct
> > cpuidle_driver *drv)
> > static int poll_idle(struct cpuidle_device *dev,
> > struct cpuidle_driver *drv, int index)
> > {
> > + /*
> > + * Polling is state 0; break out of the polling loop after
> > the
> > + * threshold for the next power state has passed. Doing
> > this several
> > + * times in a row should cause the menu governor to
> > immediately
> > + * select a deeper power state.
> > + */
> > + u64 limit = drv->states[1].target_residency *
> > NSEC_PER_USEC;
> > + ktime_t start = ktime_get();
> > + int i = 0;
> > +
> > local_irq_enable();
> > if (!current_set_polling_and_test()) {
> > - while (!need_resched())
> > + while (!need_resched()) {
> > + ktime_t now;
> > cpu_relax();
> > +
> > + /* Occasionally check for a timeout. */
> > + if (!(i % 1000)) {
> > + now = ktime_get();
> > + if (ktime_to_ns(ktime_sub(now,
> > start)) > limit)
> > + break;
> > + }
> > + }
> > }
> > current_clr_polling();
> I'm not sure how this is going to help, but maybe I'm missing
> something.
>
> Say we hit the timeout and break out of the loop. We get back to
> cpuidle_enter_state() and from there (via a couple of irrelevant
> steps) to cpuidle_idle_call() and to cpu_idle_loop(). Then, since we
> are still idle, the while (1) loop continues and we land in
> menu_select() again. That will choose polling again (because now
> there's less time to the next timer than it was last time, so if it
> didn't choose C1 then, it won't do that now either) and we land in
> idle_poll() again.
>
> So is there anything I'm overlooking?
After about three microseconds of the above, get_typical_interval()
will return an interval larger than the C1 target residency, or
fail to find a typical interval, because 3 of the 8 intervals will
exceed the C1 target residency at that point.
Only repeated very fast wakeups will lead to polling, and just
a few periods of polling timing out will lead to the system
reverting to HLT.
In other words, the system will only use polling while it appears
to be beneficial, and should snap out of that mode very quickly.
The kernel test robot also showed over 6% improvement in (IIRC)
the wikibench test, with polling being done a little more often.
Other parts of the kernel do pretty much anything for 2% extra
performance, so if we can find a way to preserve that 6%, without
hurting power usage significantly, I suspect it may be worthwhile.
--
All Rights Reversed.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-03-19 1:53 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 17:51 SKL BOOT FAILURE unless idle=nomwait (was Re: PROBLEM: Cpufreq constantly keeps frequency at maximum on 4.5-rc4) Len Brown
[not found] ` <87si087tsr.fsf@iki.fi>
2016-03-02 17:10 ` Rik van Riel
2016-03-08 21:13 ` Len Brown
2016-03-08 21:19 ` Len Brown
2016-03-09 17:01 ` Arto Jantunen
2016-03-09 23:03 ` Doug Smythies
2016-03-09 23:18 ` Rafael J. Wysocki
2016-03-09 23:45 ` Doug Smythies
2016-03-09 23:59 ` Rafael J. Wysocki
2016-03-11 14:03 ` Rik van Riel
2016-03-11 18:22 ` Doug Smythies
2016-03-11 20:30 ` Rik van Riel
2016-03-11 23:54 ` Rafael J. Wysocki
2016-03-12 0:46 ` Doug Smythies
2016-03-12 1:45 ` Rafael J. Wysocki
2016-03-12 2:02 ` Rafael J. Wysocki
2016-03-13 7:46 ` Doug Smythies
2016-03-14 1:32 ` Rafael J. Wysocki
2016-03-14 6:39 ` Doug Smythies
2016-03-14 12:47 ` Rafael J. Wysocki
2016-03-14 14:31 ` Rik van Riel
2016-03-14 15:21 ` Rafael J. Wysocki
2016-03-14 17:45 ` Rik van Riel
2016-03-14 22:55 ` Rafael J. Wysocki
2016-03-15 2:03 ` Rik van Riel
2016-03-16 0:32 ` Rafael J. Wysocki
2016-03-16 0:37 ` Rafael J. Wysocki
2016-03-16 0:55 ` Rik van Riel
2016-03-16 1:53 ` Rafael J. Wysocki
2016-03-16 13:02 ` Rafael J. Wysocki
2016-03-16 14:01 ` Rik van Riel
2016-03-16 14:14 ` Rafael J. Wysocki
2016-03-16 14:46 ` Rik van Riel
2016-03-16 15:05 ` Rafael J. Wysocki
2016-03-16 15:07 ` Rik van Riel
2016-03-16 15:09 ` Rafael J. Wysocki
2016-03-16 16:14 ` [PATCH] cpuidle: use high confidence factors only when considering polling Rik van Riel
2016-03-18 0:45 ` Rafael J. Wysocki
2016-03-18 6:32 ` Doug Smythies
2016-03-18 13:11 ` Rafael J. Wysocki
2016-03-18 18:32 ` Doug Smythies
2016-03-18 19:29 ` Rik van Riel
2016-03-18 20:59 ` Doug Smythies
2016-03-18 21:24 ` Rafael J. Wysocki
2016-03-18 21:26 ` Rik van Riel
2016-03-18 23:40 ` Rafael J. Wysocki
2016-03-18 21:35 ` Rik van Riel
2016-03-18 21:48 ` Rafael J. Wysocki
2016-03-18 21:52 ` Rik van Riel
2016-03-18 22:09 ` Rafael J. Wysocki
2016-03-18 22:28 ` Rik van Riel
2016-03-18 23:29 ` Rafael J. Wysocki
2016-03-18 21:56 ` Rafael J. Wysocki
2016-03-18 22:38 ` Rafael J. Wysocki
2016-03-18 22:56 ` Rafael J. Wysocki
2016-03-19 1:53 ` Rik van Riel [this message]
2016-03-19 2:06 ` Rafael J. Wysocki
2016-03-19 2:17 ` Rik van Riel
2016-03-19 2:33 ` Rafael J. Wysocki
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=1458352411.14723.55.camel@redhat.com \
--to=riel@redhat.com \
--cc=dsmythies@telus.net \
--cc=lenb@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=viiru@iki.fi \
--cc=viresh.kumar@linaro.org \
--cc=yu.c.chen@intel.com \
/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).