Skip to contentSkip to conversation

cpufreq: intel_pstate: Sync policy->cur when setting min pstate during CPU offline

PATCH Applied Fushuai Wang 2 participants 2 messages May 20 – May 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq: intel_pstate: Sync policy->cur when setting min pstate during CPU offline

From: Fushuai Wang <[email protected]>

When a CPU goes offline with HWP disabled, intel_pstate_set_min_pstate() sets the MSR_IA32_PERF_CTL to minimum frequency to prevent SMT siblings from being restricted. However, the policy->cur value was not updated, leaving it at the previous value.

When the CPU comes back online, governor->limits() checks if target_freq equals policy->cur and skips the frequency adjustment if they match. Since policy->cur still holds the previous value, the governor does not call cpufreq_driver->target to update MSR_IA32_PERF_CTL.

Fix this by synchronizing policy->cur with the hardware state when setting minimum pstate during CPU offline.

Fixes bb18008f8086 ("intel_pstate: Set core to min P state during core offline")
---
 drivers/cpufreq/intel_pstate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +4 -2
index 1292da53e5fc..11db1c887c80 100644
@@ -2984,10 +2984,12 @@ static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
 	 * from getting to lower performance levels, so force the minimum
 	 * performance on CPU offline to prevent that from happening.
 	 */
-	if (hwp_active)
+	if (hwp_active) {
 		intel_pstate_hwp_offline(cpu);
-	else
+	} else {
 		intel_pstate_set_min_pstate(cpu);
+		policy->cur = cpu->pstate.min_freq;
+	}
 
 	intel_pstate_exit_perf_limits(policy);
 
Signature · 1 line
2.36.1
maintainer Applied
#1 lore raw
Quoted 34 lines · Fushuai Wang

From: Fushuai Wang <[email protected]>

When a CPU goes offline with HWP disabled, intel_pstate_set_min_pstate() sets the MSR_IA32_PERF_CTL to minimum frequency to prevent SMT siblings from being restricted. However, the policy->cur value was not updated, leaving it at the previous value.

When the CPU comes back online, governor->limits() checks if target_freq equals policy->cur and skips the frequency adjustment if they match. Since policy->cur still holds the previous value, the governor does not call cpufreq_driver->target to update MSR_IA32_PERF_CTL.

Fix this by synchronizing policy->cur with the hardware state when setting minimum pstate during CPU offline.

Fixes bb18008f8086 ("intel_pstate: Set core to min P state during core offline")
---
 drivers/cpufreq/intel_pstate.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/intel_pstate.c +1 -1
index 1292da53e5fc..11db1c887c80 100644
@@ -2984,10 +2984,12 @@ static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
         * from getting to lower performance levels, so force the minimum
         * performance on CPU offline to prevent that from happening.
         */
-       if (hwp_active)
+       if (hwp_active) {

drivers/cpufreq/intel_pstate.c static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)

Quoted 10 lines
drivers/cpufreq/intel_pstate.c +3 -2
                intel_pstate_hwp_offline(cpu);
-       else
+       } else {
                intel_pstate_set_min_pstate(cpu);
+               policy->cur = cpu->pstate.min_freq;
+       }
 
        intel_pstate_exit_perf_limits(policy);
 
--

Applied as 7.1-rc material, thanks!