From 752a5ed0088bdb6605f8ec2c616404155e5766f2 Mon Sep 17 00:00:00 2001 From: Sultan Alsawaf Date: Sat, 12 Aug 2023 20:52:59 -0700 Subject: [PATCH] cpufreq: schedutil: Allow CPU frequency changes to be amended before they're set If the last CPU frequency selected isn't set before a new CPU frequency selection arrives, then use the new selection immediately to avoid using a stale frequency choice. This improves both performance and energy by more closely tracking the scheduler's latest decisions. Change-Id: I6456d0f2ef90dd0295eb29bfd6045fdf9eb1c9fe Signed-off-by: Sultan Alsawaf Signed-off-by: Richard Raya --- kernel/sched/cpufreq_schedutil.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 40ec31d0b389..f95bfa3b61e0 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -110,6 +110,11 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time) sg_policy->need_freq_update = true; return true; } + + /* If the last frequency wasn't set yet then we can still amend it */ + if (sg_policy->work_in_progress) + return true; + /* No need to recalculate next freq for min_rate_limit_us * at least. However we might still decide to further rate * limit once frequency change direction is decided, according