Skip to contentSkip to conversation

cpufreq: Make cpufreq_update_pressure() fall back to cpuinfo.max_freq

PATCH In review Rafael J. Wysocki 5 participants 5 messages Jul 7 – Jul 9 CPU frequency scaling framework

lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 cpufreq: Make cpufreq_update_pressure() fall back to cpuinfo.max_freq

From: Rafael J. Wysocki <[email protected]>

If arch_scale_freq_ref() is not defined for a given arch (like x86, for example), cpufreq_update_pressure() will always set cpufreq_pressure to zero for all CPUs in the system, which is generally problematic on systems with asymmetric capacity [1].

However, in the absence of arch_scale_freq_ref(), it is reasonable to assume that cpuinfo.max_freq is the maximum sustainable frequency for the given cpufreq policy. Moreover, there are cases in which arch_scale_freq_ref() would need to be defined to return essentially the cpuinfo.max_freq value anyway (for example, intel_pstate on hybrid platforms).

For the above reasons, update cpufreq_update_pressure() to fall back to using cpuinfo.max_freq as the reference frequency if zero is returned by arch_scale_freq_ref().

Fixes 75d659317bb1 ("cpufreq: Add a cpufreq pressure feedback for the scheduler")
---
 drivers/cpufreq/cpufreq.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq.c +3 -0
@@ -2590,6 +2590,9 @@ static void cpufreq_update_pressure(stru
 
 	cpu = cpumask_first(policy->related_cpus);
 	max_freq = arch_scale_freq_ref(cpu);
+	if (!max_freq)
+		max_freq = policy->cpuinfo.max_freq;
+
 	capped_freq = policy->max;
 
 	/*
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 28 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

If arch_scale_freq_ref() is not defined for a given arch (like x86, for example), cpufreq_update_pressure() will always set cpufreq_pressure to zero for all CPUs in the system, which is generally problematic on systems with asymmetric capacity [1].

However, in the absence of arch_scale_freq_ref(), it is reasonable to assume that cpuinfo.max_freq is the maximum sustainable frequency for the given cpufreq policy. Moreover, there are cases in which arch_scale_freq_ref() would need to be defined to return essentially the cpuinfo.max_freq value anyway (for example, intel_pstate on hybrid platforms).

For the above reasons, update cpufreq_update_pressure() to fall back to using cpuinfo.max_freq as the reference frequency if zero is returned by arch_scale_freq_ref().

Fixes 75d659317bb1 ("cpufreq: Add a cpufreq pressure feedback for the scheduler")
---
 drivers/cpufreq/cpufreq.c |    3 +++
 1 file changed, 3 insertions(+)

drivers/cpufreq/cpufreq.c static void cpufreq_update_pressure(stru · line 2598

Quoted 9 lines
drivers/cpufreq/cpufreq.c +3 -0
@@ -2590,6 +2590,9 @@ static void cpufreq_update_pressure(stru
 
 	cpu = cpumask_first(policy->related_cpus);
 	max_freq = arch_scale_freq_ref(cpu);
+	if (!max_freq)
+		max_freq = policy->cpuinfo.max_freq;
+
 	capped_freq = policy->max;
 
 	/*
Signature · 1 line
viresh
Reviewed-by
#2 lore raw
Quoted 37 lines · Viresh Kumar
Quoted 36 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

If arch_scale_freq_ref() is not defined for a given arch (like x86, for example), cpufreq_update_pressure() will always set cpufreq_pressure to zero for all CPUs in the system, which is generally problematic on systems with asymmetric capacity [1].

However, in the absence of arch_scale_freq_ref(), it is reasonable to assume that cpuinfo.max_freq is the maximum sustainable frequency for the given cpufreq policy. Moreover, there are cases in which arch_scale_freq_ref() would need to be defined to return essentially the cpuinfo.max_freq value anyway (for example, intel_pstate on hybrid platforms).

For the above reasons, update cpufreq_update_pressure() to fall back to using cpuinfo.max_freq as the reference frequency if zero is returned by arch_scale_freq_ref().

Fixes 75d659317bb1 ("cpufreq: Add a cpufreq pressure feedback for the scheduler")
---
  drivers/cpufreq/cpufreq.c |    3 +++
  1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq.c +3 -0
@@ -2590,6 +2590,9 @@ static void cpufreq_update_pressure(stru
 
  	cpu = cpumask_first(policy->related_cpus);
  	max_freq = arch_scale_freq_ref(cpu);
+	if (!max_freq)
+		max_freq = policy->cpuinfo.max_freq;
+
  	capped_freq = policy->max;
 
Quoted 4 lines

drivers/cpufreq/cpufreq.c static void cpufreq_update_pressure(stru · line 2598

Quoted 1 line
drivers/cpufreq/cpufreq.c +0 -0
  	/*
Signature · 2 lines
Thx and BRs,
Zhongqiu Han
Tested-by on v1 1/1
#3 lore raw
In reply to Rafael J. Wysocki
Quoted 14 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

If arch_scale_freq_ref() is not defined for a given arch (like x86, for example), cpufreq_update_pressure() will always set cpufreq_pressure to zero for all CPUs in the system, which is generally problematic on systems with asymmetric capacity [1].

However, in the absence of arch_scale_freq_ref(), it is reasonable to assume that cpuinfo.max_freq is the maximum sustainable frequency for the given cpufreq policy. Moreover, there are cases in which arch_scale_freq_ref() would need to be defined to return essentially the cpuinfo.max_freq value anyway (for example, intel_pstate on hybrid platforms).

Quoted 6 lines

For the above reasons, update cpufreq_update_pressure() to fall back to using cpuinfo.max_freq as the reference frequency if zero is returned by arch_scale_freq_ref().

Fixes 75d659317bb1 ("cpufreq: Add a cpufreq pressure feedback for the scheduler")

This patch achieves the desired behavior for cluster scheduling discussed in [1]: tasks duly migrate from CPUs of which frequency has been capped. Tasks spread once the frequency cap is removed.

Acked-by on v1 1/1
#4 lore raw
In reply to Rafael J. Wysocki
Quoted 15 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

If arch_scale_freq_ref() is not defined for a given arch (like x86, for example), cpufreq_update_pressure() will always set cpufreq_pressure to zero for all CPUs in the system, which is generally problematic on systems with asymmetric capacity [1].

However, in the absence of arch_scale_freq_ref(), it is reasonable to assume that cpuinfo.max_freq is the maximum sustainable frequency for the given cpufreq policy. Moreover, there are cases in which arch_scale_freq_ref() would need to be defined to return essentially the cpuinfo.max_freq value anyway (for example, intel_pstate on hybrid platforms).

Quoted 7 lines

For the above reasons, update cpufreq_update_pressure() to fall back to using cpuinfo.max_freq as the reference frequency if zero is returned by arch_scale_freq_ref().

Fixes 75d659317bb1 ("cpufreq: Add a cpufreq pressure feedback for the scheduler")
Quoted 19 lines
---
 drivers/cpufreq/cpufreq.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/cpufreq/cpufreq.c +3 -0
@@ -2590,6 +2590,9 @@ static void cpufreq_update_pressure(stru
 
        cpu = cpumask_first(policy->related_cpus);
        max_freq = arch_scale_freq_ref(cpu);
+       if (!max_freq)
+               max_freq = policy->cpuinfo.max_freq;
+
        capped_freq = policy->max;
 
        /*