Commit 1e498856 authored by Stratos Karafotis's avatar Stratos Karafotis Committed by Rafael J. Wysocki

cpufreq: Break out early when frequency equals target_freq

Many drivers keep frequencies in frequency table in ascending
or descending order. When governor tries to change to policy->min
or policy->max respectively then the cpufreq_frequency_table_target
could return on first iteration. This will save some iteration cycles.

So, break out early when a frequency in cpufreq_frequency_table
equals to target one.

Testing this during kernel compilation using ondemand governor
with a frequency table in ascending order, the
cpufreq_frequency_table_target returned early on the first
iteration at about 30% of times called.
Signed-off-by: default avatarStratos Karafotis <stratosk@semaphore.gr>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent e7b453d3
...@@ -137,9 +137,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, ...@@ -137,9 +137,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
i = pos - table; i = pos - table;
if ((freq < policy->min) || (freq > policy->max)) if ((freq < policy->min) || (freq > policy->max))
continue; continue;
if (freq == target_freq) {
optimal.driver_data = i;
break;
}
switch (relation) { switch (relation) {
case CPUFREQ_RELATION_H: case CPUFREQ_RELATION_H:
if (freq <= target_freq) { if (freq < target_freq) {
if (freq >= optimal.frequency) { if (freq >= optimal.frequency) {
optimal.frequency = freq; optimal.frequency = freq;
optimal.driver_data = i; optimal.driver_data = i;
...@@ -152,7 +156,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, ...@@ -152,7 +156,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,
} }
break; break;
case CPUFREQ_RELATION_L: case CPUFREQ_RELATION_L:
if (freq >= target_freq) { if (freq > target_freq) {
if (freq <= optimal.frequency) { if (freq <= optimal.frequency) {
optimal.frequency = freq; optimal.frequency = freq;
optimal.driver_data = i; optimal.driver_data = i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment