OSDN Git Service

cpufreq: interactive: configurable delay before raising above hispeed
authorTodd Poynor <toddpoynor@google.com>
Sat, 14 Apr 2012 03:18:02 +0000 (20:18 -0700)
committerTodd Poynor <toddpoynor@google.com>
Thu, 19 Apr 2012 02:47:38 +0000 (19:47 -0700)
Change-Id: I4d6ac40b23a3790d48e30c37408284e9f955e8fa
Signed-off-by: Todd Poynor <toddpoynor@google.com>
drivers/cpufreq/cpufreq_interactive.c

index 42b9e74..14880dd 100644 (file)
@@ -81,6 +81,13 @@ static unsigned long min_sample_time;
 #define DEFAULT_TIMER_RATE 20 * USEC_PER_MSEC
 static unsigned long timer_rate;
 
+/*
+ * Wait this long before raising speed above hispeed, by default a single
+ * timer interval.
+ */
+#define DEFAULT_ABOVE_HISPEED_DELAY DEFAULT_TIMER_RATE
+static unsigned long above_hispeed_delay_val;
+
 static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
                unsigned int event);
 
@@ -174,6 +181,17 @@ static void cpufreq_interactive_timer(unsigned long data)
 
                        if (new_freq < hispeed_freq)
                                new_freq = hispeed_freq;
+
+                       if (pcpu->target_freq == hispeed_freq &&
+                           new_freq > hispeed_freq &&
+                           cputime64_sub(pcpu->timer_run_time,
+                                         pcpu->target_set_time)
+                           < above_hispeed_delay_val) {
+                               trace_cpufreq_interactive_notyet(data, cpu_load,
+                                                                pcpu->target_freq,
+                                                                new_freq);
+                               goto rearm;
+                       }
                }
        } else {
                new_freq = pcpu->policy->max * cpu_load / 100;
@@ -515,6 +533,28 @@ static ssize_t store_min_sample_time(struct kobject *kobj,
 static struct global_attr min_sample_time_attr = __ATTR(min_sample_time, 0644,
                show_min_sample_time, store_min_sample_time);
 
+static ssize_t show_above_hispeed_delay(struct kobject *kobj,
+                                       struct attribute *attr, char *buf)
+{
+       return sprintf(buf, "%lu\n", above_hispeed_delay_val);
+}
+
+static ssize_t store_above_hispeed_delay(struct kobject *kobj,
+                                        struct attribute *attr,
+                                        const char *buf, size_t count)
+{
+       int ret;
+       unsigned long val;
+
+       ret = strict_strtoul(buf, 0, &val);
+       if (ret < 0)
+               return ret;
+       above_hispeed_delay_val = val;
+       return count;
+}
+
+define_one_global_rw(above_hispeed_delay);
+
 static ssize_t show_timer_rate(struct kobject *kobj,
                        struct attribute *attr, char *buf)
 {
@@ -540,6 +580,7 @@ static struct global_attr timer_rate_attr = __ATTR(timer_rate, 0644,
 static struct attribute *interactive_attributes[] = {
        &hispeed_freq_attr.attr,
        &go_hispeed_load_attr.attr,
+       &above_hispeed_delay.attr,
        &min_sample_time_attr.attr,
        &timer_rate_attr.attr,
        NULL,
@@ -660,6 +701,7 @@ static int __init cpufreq_interactive_init(void)
 
        go_hispeed_load = DEFAULT_GO_HISPEED_LOAD;
        min_sample_time = DEFAULT_MIN_SAMPLE_TIME;
+       above_hispeed_delay_val = DEFAULT_ABOVE_HISPEED_DELAY;
        timer_rate = DEFAULT_TIMER_RATE;
 
        /* Initalize per-cpu timers */