Skip to content

Commit

Permalink
cpufreq: Added down_threshold_hotplug tunable to ktoonservative gov
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoonsez committed Nov 12, 2012
1 parent 1dc7a4b commit 08bedbc
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions drivers/cpufreq/cpufreq_ktoonservative.c
Expand Up @@ -32,6 +32,7 @@
#define DEF_FREQUENCY_UP_THRESHOLD (67)
#define DEF_FREQUENCY_UP_THRESHOLD_HOTPLUG (65)
#define DEF_FREQUENCY_DOWN_THRESHOLD (42)
#define DEF_FREQUENCY_DOWN_THRESHOLD_HOTPLUG (30)

/*
* The polling frequency of this governor depends on the capability of
Expand Down Expand Up @@ -87,12 +88,14 @@ static struct dbs_tuners {
unsigned int up_threshold;
unsigned int up_threshold_hotplug;
unsigned int down_threshold;
unsigned int down_threshold_hotplug;
unsigned int ignore_nice;
unsigned int freq_step;
} dbs_tuners_ins = {
.up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
.up_threshold_hotplug = DEF_FREQUENCY_UP_THRESHOLD_HOTPLUG,
.down_threshold = DEF_FREQUENCY_DOWN_THRESHOLD,
.down_threshold_hotplug = DEF_FREQUENCY_DOWN_THRESHOLD_HOTPLUG,
.sampling_down_factor = DEF_SAMPLING_DOWN_FACTOR,
.ignore_nice = 1,
.freq_step = 5,
Expand Down Expand Up @@ -184,6 +187,7 @@ show_one(sampling_down_factor, sampling_down_factor);
show_one(up_threshold, up_threshold);
show_one(up_threshold_hotplug, up_threshold_hotplug);
show_one(down_threshold, down_threshold);
show_one(down_threshold_hotplug, down_threshold_hotplug);
show_one(ignore_nice_load, ignore_nice);
show_one(freq_step, freq_step);

Expand Down Expand Up @@ -262,6 +266,22 @@ static ssize_t store_down_threshold(struct kobject *a, struct attribute *b,
return count;
}

static ssize_t store_down_threshold_hotplug(struct kobject *a, struct attribute *b,
const char *buf, size_t count)
{
unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);

/* cannot be lower than 11 otherwise freq will not fall */
if (ret != 1 || input < 11 || input > 100 ||
input >= dbs_tuners_ins.up_threshold)
return -EINVAL;

dbs_tuners_ins.down_threshold_hotplug = input;
return count;
}

static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b,
const char *buf, size_t count)
{
Expand Down Expand Up @@ -318,6 +338,7 @@ define_one_global_rw(sampling_down_factor);
define_one_global_rw(up_threshold);
define_one_global_rw(up_threshold_hotplug);
define_one_global_rw(down_threshold);
define_one_global_rw(down_threshold_hotplug);
define_one_global_rw(ignore_nice_load);
define_one_global_rw(freq_step);

Expand All @@ -328,6 +349,7 @@ static struct attribute *dbs_attributes[] = {
&up_threshold.attr,
&up_threshold_hotplug.attr,
&down_threshold.attr,
&down_threshold_hotplug.attr,
&ignore_nice_load.attr,
&freq_step.attr,
NULL
Expand Down Expand Up @@ -442,6 +464,11 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
return;
}

if (max_load < (dbs_tuners_ins.down_threshold_hotplug)) {
if (num_online_cpus() > 1)
cpu_down(1);
}

/*
* The optimal frequency is the frequency that is the lowest that
* can support the current CPU usage without triggering the up
Expand All @@ -458,11 +485,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
* if we cannot reduce the frequency anymore, break out early
*/
if (policy->cur == policy->min)
{
if (num_online_cpus() > 1)
cpu_down(1);
return;
}

__cpufreq_driver_target(policy, this_dbs_info->requested_freq,
CPUFREQ_RELATION_H);
Expand Down

0 comments on commit 08bedbc

Please sign in to comment.