Skip to content

Commit 0070ea2

Browse files
weivincewangrafaeljw
authored andcommitted
cpufreq: schedutil: restore cached freq when next_f is not changed
We have the raw cached freq to reduce the chance in calling cpufreq driver where it could be costly in some arch/SoC. Currently, the raw cached freq is reset in sugov_update_single() when it avoids frequency reduction (which is not desirable sometimes), but it is better to restore the previous value of it in that case, because it may not change in the next cycle and it is not necessary to change the CPU frequency then. Adapted from https://android-review.googlesource.com/1352810/ Signed-off-by: Wei Wang <wvw@google.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> [ rjw: Subject edit and changelog rewrite ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 5368512 commit 0070ea2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

kernel/sched/cpufreq_schedutil.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
441441
unsigned long util, max;
442442
unsigned int next_f;
443443
bool busy;
444+
unsigned int cached_freq = sg_policy->cached_raw_freq;
444445

445446
sugov_iowait_boost(sg_cpu, time, flags);
446447
sg_cpu->last_update = time;
@@ -464,8 +465,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
464465
if (busy && next_f < sg_policy->next_freq) {
465466
next_f = sg_policy->next_freq;
466467

467-
/* Reset cached freq as next_freq has changed */
468-
sg_policy->cached_raw_freq = 0;
468+
/* Restore cached freq as next_freq has changed */
469+
sg_policy->cached_raw_freq = cached_freq;
469470
}
470471

471472
/*

0 commit comments

Comments
 (0)