From 37f57e2252d434adbcecc488872d5dd0a992c3da Mon Sep 17 00:00:00 2001 From: Allen Martin Date: Thu, 30 Jun 2011 23:54:07 -0700 Subject: [PATCH] cpufreq: interactive: add sysfs control for timer rate Add a new sysfs control that tunes the rate of the timer used to increase cpu frequency Change-Id: I1aa13ae54bb43aff5b3688984d2955f56aae1658 Signed-off-by: Allen Martin --- drivers/cpufreq/cpufreq_interactive.c | 36 ++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index fe20e31..6a98631 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -66,6 +66,12 @@ static unsigned long go_maxspeed_load; #define DEFAULT_MIN_SAMPLE_TIME 80000; static unsigned long min_sample_time; +/* + * The sample rate of the timer used to increase frequency + */ +#define DEFAULT_TIMER_RATE 30000; +static unsigned long timer_rate; + static int cpufreq_governor_interactive(struct cpufreq_policy *policy, unsigned int event); @@ -219,7 +225,7 @@ rearm: pcpu->time_in_idle = get_cpu_idle_time_us( data, &pcpu->idle_exit_time); - mod_timer(&pcpu->cpu_timer, jiffies + 2); + mod_timer(&pcpu->cpu_timer, jiffies + usecs_to_jiffies(timer_rate)); } exit: @@ -254,7 +260,7 @@ static void cpufreq_interactive_idle_start(void) pcpu->time_in_idle = get_cpu_idle_time_us( smp_processor_id(), &pcpu->idle_exit_time); pcpu->timer_idlecancel = 0; - mod_timer(&pcpu->cpu_timer, jiffies + 2); + mod_timer(&pcpu->cpu_timer, jiffies + usecs_to_jiffies(timer_rate)); } #endif } else { @@ -304,7 +310,7 @@ static void cpufreq_interactive_idle_end(void) get_cpu_idle_time_us(smp_processor_id(), &pcpu->idle_exit_time); pcpu->timer_idlecancel = 0; - mod_timer(&pcpu->cpu_timer, jiffies + 2); + mod_timer(&pcpu->cpu_timer, jiffies + usecs_to_jiffies(timer_rate)); } } @@ -429,9 +435,32 @@ 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_timer_rate(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + return sprintf(buf, "%lu\n", timer_rate); +} + +static ssize_t store_timer_rate(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; + timer_rate = val; + return count; +} + +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, &min_sample_time_attr.attr, + &timer_rate_attr.attr, NULL, }; @@ -547,6 +576,7 @@ static int __init cpufreq_interactive_init(void) go_maxspeed_load = DEFAULT_GO_MAXSPEED_LOAD; min_sample_time = DEFAULT_MIN_SAMPLE_TIME; + timer_rate = DEFAULT_TIMER_RATE; /* Initalize per-cpu timers */ for_each_possible_cpu(i) { -- 2.7.4