cpufreq: intel_pstate: Fix max_freq fallback in cpufreq_update_pressure()

After commit d2d5c129d0 ("cpufreq: Make cpufreq_update_pressure() fall
back to cpuinfo.max_freq"), cpufreq pressure appears in the CPU load
balancer unexpectedly in some cases in which it was not present before,
leading to confusion and uncertainty.

Clearly, the scheduler assumes that cpufreq pressure will not be set
unless the capacity reference frequency of the CPU is known, and the
commit mentioned above violates that assumption.

However, in some cases the capacity reference frequency of the CPU is
in fact known even though arch_scale_freq_ref() returns 0 and in those
cases it should be possible to set cpufreq pressure as appropriate.

For this purpose, introduce a new cpufreq driver callback returning
the CPU capacity reference frequency, .scale_freq_ref(), and make
cpufreq_update_pressure() invoke it, if present, instead of falling
back to cpuinfo.max_freq unconditionally.

Add that callback to the intel_pstate driver and make it return 0 unless
the scale-invariant capacity of the given CPU has been explicitly set,
in which cases its reference frequency is always cpuinfo.max_freq.

Fixes: d2d5c129d0 ("cpufreq: Make cpufreq_update_pressure() fall back to cpuinfo.max_freq")
Reported-by: Jianyong Wu <[email protected]>
Closes: https://lore.kernel.org/linux-pm/[email protected]/
Tested-by: Jianyong Wu <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Tested-by: Ricardo Neri <[email protected]> # Intel hybrid parts
Tested-by: Chen Yu <[email protected]>
[ rjw: Add READ_ONCE() around a capacity_perf read ]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Rafael J. Wysocki <[email protected]>
This commit is contained in:
Rafael J. Wysocki committed 2026-09-29 12:23:20 +02:00
1 parent 72d3fcf802
commit f341dc4d93
3 files changed
+15 -2

No files matched your search

+2 -2
View File
@@ -2590,8 +2590,8 @@ static void cpufreq_update_pressure(struct cpufreq_policy *policy)
cpu = cpumask_first(policy->related_cpus);
max_freq = arch_scale_freq_ref(cpu);
if (!max_freq)
max_freq = policy->cpuinfo.max_freq;
if (!max_freq && cpufreq_driver->scale_freq_ref)
max_freq = cpufreq_driver->scale_freq_ref(policy);
capped_freq = policy->max;
+10
View File
@@ -1135,6 +1135,14 @@ static bool hybrid_clear_max_perf_cpu(void)
return ret;
}
static unsigned int intel_pstate_scale_freq_ref(struct cpufreq_policy *policy)
{
if (READ_ONCE(all_cpu_data[policy->cpu]->capacity_perf))
return policy->cpuinfo.max_freq;
return 0;
}
static void intel_pstate_update_freq_limits(struct cpudata *cpu)
{
int scaling = cpu->pstate.scaling;
@@ -3088,6 +3096,7 @@ static struct cpufreq_driver intel_pstate = {
.offline = intel_pstate_cpu_offline,
.online = intel_pstate_cpu_online,
.update_limits = intel_pstate_update_limits,
.scale_freq_ref = intel_pstate_scale_freq_ref,
.name = "intel_pstate",
};
@@ -3411,6 +3420,7 @@ static struct cpufreq_driver intel_cpufreq = {
.suspend = intel_cpufreq_suspend,
.resume = intel_pstate_resume,
.update_limits = intel_pstate_update_limits,
.scale_freq_ref = intel_pstate_scale_freq_ref,
.name = "intel_cpufreq",
};
+3
View File
@@ -420,6 +420,9 @@ struct cpufreq_driver {
/* Will be called after the driver is fully initialized */
void (*ready)(struct cpufreq_policy *policy);
/* Return the capacity reference frequency for policy. */
unsigned int (*scale_freq_ref)(struct cpufreq_policy *policy);
struct freq_attr **attr;
/* platform specific boost support code */