Skip to content

Commit 9d44592

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: ondemand: Don't update sample_type if we don't evaluate load again
Because we have per cpu timer now, we check if we need to evaluate load again or not (In case it is recently evaluated). Here the 2nd cpu which got timer interrupt updates core_dbs_info->sample_type irrespective of load evaluation is required or not. Which is wrong as the first cpu is dependent on this variable set to an older value. Moreover it would be best in this case to schedule 2nd cpu's timer to sampling_rate instead of freq_lo or hi as that must be managed by the other cpu. In case the other cpu idles in between then also we wouldn't loose much power. Signed-off-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 98104ee commit 9d44592

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/cpufreq/cpufreq_ondemand.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,34 +224,32 @@ static void od_dbs_timer(struct work_struct *work)
224224
cpu);
225225
struct dbs_data *dbs_data = dbs_info->cdbs.cur_policy->governor_data;
226226
struct od_dbs_tuners *od_tuners = dbs_data->tuners;
227-
int delay, sample_type = core_dbs_info->sample_type;
228-
bool eval_load;
227+
int delay = 0, sample_type = core_dbs_info->sample_type;
229228

230229
mutex_lock(&core_dbs_info->cdbs.timer_mutex);
231-
eval_load = need_load_eval(&core_dbs_info->cdbs,
232-
od_tuners->sampling_rate);
230+
if (!need_load_eval(&core_dbs_info->cdbs, od_tuners->sampling_rate))
231+
goto max_delay;
233232

234233
/* Common NORMAL_SAMPLE setup */
235234
core_dbs_info->sample_type = OD_NORMAL_SAMPLE;
236235
if (sample_type == OD_SUB_SAMPLE) {
237236
delay = core_dbs_info->freq_lo_jiffies;
238-
if (eval_load)
239-
__cpufreq_driver_target(core_dbs_info->cdbs.cur_policy,
240-
core_dbs_info->freq_lo,
241-
CPUFREQ_RELATION_H);
237+
__cpufreq_driver_target(core_dbs_info->cdbs.cur_policy,
238+
core_dbs_info->freq_lo, CPUFREQ_RELATION_H);
242239
} else {
243-
if (eval_load)
244-
dbs_check_cpu(dbs_data, cpu);
240+
dbs_check_cpu(dbs_data, cpu);
245241
if (core_dbs_info->freq_lo) {
246242
/* Setup timer for SUB_SAMPLE */
247243
core_dbs_info->sample_type = OD_SUB_SAMPLE;
248244
delay = core_dbs_info->freq_hi_jiffies;
249-
} else {
250-
delay = delay_for_sampling_rate(od_tuners->sampling_rate
251-
* core_dbs_info->rate_mult);
252245
}
253246
}
254247

248+
max_delay:
249+
if (!delay)
250+
delay = delay_for_sampling_rate(od_tuners->sampling_rate
251+
* core_dbs_info->rate_mult);
252+
255253
schedule_delayed_work_on(smp_processor_id(), dw, delay);
256254
mutex_unlock(&core_dbs_info->cdbs.timer_mutex);
257255
}

0 commit comments

Comments
 (0)