diff options
author | Fabio Baltieri <fabio.baltieri@linaro.org> | 2012-12-27 09:55:40 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-02-01 18:01:13 -0500 |
commit | da53d61e21a5869b2e44247bb37deb8be387e063 (patch) | |
tree | d4a7f04cac977e16b6db523635cb875c8523fb2e /drivers/cpufreq/cpufreq_ondemand.c | |
parent | 2abfa876f1117b0ab45f191fb1f82c41b1cbc8fe (diff) |
cpufreq: ondemand: call dbs_check_cpu only when necessary
Modify ondemand timer to not resample CPU utilization if recently
sampled from another SW coordinated core.
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpufreq/cpufreq_ondemand.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 93bb56d14cfa..13ceb3c69b64 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -216,23 +216,23 @@ static void od_check_cpu(int cpu, unsigned int load_freq) | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | static void od_dbs_timer(struct work_struct *work) | 219 | static void od_timer_update(struct od_cpu_dbs_info_s *dbs_info, bool sample, |
220 | struct delayed_work *dw) | ||
220 | { | 221 | { |
221 | struct od_cpu_dbs_info_s *dbs_info = | ||
222 | container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); | ||
223 | unsigned int cpu = dbs_info->cdbs.cpu; | 222 | unsigned int cpu = dbs_info->cdbs.cpu; |
224 | int delay, sample_type = dbs_info->sample_type; | 223 | int delay, sample_type = dbs_info->sample_type; |
225 | 224 | ||
226 | mutex_lock(&dbs_info->cdbs.timer_mutex); | ||
227 | |||
228 | /* Common NORMAL_SAMPLE setup */ | 225 | /* Common NORMAL_SAMPLE setup */ |
229 | dbs_info->sample_type = OD_NORMAL_SAMPLE; | 226 | dbs_info->sample_type = OD_NORMAL_SAMPLE; |
230 | if (sample_type == OD_SUB_SAMPLE) { | 227 | if (sample_type == OD_SUB_SAMPLE) { |
231 | delay = dbs_info->freq_lo_jiffies; | 228 | delay = dbs_info->freq_lo_jiffies; |
232 | __cpufreq_driver_target(dbs_info->cdbs.cur_policy, | 229 | if (sample) |
233 | dbs_info->freq_lo, CPUFREQ_RELATION_H); | 230 | __cpufreq_driver_target(dbs_info->cdbs.cur_policy, |
231 | dbs_info->freq_lo, | ||
232 | CPUFREQ_RELATION_H); | ||
234 | } else { | 233 | } else { |
235 | dbs_check_cpu(&od_dbs_data, cpu); | 234 | if (sample) |
235 | dbs_check_cpu(&od_dbs_data, cpu); | ||
236 | if (dbs_info->freq_lo) { | 236 | if (dbs_info->freq_lo) { |
237 | /* Setup timer for SUB_SAMPLE */ | 237 | /* Setup timer for SUB_SAMPLE */ |
238 | dbs_info->sample_type = OD_SUB_SAMPLE; | 238 | dbs_info->sample_type = OD_SUB_SAMPLE; |
@@ -243,11 +243,49 @@ static void od_dbs_timer(struct work_struct *work) | |||
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | schedule_delayed_work_on(smp_processor_id(), &dbs_info->cdbs.work, | 246 | schedule_delayed_work_on(smp_processor_id(), dw, delay); |
247 | delay); | 247 | } |
248 | |||
249 | static void od_timer_coordinated(struct od_cpu_dbs_info_s *dbs_info_local, | ||
250 | struct delayed_work *dw) | ||
251 | { | ||
252 | struct od_cpu_dbs_info_s *dbs_info; | ||
253 | ktime_t time_now; | ||
254 | s64 delta_us; | ||
255 | bool sample = true; | ||
256 | |||
257 | /* use leader CPU's dbs_info */ | ||
258 | dbs_info = &per_cpu(od_cpu_dbs_info, dbs_info_local->cdbs.cpu); | ||
259 | mutex_lock(&dbs_info->cdbs.timer_mutex); | ||
260 | |||
261 | time_now = ktime_get(); | ||
262 | delta_us = ktime_us_delta(time_now, dbs_info->cdbs.time_stamp); | ||
263 | |||
264 | /* Do nothing if we recently have sampled */ | ||
265 | if (delta_us < (s64)(od_tuners.sampling_rate / 2)) | ||
266 | sample = false; | ||
267 | else | ||
268 | dbs_info->cdbs.time_stamp = time_now; | ||
269 | |||
270 | od_timer_update(dbs_info, sample, dw); | ||
248 | mutex_unlock(&dbs_info->cdbs.timer_mutex); | 271 | mutex_unlock(&dbs_info->cdbs.timer_mutex); |
249 | } | 272 | } |
250 | 273 | ||
274 | static void od_dbs_timer(struct work_struct *work) | ||
275 | { | ||
276 | struct delayed_work *dw = to_delayed_work(work); | ||
277 | struct od_cpu_dbs_info_s *dbs_info = | ||
278 | container_of(work, struct od_cpu_dbs_info_s, cdbs.work.work); | ||
279 | |||
280 | if (dbs_sw_coordinated_cpus(&dbs_info->cdbs)) { | ||
281 | od_timer_coordinated(dbs_info, dw); | ||
282 | } else { | ||
283 | mutex_lock(&dbs_info->cdbs.timer_mutex); | ||
284 | od_timer_update(dbs_info, true, dw); | ||
285 | mutex_unlock(&dbs_info->cdbs.timer_mutex); | ||
286 | } | ||
287 | } | ||
288 | |||
251 | /************************** sysfs interface ************************/ | 289 | /************************** sysfs interface ************************/ |
252 | 290 | ||
253 | static ssize_t show_sampling_rate_min(struct kobject *kobj, | 291 | static ssize_t show_sampling_rate_min(struct kobject *kobj, |