aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd Poynor2011-11-08 21:54:07 -0600
committerPraneeth Bajjuri2011-11-21 04:39:15 -0600
commite23a52bae1ce63e6d2a98ec145949ec6098ff1fc (patch)
tree488620fedd9bd1aceee4cefb92df5455ce4830b2
parent5dd5b4d90345e5a847a749c38e08a8ddfffab745 (diff)
downloadkernel-common-e23a52bae1ce63e6d2a98ec145949ec6098ff1fc.tar.gz
kernel-common-e23a52bae1ce63e6d2a98ec145949ec6098ff1fc.tar.xz
kernel-common-e23a52bae1ce63e6d2a98ec145949ec6098ff1fc.zip
cpufreq: interactive governor: go to intermediate hi speed before max
* Add attribute hispeed_freq, which defaults to max. * Rename go_maxspeed_load to go_hispeed_load. * If hit go_hispeed_load and at min speed, go to hispeed_freq; if hit go_hispeed_load and already above min speed go to max speed. Change-Id: I1050dec5f013fc1177387352ba787a7e1c68703e Signed-off-by: Todd Poynor <toddpoynor@google.com>
-rw-r--r--drivers/cpufreq/cpufreq_interactive.c57
1 files changed, 44 insertions, 13 deletions
diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c
index 72ae6533a2d..859fdc14166 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -58,9 +58,12 @@ static cpumask_t down_cpumask;
58static spinlock_t down_cpumask_lock; 58static spinlock_t down_cpumask_lock;
59static struct mutex set_speed_lock; 59static struct mutex set_speed_lock;
60 60
61/* Go to max speed when CPU load at or above this value. */ 61/* Hi speed to bump to from lo speed when load burst (default max) */
62#define DEFAULT_GO_MAXSPEED_LOAD 95 62static u64 hispeed_freq;
63static unsigned long go_maxspeed_load; 63
64/* Go to hi speed when CPU load at or above this value. */
65#define DEFAULT_GO_HISPEED_LOAD 95
66static unsigned long go_hispeed_load;
64 67
65/* 68/*
66 * The minimum amount of time to spend at a frequency before we can ramp down. 69 * The minimum amount of time to spend at a frequency before we can ramp down.
@@ -159,9 +162,9 @@ static void cpufreq_interactive_timer(unsigned long data)
159 if (load_since_change > cpu_load) 162 if (load_since_change > cpu_load)
160 cpu_load = load_since_change; 163 cpu_load = load_since_change;
161 164
162 if (cpu_load >= go_maxspeed_load) { 165 if (cpu_load >= go_hispeed_load) {
163 if (pcpu->policy->cur == pcpu->policy->min) 166 if (pcpu->policy->cur == pcpu->policy->min)
164 new_freq = pcpu->policy->max; 167 new_freq = hispeed_freq;
165 else 168 else
166 new_freq = pcpu->policy->max * cpu_load / 100; 169 new_freq = pcpu->policy->max * cpu_load / 100;
167 } else { 170 } else {
@@ -427,13 +430,37 @@ static void cpufreq_interactive_freq_down(struct work_struct *work)
427 } 430 }
428} 431}
429 432
430static ssize_t show_go_maxspeed_load(struct kobject *kobj, 433static ssize_t show_hispeed_freq(struct kobject *kobj,
434 struct attribute *attr, char *buf)
435{
436 return sprintf(buf, "%llu\n", hispeed_freq);
437}
438
439static ssize_t store_hispeed_freq(struct kobject *kobj,
440 struct attribute *attr, const char *buf,
441 size_t count)
442{
443 int ret;
444 u64 val;
445
446 ret = strict_strtoull(buf, 0, &val);
447 if (ret < 0)
448 return ret;
449 hispeed_freq = val;
450 return count;
451}
452
453static struct global_attr hispeed_freq_attr = __ATTR(hispeed_freq, 0644,
454 show_hispeed_freq, store_hispeed_freq);
455
456
457static ssize_t show_go_hispeed_load(struct kobject *kobj,
431 struct attribute *attr, char *buf) 458 struct attribute *attr, char *buf)
432{ 459{
433 return sprintf(buf, "%lu\n", go_maxspeed_load); 460 return sprintf(buf, "%lu\n", go_hispeed_load);
434} 461}
435 462
436static ssize_t store_go_maxspeed_load(struct kobject *kobj, 463static ssize_t store_go_hispeed_load(struct kobject *kobj,
437 struct attribute *attr, const char *buf, size_t count) 464 struct attribute *attr, const char *buf, size_t count)
438{ 465{
439 int ret; 466 int ret;
@@ -442,12 +469,12 @@ static ssize_t store_go_maxspeed_load(struct kobject *kobj,
442 ret = strict_strtoul(buf, 0, &val); 469 ret = strict_strtoul(buf, 0, &val);
443 if (ret < 0) 470 if (ret < 0)
444 return ret; 471 return ret;
445 go_maxspeed_load = val; 472 go_hispeed_load = val;
446 return count; 473 return count;
447} 474}
448 475
449static struct global_attr go_maxspeed_load_attr = __ATTR(go_maxspeed_load, 0644, 476static struct global_attr go_hispeed_load_attr = __ATTR(go_hispeed_load, 0644,
450 show_go_maxspeed_load, store_go_maxspeed_load); 477 show_go_hispeed_load, store_go_hispeed_load);
451 478
452static ssize_t show_min_sample_time(struct kobject *kobj, 479static ssize_t show_min_sample_time(struct kobject *kobj,
453 struct attribute *attr, char *buf) 480 struct attribute *attr, char *buf)
@@ -494,7 +521,8 @@ static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
494 show_timer_rate, store_timer_rate); 521 show_timer_rate, store_timer_rate);
495 522
496static struct attribute *interactive_attributes[] = { 523static struct attribute *interactive_attributes[] = {
497 &go_maxspeed_load_attr.attr, 524 &hispeed_freq_attr.attr,
525 &go_hispeed_load_attr.attr,
498 &min_sample_time_attr.attr, 526 &min_sample_time_attr.attr,
499 &timer_rate_attr.attr, 527 &timer_rate_attr.attr,
500 NULL, 528 NULL,
@@ -533,6 +561,9 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
533 smp_wmb(); 561 smp_wmb();
534 } 562 }
535 563
564 if (!hispeed_freq)
565 hispeed_freq = policy->max;
566
536 /* 567 /*
537 * Do not register the idle hook and create sysfs 568 * Do not register the idle hook and create sysfs
538 * entries if we have already done so. 569 * entries if we have already done so.
@@ -610,7 +641,7 @@ static int __init cpufreq_interactive_init(void)
610 struct cpufreq_interactive_cpuinfo *pcpu; 641 struct cpufreq_interactive_cpuinfo *pcpu;
611 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; 642 struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
612 643
613 go_maxspeed_load = DEFAULT_GO_MAXSPEED_LOAD; 644 go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
614 min_sample_time = DEFAULT_MIN_SAMPLE_TIME; 645 min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
615 timer_rate = DEFAULT_TIMER_RATE; 646 timer_rate = DEFAULT_TIMER_RATE;
616 647