[PATCH v1 1/5] cpufreq/sched: Check fast_switch_enabled when setting need_freq_update

From: Rafael J. Wysocki
Date: Mon Apr 14 2025 - 16:53:32 EST


From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>

Commit 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused
by need_freq_update") overlooked the fact that when fast swtching is
enabled, it is the only way to pick up new policy limits and so
need_freq_update needs to be set in that case when limits_changed is
set.

This causes policy limits updates to be missed in some cases, so
make sugov_should_update_freq() also set need_freq_update when the
fast_switch_enabled policy flag is set.

Fixes: 8e461a1cb43d ("cpufreq: schedutil: Fix superfluous updates caused by need_freq_update")
Closes: https://lore.kernel.org/lkml/Z_Tlc6Qs-tYpxWYb@xxxxxxxxxx/
Reported-by: Stephan Gerhold <stephan.gerhold@xxxxxxxxxx>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
kernel/sched/cpufreq_schedutil.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -83,7 +83,9 @@

if (unlikely(sg_policy->limits_changed)) {
sg_policy->limits_changed = false;
- sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
+ sg_policy->need_freq_update =
+ sg_policy->policy->fast_switch_enabled ||
+ cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
return true;
}