diff options
author | Stratos Karafotis <stratosk@semaphore.gr> | 2014-05-14 14:05:52 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-20 08:02:09 -0400 |
commit | 1e4988563d3c92ba756d8c86917fc1b594ebe855 (patch) | |
tree | 807afe61525fc4fb70f2e84ad6e5ff458f97652d | |
parent | e7b453d3dd5f251f13bf4670037af70bf611d0cb (diff) |
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: Stratos Karafotis <stratosk@semaphore.gr>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpufreq/freq_table.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c index 8e518c689393..1632981c4b25 100644 --- a/drivers/cpufreq/freq_table.c +++ b/drivers/cpufreq/freq_table.c | |||
@@ -137,9 +137,13 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
137 | i = pos - table; | 137 | i = pos - table; |
138 | if ((freq < policy->min) || (freq > policy->max)) | 138 | if ((freq < policy->min) || (freq > policy->max)) |
139 | continue; | 139 | continue; |
140 | if (freq == target_freq) { | ||
141 | optimal.driver_data = i; | ||
142 | break; | ||
143 | } | ||
140 | switch (relation) { | 144 | switch (relation) { |
141 | case CPUFREQ_RELATION_H: | 145 | case CPUFREQ_RELATION_H: |
142 | if (freq <= target_freq) { | 146 | if (freq < target_freq) { |
143 | if (freq >= optimal.frequency) { | 147 | if (freq >= optimal.frequency) { |
144 | optimal.frequency = freq; | 148 | optimal.frequency = freq; |
145 | optimal.driver_data = i; | 149 | optimal.driver_data = i; |
@@ -152,7 +156,7 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, | |||
152 | } | 156 | } |
153 | break; | 157 | break; |
154 | case CPUFREQ_RELATION_L: | 158 | case CPUFREQ_RELATION_L: |
155 | if (freq >= target_freq) { | 159 | if (freq > target_freq) { |
156 | if (freq <= optimal.frequency) { | 160 | if (freq <= optimal.frequency) { |
157 | optimal.frequency = freq; | 161 | optimal.frequency = freq; |
158 | optimal.driver_data = i; | 162 | optimal.driver_data = i; |