aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/cpufreq/cpufreq_governor.c
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2013-02-27 01:54:03 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-03-31 19:11:35 -0400
commit031299b3be30f3ecab110fff8faad85af70e1797 (patch)
tree3e823df16db43dffbf14b7895811059e22427a1e /drivers/cpufreq/cpufreq_governor.c
parent9d44592018e617abf62a5f6a5d92a04aa07e7625 (diff)
cpufreq: governors: Avoid unnecessary per cpu timer interrupts
Following patch has introduced per cpu timers or works for ondemand and conservative governors. commit 2abfa876f1117b0ab45f191fb1f82c41b1cbc8fe Author: Rickard Andersson <rickard.andersson@stericsson.com> Date: Thu Dec 27 14:55:38 2012 +0000 cpufreq: handle SW coordinated CPUs This causes additional unnecessary interrupts on all cpus when the load is recently evaluated by any other cpu. i.e. When load is recently evaluated by cpu x, we don't really need any other cpu to evaluate this load again for the next sampling_rate time. Some sort of code is present to avoid that but we are still getting timer interrupts for all cpus. A good way of avoiding this would be to modify delays for all cpus (policy->cpus) whenever any cpu has evaluated load. This patch does this change and some related code cleanup. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_governor.c')
-rw-r--r--drivers/cpufreq/cpufreq_governor.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
index 26fbb729bc1c..326f0c2e2bd5 100644
--- a/drivers/cpufreq/cpufreq_governor.c
+++ b/drivers/cpufreq/cpufreq_governor.c
@@ -178,20 +178,38 @@ void dbs_check_cpu(struct dbs_data *dbs_data, int cpu)
178} 178}
179EXPORT_SYMBOL_GPL(dbs_check_cpu); 179EXPORT_SYMBOL_GPL(dbs_check_cpu);
180 180
181static inline void dbs_timer_init(struct dbs_data *dbs_data, int cpu, 181static inline void __gov_queue_work(int cpu, struct dbs_data *dbs_data,
182 unsigned int sampling_rate) 182 unsigned int delay)
183{ 183{
184 int delay = delay_for_sampling_rate(sampling_rate);
185 struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); 184 struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu);
186 185
187 schedule_delayed_work_on(cpu, &cdbs->work, delay); 186 mod_delayed_work_on(cpu, system_wq, &cdbs->work, delay);
188} 187}
189 188
190static inline void dbs_timer_exit(struct dbs_data *dbs_data, int cpu) 189void gov_queue_work(struct dbs_data *dbs_data, struct cpufreq_policy *policy,
190 unsigned int delay, bool all_cpus)
191{ 191{
192 struct cpu_dbs_common_info *cdbs = dbs_data->cdata->get_cpu_cdbs(cpu); 192 int i;
193
194 if (!all_cpus) {
195 __gov_queue_work(smp_processor_id(), dbs_data, delay);
196 } else {
197 for_each_cpu(i, policy->cpus)
198 __gov_queue_work(i, dbs_data, delay);
199 }
200}
201EXPORT_SYMBOL_GPL(gov_queue_work);
202
203static inline void gov_cancel_work(struct dbs_data *dbs_data,
204 struct cpufreq_policy *policy)
205{
206 struct cpu_dbs_common_info *cdbs;
207 int i;
193 208
194 cancel_delayed_work_sync(&cdbs->work); 209 for_each_cpu(i, policy->cpus) {
210 cdbs = dbs_data->cdata->get_cpu_cdbs(i);
211 cancel_delayed_work_sync(&cdbs->work);
212 }
195} 213}
196 214
197/* Will return if we need to evaluate cpu load again or not */ 215/* Will return if we need to evaluate cpu load again or not */
@@ -380,16 +398,15 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
380 /* Initiate timer time stamp */ 398 /* Initiate timer time stamp */
381 cpu_cdbs->time_stamp = ktime_get(); 399 cpu_cdbs->time_stamp = ktime_get();
382 400
383 for_each_cpu(j, policy->cpus) 401 gov_queue_work(dbs_data, policy,
384 dbs_timer_init(dbs_data, j, sampling_rate); 402 delay_for_sampling_rate(sampling_rate), true);
385 break; 403 break;
386 404
387 case CPUFREQ_GOV_STOP: 405 case CPUFREQ_GOV_STOP:
388 if (dbs_data->cdata->governor == GOV_CONSERVATIVE) 406 if (dbs_data->cdata->governor == GOV_CONSERVATIVE)
389 cs_dbs_info->enable = 0; 407 cs_dbs_info->enable = 0;
390 408
391 for_each_cpu(j, policy->cpus) 409 gov_cancel_work(dbs_data, policy);
392 dbs_timer_exit(dbs_data, j);
393 410
394 mutex_lock(&dbs_data->mutex); 411 mutex_lock(&dbs_data->mutex);
395 mutex_destroy(&cpu_cdbs->timer_mutex); 412 mutex_destroy(&cpu_cdbs->timer_mutex);