From 0917ae7987a25f50b41106ef9726db18298f86c9 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 30 Jun 2020 13:47:39 -0700 Subject: [PATCH] ANDROID: cpufreq: schedutil: maintain raw cache when next_f is not changed Currently, the raw cache will be reset when next_f is changed after get_next_freq for correctness. However, it may introduce more cycles in those cases. This patch changes it to maintain the cached value instead of dropping it. Bug: 159936782 Bug: 158863204 Signed-off-by: Wei Wang [dereference23: Backport to 4.14] Signed-off-by: Alexander Winkowski Change-Id: I519ca02dd2e6038e3966e1f68fee641628827c82 --- kernel/sched/cpufreq_schedutil.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 99761dd2f21c..0687bb36fb23 100755 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -164,8 +164,8 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, return; if (sugov_up_down_rate_limit(sg_policy, time, next_freq)) { - /* Don't cache a raw freq that didn't become next_freq */ - sg_policy->cached_raw_freq = 0; + /* Restore cached freq as next_freq is not changed */ + sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq; return; } @@ -335,8 +335,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, busy = use_pelt() && sugov_cpu_is_busy(sg_cpu); if (flags & SCHED_CPUFREQ_RT_DL) { - /* clear cache when it's bypassed */ - sg_policy->cached_raw_freq = 0; + sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq; next_f = policy->cpuinfo.max_freq; } else { sugov_get_util(&util, &max, sg_cpu->cpu); @@ -384,8 +383,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) continue; } if (j_sg_cpu->flags & SCHED_CPUFREQ_RT_DL) { - /* clear cache when it's bypassed */ - sg_policy->cached_raw_freq = 0; + sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq; return policy->cpuinfo.max_freq; } @@ -428,8 +426,7 @@ static void sugov_update_shared(struct update_util_data *hook, u64 time, !(flags & SCHED_CPUFREQ_CONTINUE)) { if (flags & SCHED_CPUFREQ_RT_DL) { next_f = sg_policy->policy->cpuinfo.max_freq; - /* clear cache when it's bypassed */ - sg_policy->cached_raw_freq = 0; + sg_policy->cached_raw_freq = sg_policy->prev_cached_raw_freq; } else { next_f = sugov_next_freq_shared(sg_cpu, time); }