From: "Doug Smythies" <dsmythies@telus.net>
To: 'Andy Tang' <andy.tang@nxp.com>,
'Viresh Kumar' <viresh.kumar@linaro.org>,
'Stratos Karafotis' <stratosk@semaphore.gr>
Cc: "'Rafael J. Wysocki'" <rafael@kernel.org>,
"'Rafael J. Wysocki'" <rjw@rjwysocki.net>,
'Linux PM' <linux-pm@vger.kernel.org>,
Doug Smythies <dsmythies@telus.net>
Subject: RE: Ask for help on governor
Date: Wed, 13 Dec 2017 17:21:29 -0800 [thread overview]
Message-ID: <000701d37479$e0570320$a1050960$@net> (raw)
In-Reply-To: P0QweRTHbuQ9TP0R1eouYx
Note: adding Stratos, the commit author.
On 2017.12.12 22:22 Andy Tang wrote:
> Anyway I found the root cause myself.
>
> It was caused by commit: 00bfe05889e91b5112893b001e4a47b0a0f8bdd7.
Agreed.
Then why did my kernel bisection come to a different conclusion?
Because, in my case, the issue only manifested itself when the
sampling rate (which should really be called sampling period), became
low enough to bring the issue to the surface.
The other important thing to note for my system is that I use (O.K.,
steal) the Ubuntu kernel configuration and so my tick rate is 250 Hz, not
1000 Hz.
I think the math for the idle periods calculation breaks down here
(from drivers/cpufreq/cpufreq_governor.c):
if (time_elapsed > 2 * sampling_rate) {
unsigned int periods = time_elapsed / sampling_rate;
if (periods < idle_periods)
idle_periods = periods;
}
if 2 * sampling_rate is less than one jiffy.
I.E. isn't time_elapsed always exactly one jiffy for a fully loaded CPU?
Important note: on my system a jiffy is just over 4 milliseconds.
So, for my test which is 100% load on one CPU, basically, idle_periods is always 2,
maybe more and the conservative code is always resetting the target CPU frequency
to minimum.
For whatever reason, on my system, a frequency step of 5% will not raise the pstate,
even though it should (the math works out to 1790 MHz, or pstate 17, but I never see it.
If I raise the frequency step to anything else, the math makes complete sense. Example:
frequency step = 10% so 3800 * 0.1 + 1600 = 1980 which means I should see pstate 19 being
asked for. I do. However, it does not continue to increase because of the
idle_periods problem, driving it back as an intermediate calculation, so all I ever see is
requested pstate of 19.
O.K. so if all this is true, then a 1000 Hz kernel shouldn't have a problem. Sort of, it
doesn't. Why "sort of"? Because the default sample period of 500 usec is right
on the edge, and sometimes the requested pstate does drop as a result. I used this
command to watch the requested pstate:
watch -d -n 1 sudo rdmsr --bitfield 15:8 -d -a 0x199
(translation: watch the actual requested pstates for all CPUs, by reading the processor itself.)
and while for CPU 7, it should clamp at 38 (for my system) it doesn't. O.K. so just
increase the sampling period a little, to say 510 uSec, and then yes, it clamps at 38.
O.K. so finally, I reverted the commit (but in a cheating way):
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 58d4f4e..3493ca7 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -222,6 +222,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
max_load = load;
}
+ idle_periods = 0;
policy_dbs->idle_periods = idle_periods;
return max_load;
And everything is fine.
... Doug
next prev parent reply other threads:[~2017-12-14 1:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <HE1PR0402MB282866171A847AE244A9F76CF3340@HE1PR0402MB2828.eurprd04.prod.outlook.com>
2017-12-12 7:30 ` Ask for help on governor Viresh Kumar
2017-12-12 16:18 ` Doug Smythies
2017-12-12 16:51 ` Rafael J. Wysocki
2017-12-13 3:10 ` Doug Smythies
2017-12-13 6:17 ` Viresh Kumar
2017-12-13 6:22 ` Andy Tang
2017-12-13 6:55 ` Viresh Kumar
2017-12-13 16:13 ` Doug Smythies
2017-12-14 1:21 ` Doug Smythies [this message]
2017-12-14 2:42 ` Andy Tang
2017-12-14 18:25 ` Stratos Karafotis
2017-12-15 1:29 ` Doug Smythies
2017-12-15 1:30 ` Doug Smythies
2017-12-15 1:56 ` Andy Tang
2017-12-15 7:37 ` Doug Smythies
2017-12-15 9:00 ` Andy Tang
2017-12-15 14:26 ` Rafael J. Wysocki
2017-12-15 15:53 ` Rafael J. Wysocki
2017-12-15 18:27 ` Doug Smythies
2017-12-15 23:53 ` Rafael J. Wysocki
2017-12-18 1:15 ` [PATCH] cpufreq: governor: Ensure sufficiently large sampling intervals Rafael J. Wysocki
2017-12-18 2:59 ` Andy Tang
2017-12-18 4:38 ` Viresh Kumar
2017-12-18 16:11 ` Doug Smythies
2017-12-18 17:42 ` Rafael J. Wysocki
2017-12-13 16:13 ` Ask for help on governor Doug Smythies
2017-12-13 16:49 ` 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='000701d37479$e0570320$a1050960$@net' \
--to=dsmythies@telus.net \
--cc=andy.tang@nxp.com \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=stratosk@semaphore.gr \
--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).