[RFC][PATCH v0.3 3/6] cpufreq/sched: Allow .setpolicy() cpufreq drivers to enable EAS

From: Rafael J. Wysocki
Date: Fri Mar 07 2025 - 14:43:31 EST


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

Some cpufreq drivers, like intel_pstate, have built-in governors that
are used instead of regular cpufreq governors, schedutil in particular,
but they can work with EAS just fine, so allow EAS to be used with
those drivers.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
drivers/cpufreq/cpufreq.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -3053,6 +3053,20 @@
return 0;
}

+static bool cpufreq_policy_is_good_for_eas(struct cpufreq_policy *policy)
+{
+ /*
+ * For EAS compatibility, require that either schedutil is the policy
+ * governor or the policy is governed directly by the cpufreq driver.
+ *
+ * In the latter case, it is assumed that EAS can only be enabled by the
+ * cpufreq driver itself which will not enable EAS if it does not meet
+ * the EAS' expectations regarding performance scaling response.
+ */
+ return sugov_is_cpufreq_governor(policy) || (!policy->governor &&
+ policy->policy != CPUFREQ_POLICY_UNKNOWN);
+}
+
bool cpufreq_ready_for_eas(const struct cpumask *cpu_mask)
{
int i;
@@ -3069,7 +3083,7 @@

return false;
}
- policy_is_ready = sugov_is_cpufreq_governor(policy);
+ policy_is_ready = cpufreq_policy_is_good_for_eas(policy);
cpufreq_cpu_put(policy);
if (!policy_is_ready) {
pr_debug("rd %*pbl: schedutil is mandatory for EAS\n",