Skip to content

Commit

Permalink
cpufreq_conservative: Improve support for micro idle accounting
Browse files Browse the repository at this point in the history
The minimum samplerate calculations of the current conservative
implementation assume that there is not micro idle accounting present,
however, we do have that capability in our idle estimates.  As a result,
we can support lower polling intervals just like ondemand does.

Change-Id: I134027f28abd8e76ee8212685572272b1ddaa872
Signed-off-by: Andrew Dodd <atd7@cornell.edu>
  • Loading branch information
Entropy512 committed Dec 26, 2013
1 parent e0739aa commit 25f442a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions drivers/cpufreq/cpufreq_conservative.c
Expand Up @@ -48,6 +48,7 @@ static unsigned int min_sampling_rate;

#define LATENCY_MULTIPLIER (1000)
#define MIN_LATENCY_MULTIPLIER (100)
#define MICRO_FREQUENCY_MIN_SAMPLE_RATE (10000)
#define DEF_SAMPLING_DOWN_FACTOR (1)
#define MAX_SAMPLING_DOWN_FACTOR (10)
#define TRANSITION_LATENCY_LIMIT (10 * 1000 * 1000)
Expand Down Expand Up @@ -527,12 +528,6 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
return rc;
}

/*
* conservative does not implement micro like ondemand
* governor, thus we are bound to jiffes/HZ
*/
min_sampling_rate =
MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
/* Bring kernel and HW constraints together */
min_sampling_rate = max(min_sampling_rate,
MIN_LATENCY_MULTIPLIER * latency);
Expand Down Expand Up @@ -602,6 +597,24 @@ struct cpufreq_governor cpufreq_gov_conservative = {

static int __init cpufreq_gov_dbs_init(void)
{
u64 idle_time;
int cpu = get_cpu();

idle_time = get_cpu_idle_time_us(cpu, NULL);
put_cpu();
if (idle_time != -1ULL) {
/*
* In nohz/micro accounting case we set the minimum frequency
* not depending on HZ, but fixed (very low). The deferred
* timer might skip some samples if idle/sleeping as needed.
*/
min_sampling_rate = MICRO_FREQUENCY_MIN_SAMPLE_RATE;
} else {
/* For correct statistics, we need 10 ticks for each measure */
min_sampling_rate =
MIN_SAMPLING_RATE_RATIO * jiffies_to_usecs(10);
}

return cpufreq_register_governor(&cpufreq_gov_conservative);
}

Expand Down

0 comments on commit 25f442a

Please sign in to comment.