From: venkatesh.pallipadi@intel.com
To: cpufreq@www.linux.org.uk
Cc: davej@redhat.com
Subject: [patch 2/6] cpufreq: Change load calculation in ondemand for software coordination
Date: Thu, 17 Jul 2008 13:55:56 -0700 [thread overview]
Message-ID: <20080717205616.091452000@intel.com> (raw)
In-Reply-To: 20080717205554.214645000@intel.com
[-- Attachment #1: ondemand_swcoord_simplify.patch --]
[-- Type: text/plain, Size: 4403 bytes --]
Change the load calculation algorithm in ondemand to work well with software
coordination of frequency across the dependent cpus.
Multiply individual CPU utilization with the average freq of that logical CPU
during the measurement interval (using getavg call). And find the max CPU
utilization number in terms of CPU freq. That number is then used to
get to the target freq for next sampling interval.
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
---
drivers/cpufreq/cpufreq_ondemand.c | 65 +++++++++++++++++++------------------
1 file changed, 35 insertions(+), 30 deletions(-)
Index: linux-2.6/drivers/cpufreq/cpufreq_ondemand.c
===================================================================
--- linux-2.6.orig/drivers/cpufreq/cpufreq_ondemand.c 2008-07-17 12:59:31.000000000 -0700
+++ linux-2.6/drivers/cpufreq/cpufreq_ondemand.c 2008-07-17 13:05:51.000000000 -0700
@@ -334,9 +334,7 @@ static struct attribute_group dbs_attr_g
static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
{
- unsigned int idle_ticks, total_ticks;
- unsigned int load = 0;
- cputime64_t cur_jiffies;
+ unsigned int max_load_freq;
struct cpufreq_policy *policy;
unsigned int j;
@@ -346,13 +344,7 @@ static void dbs_check_cpu(struct cpu_dbs
this_dbs_info->freq_lo = 0;
policy = this_dbs_info->cur_policy;
- cur_jiffies = jiffies64_to_cputime64(get_jiffies_64());
- total_ticks = (unsigned int) cputime64_sub(cur_jiffies,
- this_dbs_info->prev_cpu_wall);
- this_dbs_info->prev_cpu_wall = get_jiffies_64();
- if (!total_ticks)
- return;
/*
* Every sampling_rate, we check, if current idle time is less
* than 20% (default), then we try to increase frequency
@@ -365,27 +357,46 @@ static void dbs_check_cpu(struct cpu_dbs
* 5% (default) of current frequency
*/
- /* Get Idle Time */
- idle_ticks = UINT_MAX;
+ /* Get Absolute Load - in terms of freq */
+ max_load_freq = 0;
+
for_each_cpu_mask(j, policy->cpus) {
- cputime64_t total_idle_ticks;
- unsigned int tmp_idle_ticks;
struct cpu_dbs_info_s *j_dbs_info;
+ cputime64_t cur_wall_time, cur_idle_time;
+ unsigned int idle_time, wall_time;
+ unsigned int load, load_freq;
+ int freq_avg;
j_dbs_info = &per_cpu(cpu_dbs_info, j);
- total_idle_ticks = get_cpu_idle_time(j);
- tmp_idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks,
+ cur_wall_time = jiffies64_to_cputime64(get_jiffies_64());
+ wall_time = (unsigned int) cputime64_sub(cur_wall_time,
+ j_dbs_info->prev_cpu_wall);
+ j_dbs_info->prev_cpu_wall = cur_wall_time;
+
+ cur_idle_time = get_cpu_idle_time(j);
+ idle_time = (unsigned int) cputime64_sub(cur_idle_time,
j_dbs_info->prev_cpu_idle);
- j_dbs_info->prev_cpu_idle = total_idle_ticks;
+ j_dbs_info->prev_cpu_idle = cur_idle_time;
+
+ if (unlikely(wall_time <= idle_time ||
+ (cputime_to_msecs(wall_time) <
+ dbs_tuners_ins.sampling_rate / (2 * 1000)))) {
+ continue;
+ }
+
+ load = 100 * (wall_time - idle_time) / wall_time;
- if (tmp_idle_ticks < idle_ticks)
- idle_ticks = tmp_idle_ticks;
+ freq_avg = __cpufreq_driver_getavg(policy, j);
+ if (freq_avg <= 0)
+ freq_avg = policy->cur;
+
+ load_freq = load * freq_avg;
+ if (load_freq > max_load_freq)
+ max_load_freq = load_freq;
}
- if (likely(total_ticks > idle_ticks))
- load = (100 * (total_ticks - idle_ticks)) / total_ticks;
/* Check for frequency increase */
- if (load > dbs_tuners_ins.up_threshold) {
+ if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
/* if we are already at full speed then break out early */
if (!dbs_tuners_ins.powersave_bias) {
if (policy->cur == policy->max)
@@ -412,15 +423,9 @@ static void dbs_check_cpu(struct cpu_dbs
* can support the current CPU usage without triggering the up
* policy. To be safe, we focus 10 points under the threshold.
*/
- if (load < (dbs_tuners_ins.up_threshold - 10)) {
- unsigned int freq_next, freq_cur;
-
- freq_cur = __cpufreq_driver_getavg(policy, policy->cpu);
- if (!freq_cur)
- freq_cur = policy->cur;
-
- freq_next = (freq_cur * load) /
- (dbs_tuners_ins.up_threshold - 10);
+ if (max_load_freq < (dbs_tuners_ins.up_threshold - 10) * policy->cur) {
+ unsigned int freq_next;
+ freq_next = max_load_freq / (dbs_tuners_ins.up_threshold - 10);
if (!dbs_tuners_ins.powersave_bias) {
__cpufreq_driver_target(policy, freq_next,
--
next prev parent reply other threads:[~2008-07-17 20:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 20:55 [patch 0/6] cpufreq: Use idle micro-accounting information in ondemand governor venkatesh.pallipadi
2008-07-17 20:55 ` [patch 1/6] cpufreq: Add cpu number parameter to __cpufreq_driver_getavg() venkatesh.pallipadi
2008-07-17 20:55 ` venkatesh.pallipadi [this message]
2008-07-17 20:55 ` [patch 3/6] cpufreq: get_cpu_idle_time() changes in ondemand to suit idle-microaccounting venkatesh.pallipadi
2008-07-17 20:55 ` [patch 4/6] cpufreq_ondemand: Parameterize down differential venkatesh.pallipadi
2008-07-17 20:55 ` [patch 5/6] cpufreq: Changes to get_cpu_idle_time_us(), to be used in ondemand governor venkatesh.pallipadi
2008-07-17 20:56 ` [patch 6/6] cpufreq: Add idle microaccounting " venkatesh.pallipadi
2008-07-30 16:56 ` [patch 0/6] cpufreq: Use idle micro-accounting information " Dave Jones
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=20080717205616.091452000@intel.com \
--to=venkatesh.pallipadi@intel.com \
--cc=cpufreq@www.linux.org.uk \
--cc=davej@redhat.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).