Skip to contentSkip to conversation

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

PATCH RESEND Superseded Fushuai Wang 2 participants 2 messages May 19

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 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 f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode with HWP enabled")
---
 drivers/cpufreq/intel_pstate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +3 -1
index 1292da53e5fc..0bd6388caa9d 100644
@@ -2986,8 +2986,10 @@ static int intel_cpufreq_cpu_offline(struct cpufreq_policy *policy)
 	 */
 	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
#1 lore raw
Quoted 18 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.

Quoted 6 lines

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

Fixes f6ebbcf08f37 ("cpufreq: intel_pstate: Implement passive mode

with HWP enabled")

The patch is fine with some comments below, but this Fixes tag is not necessary added this. This was implementation from
Commit bb18008f8086283f8f03e8e50fbbf17f213b9ea9

Author: Dirk Brandewie <[email protected]>
Date:   Wed Mar 19 08:45:54 2014 -0700

intel_pstate: Set core to min P state during core offline

Quoted 11 lines

---
 drivers/cpufreq/intel_pstate.c | 4 +++-

 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/cpufreq/intel_pstate.c +0 -0
index 1292da53e5fc..0bd6388caa9d 100644

drivers/cpufreq/intel_pstate.c static int intel_cpufreq_cpu_offline(struct · line 2988

Quoted 3 lines
drivers/cpufreq/intel_pstate.c +0 -0
@@ -2986,8 +2986,10 @@ static int intel_cpufreq_cpu_offline(struct
 cpufreq_policy *policy)
  	 */
  	if (hwp_active)

{

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

Quoted 3 lines
drivers/cpufreq/intel_pstate.c +1 -1
  		intel_pstate_hwp_offline(cpu);
-	else
+	else {

s/else / } else {

Quoted 7 lines
drivers/cpufreq/intel_pstate.c +2 -0
  		intel_pstate_set_min_pstate(cpu);
+		policy->cur = cpu->pstate.min_freq;
+	}
 


  intel_pstate_exit_perf_limits(policy);