--- linux-2.6.9.orig/drivers/cpufreq/cpufreq_ondemand.c 2004-11-08 21:11:15.000000000 +0000 +++ linux-2.6.9/drivers/cpufreq/cpufreq_ondemand.c 2004-11-08 21:12:58.000000000 +0000 @@ -82,6 +82,7 @@ unsigned int up_threshold; unsigned int down_threshold; unsigned int ignore_nice; + unsigned int freq_step; }; struct dbs_tuners dbs_tuners_ins = { @@ -123,6 +124,13 @@ show_one(down_threshold, down_threshold); show_one(ignore_nice, ignore_nice); +static ssize_t show_freq_step(struct cpufreq_policy *policy, char *buf) +{ + unsigned int percent = (dbs_tuners_ins.freq_step * 100) / policy->max; + + return sprintf (buf, "%u\n", percent); +} + static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, const char *buf, size_t count) { @@ -209,6 +217,31 @@ return count; } +static ssize_t store_freq_step(struct cpufreq_policy *policy, + const char *buf, size_t count) +{ + unsigned int input; + int ret; + unsigned int freq_step = dbs_tuners_ins.freq_step; + ret = sscanf (buf, "%u", &input); + down(&dbs_sem); + if ( ret != 1 ) + goto out; + + if (input > (((policy->max - policy->min) * 100) / policy->max)) { + freq_step = policy->max - policy->min; + } else { + /* no need to test here if freq_step is zero as the user might + * actually want this */ + freq_step = (input * policy->max) / 100; + } + + dbs_tuners_ins.freq_step = freq_step; +out: + up(&dbs_sem); + return count; +} + #define define_one_rw(_name) \ static struct freq_attr _name = { \ .attr = { .name = __stringify(_name), .mode = 0644 }, \ @@ -221,6 +254,7 @@ define_one_rw(up_threshold); define_one_rw(down_threshold); define_one_rw(ignore_nice); +define_one_rw(freq_step); static struct attribute * dbs_attributes[] = { &sampling_rate_max.attr, @@ -230,6 +264,7 @@ &up_threshold.attr, &down_threshold.attr, &ignore_nice.attr, + &freq_step.attr, NULL }; @@ -244,7 +279,6 @@ { unsigned int idle_ticks, up_idle_ticks, down_idle_ticks; unsigned int total_idle_ticks; - unsigned int freq_down_step; unsigned int freq_down_sampling_rate; static int down_skip[NR_CPUS]; struct cpu_dbs_info_s *this_dbs_info; @@ -264,7 +298,7 @@ * * Any frequency increase takes it to the maximum frequency. * Frequency reduction happens at minimum steps of - * 5% of max_frequency + * 5% (default) of max_frequency */ /* Check for frequency increase */ total_idle_ticks = kstat_cpu(cpu).cpustat.idle + @@ -315,14 +349,10 @@ if (this_dbs_info->cur_policy->cur == this_dbs_info->cur_policy->min) return; - freq_down_step = (5 * this_dbs_info->cur_policy->max) / 100; - - /* max freq cannot be less than 100. But who knows.... */ - if (unlikely(freq_down_step == 0)) - freq_down_step = 5; __cpufreq_driver_target(this_dbs_info->cur_policy, - this_dbs_info->cur_policy->cur - freq_down_step, + this_dbs_info->cur_policy->cur + - dbs_tuners_ins.freq_step, CPUFREQ_RELATION_H); return; } @@ -403,7 +433,12 @@ DEF_SAMPLING_RATE_LATENCY_MULTIPLIER; dbs_tuners_ins.sampling_rate = def_sampling_rate; dbs_tuners_ins.ignore_nice = 0; - + dbs_tuners_ins.freq_step = (5 * policy->max ) / 100; + + /* max freq cannot be less than 100. But who knows... */ + if (unlikely(dbs_tuners_ins.freq_step == 0)) + dbs_tuners_ins.freq_step = 5; + dbs_timer_init(); }