From: "Doug Smythies" <dsmythies@telus.net>
To: 'Thomas Ilsche' <thomas.ilsche@tu-dresden.de>
Cc: "'Marcus Hähnel'" <mhaehnel@os.inf.tu-dresden.de>,
"'Daniel Hackenberg'" <daniel.hackenberg@tu-dresden.de>,
"'Robert Schöne'" <robert.schoene@tu-dresden.de>,
mario.bielert@tu-dresden.de,
"'Rafael J. Wysocki'" <rafael.j.wysocki@intel.com>,
"'Alex Shi'" <alex.shi@linaro.org>,
"'Ingo Molnar'" <mingo@kernel.org>,
"'Rik van Riel'" <riel@redhat.com>,
"'Daniel Lezcano'" <daniel.lezcano@linaro.org>,
"'Nicholas Piggin'" <npiggin@gmail.com>,
linux-pm@vger.kernel.org, "'Len Brown'" <lenb@kernel.org>,
"Doug Smythies" <dsmythies@telus.net>
Subject: RE: [PATCH] cpuidle: Allow menu governor to enter deeper sleep states after some time
Date: Fri, 10 Nov 2017 09:42:14 -0800 [thread overview]
Message-ID: <001901d35a4b$40d2f310$c278d930$@net> (raw)
In-Reply-To: CCuzeI4ZRt1L5CCv4eEEwJ
Hi Thomas,
In addition to my previous reply:
On 2017.11.7 15:04 Thomas Ilsche wrote:
> I made a hack[1] to stop poll_idle after timer_expires which prevents the issue
> in my tests. The idea is to make sure that poll_idle is really exited whenever a
> timer happens. I was trying to use existing information, but I'm not entirely
> sure if tick_sched.timer_expires actually has the right semantic.
Your patch does not prevent the issue in my case.
And actually I wouldn't expect it to. Why not? My (unproven) theory has always been
that by the time it ends up in the loop in drivers/cpuidle/poll_state.c the timer has
already expired, so you are looking at the next timer time, which is long.
As previously mentioned, another old, but rebased, patch does work for my case,
I'll paste it below.
I'll just add a note that I find testing results hard to repeat here. Sometimes my tests
will go for hours without an issue and other times they go for hours with constant issues.
I will say that there does appear to be some repeatable pattern, where forcing minimum
pstate makes the problem worse than when forcing the maximum pstate. (i.e. the time between
reading the original call to tick_nohz_get_sleep_length and the loop inside
drivers/cpuidle/poll_state.c is longer).
[1]: https://github.com/tud-zih-energy/linux/commit/7529b167dc7c2afaacd4551fe01ec576df5097e3
... Doug
>From 788fab5531625d7bc7f6db9622984c8e87fe7672 Mon Sep 17 00:00:00 2001
From: Doug Smythies <dsmythies@telus.net>
Date: Sat, 28 Oct 2017 07:15:41 -0700
Subject: [PATCH] cpuidle: break out of idle polling loop after HLT threshold
This was from Rik van Riel on 2016.03.18
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: Doug Smythies <dsmythies@telus.net>
---
drivers/cpuidle/poll_state.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c
index 7416b16..3023d44 100644
--- a/drivers/cpuidle/poll_state.c
+++ b/drivers/cpuidle/poll_state.c
@@ -11,10 +11,29 @@
static int __cpuidle 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();
--
2.7.4
next prev parent reply other threads:[~2017-11-10 17:42 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <a181bf42-9462-476c-6dcd-39fc7151957f@tu-dresden.de>
2017-07-27 12:50 ` [PATCH] cpuidle: Allow menu governor to enter deeper sleep states after some time Thomas Ilsche
2017-10-19 7:46 ` Len Brown
2017-10-20 16:31 ` Thomas Ilsche
2017-10-21 14:27 ` Doug Smythies
2017-10-20 0:17 ` Doug Smythies
2017-10-20 17:13 ` Thomas Ilsche
2017-10-21 14:28 ` Doug Smythies
2017-11-07 23:04 ` Thomas Ilsche
2017-11-08 4:53 ` Len Brown
2017-11-08 6:01 ` Yu Chen
2017-11-08 16:26 ` Doug Smythies
2017-11-08 16:26 ` Doug Smythies
2017-11-10 17:42 ` Doug Smythies [this message]
2017-11-14 6:12 ` Doug Smythies
2017-11-16 16:11 ` Thomas Ilsche
2017-11-16 22:47 ` Doug Smythies
2017-11-24 17:36 ` Doug Smythies
2017-12-02 12:56 ` Thomas Ilsche
2017-12-15 10:44 ` Thomas Ilsche
2017-12-15 14:23 ` Rafael J. Wysocki
2017-12-21 9:43 ` Thomas Ilsche
2017-12-22 19:37 ` Rafael J. Wysocki
2017-12-15 16:16 ` Doug Smythies
2017-12-16 2:34 ` Rafael J. Wysocki
2017-11-25 16:30 ` Doug Smythies
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='001901d35a4b$40d2f310$c278d930$@net' \
--to=dsmythies@telus.net \
--cc=alex.shi@linaro.org \
--cc=daniel.hackenberg@tu-dresden.de \
--cc=daniel.lezcano@linaro.org \
--cc=lenb@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.bielert@tu-dresden.de \
--cc=mhaehnel@os.inf.tu-dresden.de \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=rafael.j.wysocki@intel.com \
--cc=riel@redhat.com \
--cc=robert.schoene@tu-dresden.de \
--cc=thomas.ilsche@tu-dresden.de \
/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).