summaryrefslogtreecommitdiff
path: root/drivers/cpufreq
diff options
context:
space:
mode:
authorTodd Poynor <toddpoynor@google.com>2011-11-08 19:54:07 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:39:18 -0800
commitd48fe37bd7413252e3fa39d6497657ade72e84bc (patch)
tree67c3e46ac3bc114f6c1ecd0f908e74b4f45efdee /drivers/cpufreq
parentcf9f9c59cf46c60fe41712a057b70f754c46cca6 (diff)
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>
Diffstat (limited to 'drivers/cpufreq')
-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 72ae6533a2d4..859fdc14166f 100644
--- a/drivers/cpufreq/cpufreq_interactive.c
+++ b/drivers/cpufreq/cpufreq_interactive.c
@@ -58,9 +58,12 @@ static cpumask_t down_cpumask;
static spinlock_t down_cpumask_lock;
static struct mutex set_speed_lock;
-/* Go to max speed when CPU load at or above this value. */
-#define DEFAULT_GO_MAXSPEED_LOAD 95
-static unsigned long go_maxspeed_load;
+/* Hi speed to bump to from lo speed when load burst (default max) */
+static u64 hispeed_freq;
+
+/* Go to hi speed when CPU load at or above this value. */
+#define DEFAULT_GO_HISPEED_LOAD 95
+static unsigned long go_hispeed_load;
/*
* 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)
if (load_since_change > cpu_load)
cpu_load = load_since_change;
- if (cpu_load >= go_maxspeed_load) {
+ if (cpu_load >= go_hispeed_load) {
if (pcpu->policy->cur == pcpu->policy->min)
- new_freq = pcpu->policy->max;
+ new_freq = hispeed_freq;
else
new_freq = pcpu->policy->max * cpu_load / 100;
} else {
@@ -427,13 +430,37 @@ static void cpufreq_interactive_freq_down(struct work_struct *work)
}
}
-static ssize_t show_go_maxspeed_load(struct kobject *kobj,
+static ssize_t show_hispeed_freq(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ return sprintf(buf, "%llu\n", hispeed_freq);
+}
+
+static ssize_t store_hispeed_freq(struct kobject *kobj,
+ struct attribute *attr, const char *buf,
+ size_t count)
+{
+ int ret;
+ u64 val;
+
+ ret = strict_strtoull(buf, 0, &val);
+ if (ret < 0)
+ return ret;
+ hispeed_freq = val;
+ return count;
+}
+
+static struct global_attr hispeed_freq_attr = __ATTR(hispeed_freq, 0644,
+ show_hispeed_freq, store_hispeed_freq);
+
+
+static ssize_t show_go_hispeed_load(struct kobject *kobj,
struct attribute *attr, char *buf)
{
- return sprintf(buf, "%lu\n", go_maxspeed_load);
+ return sprintf(buf, "%lu\n", go_hispeed_load);
}
-static ssize_t store_go_maxspeed_load(struct kobject *kobj,
+static ssize_t store_go_hispeed_load(struct kobject *kobj,
struct attribute *attr, const char *buf, size_t count)
{
int ret;
@@ -442,12 +469,12 @@ static ssize_t store_go_maxspeed_load(struct kobject *kobj,
ret = strict_strtoul(buf, 0, &val);
if (ret < 0)
return ret;
- go_maxspeed_load = val;
+ go_hispeed_load = val;
return count;
}
-static struct global_attr go_maxspeed_load_attr = __ATTR(go_maxspeed_load, 0644,
- show_go_maxspeed_load, store_go_maxspeed_load);
+static struct global_attr go_hispeed_load_attr = __ATTR(go_hispeed_load, 0644,
+ show_go_hispeed_load, store_go_hispeed_load);
static ssize_t show_min_sample_time(struct kobject *kobj,
struct attribute *attr, char *buf)
@@ -494,7 +521,8 @@ static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
show_timer_rate, store_timer_rate);
static struct attribute *interactive_attributes[] = {
- &go_maxspeed_load_attr.attr,
+ &hispeed_freq_attr.attr,
+ &go_hispeed_load_attr.attr,
&min_sample_time_attr.attr,
&timer_rate_attr.attr,
NULL,
@@ -533,6 +561,9 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
smp_wmb();
}
+ if (!hispeed_freq)
+ hispeed_freq = policy->max;
+
/*
* Do not register the idle hook and create sysfs
* entries if we have already done so.
@@ -610,7 +641,7 @@ static int __init cpufreq_interactive_init(void)
struct cpufreq_interactive_cpuinfo *pcpu;
struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
- go_maxspeed_load = DEFAULT_GO_MAXSPEED_LOAD;
+ go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
timer_rate = DEFAULT_TIMER_RATE;