From: Eric Piel <Eric.Piel@tremplin-utc.net>
To: venkatesh.pallipadi@intel.com
Cc: cpufreq@lists.linux.org.uk
Subject: [PATCH] ondemand governor : avoid too high frequency for stats
Date: Fri, 19 Aug 2005 19:04:58 +0200 [thread overview]
Message-ID: <4306113A.9060301@tremplin-utc.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]
Hello,
In the ondemand governor, there is a periodic measurement of the CPU
usage. This CPU usage is updated by the scheduler after every tick
(basically, by adding 1 either to "idle" or to "user" or to "system").
So if the frequency of the governor is too high, the stat will be
meaningless (as mostly no number have changed).
So this patch checks that the measurements are separated by at least 10
ticks. It means that by default, stats will have about 5% error (20
ticks). Of course those numbers can be argued but, IMHO, they look sane.
The patch also includes a small clean-up to check more explictly the
result of the conversion from ns to µs being null.
Let's note that (on x86) this has never been really needed before 2.6.13
because HZ was always 1000. Now that HZ can be 100, some CPU might be
affected by this problem. For instance, the centrino which has a 10µs
transition latency would lead to the governor allowing to read stats
every tick (10ms)!
Please apply,
Eric Piel
--
From: Eric Piel <eric.piel@tremplin-utc.net>
Avoid the ondemand cpufreq goveror to use a too high frequency for stats.
Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>
--
[-- Attachment #2: ondemand-stat-at-least-10-ticks-2.6.13-rc6.patch --]
[-- Type: text/x-patch, Size: 1448 bytes --]
--- linux-2.6.13-rc6/drivers/cpufreq/cpufreq_ondemand.c.bak 2005-08-18 16:54:45.000000000 +0200
+++ linux-2.6.13-rc6/drivers/cpufreq/cpufreq_ondemand.c 2005-08-18 17:46:31.000000000 +0200
@@ -48,7 +48,10 @@
* All times here are in uS.
*/
static unsigned int def_sampling_rate;
-#define MIN_SAMPLING_RATE (def_sampling_rate / 2)
+#define MIN_SAMPLING_RATE_RATIO (2)
+/* for correct statistics, we need at least 10 ticks between each measure */
+#define MIN_STAT_SAMPLING_RATE (MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10))
+#define MIN_SAMPLING_RATE (def_sampling_rate / MIN_SAMPLING_RATE_RATIO)
#define MAX_SAMPLING_RATE (500 * def_sampling_rate)
#define DEF_SAMPLING_RATE_LATENCY_MULTIPLIER (1000)
#define DEF_SAMPLING_DOWN_FACTOR (1)
@@ -416,13 +419,16 @@ static int cpufreq_governor_dbs(struct c
if (dbs_enable == 1) {
unsigned int latency;
/* policy latency is in nS. Convert it to uS first */
+ latency = policy->cpuinfo.transition_latency / 1000;
+ if (latency == 0)
+ latency = 1;
- latency = policy->cpuinfo.transition_latency;
- if (latency < 1000)
- latency = 1000;
-
- def_sampling_rate = (latency / 1000) *
+ def_sampling_rate = latency *
DEF_SAMPLING_RATE_LATENCY_MULTIPLIER;
+
+ if (def_sampling_rate < MIN_STAT_SAMPLING_RATE)
+ def_sampling_rate = MIN_STAT_SAMPLING_RATE;
+
dbs_tuners_ins.sampling_rate = def_sampling_rate;
dbs_tuners_ins.ignore_nice = 0;
[-- Attachment #3: Type: text/plain, Size: 147 bytes --]
_______________________________________________
Cpufreq mailing list
Cpufreq@lists.linux.org.uk
http://lists.linux.org.uk/mailman/listinfo/cpufreq
reply other threads:[~2005-08-19 17:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4306113A.9060301@tremplin-utc.net \
--to=eric.piel@tremplin-utc.net \
--cc=cpufreq@lists.linux.org.uk \
--cc=venkatesh.pallipadi@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