Skip to contentSkip to conversation

cpufreq: amd-pstate: Set a fallback policy based on preferred_profile

PATCH In review Perry Yuan 3 participants 6 messages Jun 15, 2023 – Jun 20, 2023

Subsystems (2)
lore
Share & tools
lore

Perry Yuan

author reviewer
#0 lore raw

PATCH v2 2/4 cpufreq: amd-pstate: Set a fallback policy based on preferred_profile

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
 drivers/cpufreq/amd-pstate.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 	policy->max = policy->cpuinfo.max_freq;
 
 	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
 	 * the default cpufreq governor is neither powersave nor performance.
 	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
 	if (boot_cpu_has(X86_FEATURE_CPPC)) {
 		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 5 lines · Perry

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but

May I know if the processor is powerful desktop such as threadripper, whether it will be default to 'performance' or 'powersave'?

Thanks,
Ray

Quoted 36 lines

servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
 drivers/cpufreq/amd-pstate.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
 	policy->max = policy->cpuinfo.max_freq;
 
 	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
 	 * the default cpufreq governor is neither powersave nor performance.
 	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
 	if (boot_cpu_has(X86_FEATURE_CPPC)) {
 		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1
#2 lore raw
Quoted 8 lines · Huang Rui
Quoted 5 lines · Perry

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but

May I know if the processor is powerful desktop such as threadripper, whether it will be default to 'performance' or 'powersave'?

It's currently defaulting to 'powersave' for desktops and workstations.

Do you think we should adopt performance for these?

Quoted 40 lines

Thanks,
Ray

Quoted 36 lines

servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
  drivers/cpufreq/amd-pstate.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
  	policy->max = policy->cpuinfo.max_freq;
 
  	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
  	 * the default cpufreq governor is neither powersave nor performance.
  	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
  	if (boot_cpu_has(X86_FEATURE_CPPC)) {
  		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1
maintainer
#3 lore raw
Quoted 8 lines · Mario
Quoted 6 lines · Huang Rui
Quoted 5 lines · Perry

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but

Quoted 6 lines
Quoted 2 lines

May I know if the processor is powerful desktop such as threadripper, whether it will be default to 'performance' or 'powersave'?

It's currently defaulting to 'powersave' for desktops and workstations.

Do you think we should adopt performance for these?

Yes, I didn't see any different use cases here between server and threadripper here. Or I missed anything?

Do we have a way to separate them?

Thanks,
Ray

Quoted 41 lines
Quoted 41 lines

Thanks,
Ray

Quoted 36 lines

servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
  drivers/cpufreq/amd-pstate.c | 7 +++++--
  1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
  	policy->max = policy->cpuinfo.max_freq;
 
  	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
  	 * the default cpufreq governor is neither powersave nor performance.
  	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
  	if (boot_cpu_has(X86_FEATURE_CPPC)) {
  		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1
#4 lore raw
Quoted 8 lines · Huang Rui
Quoted 7 lines · Mario
Quoted 6 lines · Huang Rui
Quoted 5 lines · Perry

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

May I know if the processor is powerful desktop such as threadripper, whether it will be default to 'performance' or 'powersave'?

It's currently defaulting to 'powersave' for desktops and workstations.

Do you think we should adopt performance for these?

Yes, I didn't see any different use cases here between server and threadripper here. Or I missed anything?

Workstations and Desktops usually have to go through energy consumption certifications.  Couldn't setting it to performance be inappropriate for those?

Quoted 1 line

Do we have a way to separate them?

If Threadripper identified as

3 Workstation

I'd agree; but I'd think we're going to lump AM4/AM5 desktops along with Threadripper.  So should we still set all those to performance?

Quoted 43 lines

Thanks,
Ray

Quoted 39 lines
Quoted 39 lines

Thanks,
Ray

Quoted 36 lines

servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
   drivers/cpufreq/amd-pstate.c | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
   	policy->max = policy->cpuinfo.max_freq;
 
   	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
   	 * the default cpufreq governor is neither powersave nor performance.
   	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
   	if (boot_cpu_has(X86_FEATURE_CPPC)) {
   		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1
maintainer Acked-by
#5 lore raw
Quoted 15 lines · Mario
Quoted 13 lines · Huang Rui
Quoted 12 lines · Mario
Quoted 8 lines · Huang Rui
Quoted 5 lines · Perry

From: Mario Limonciello <[email protected]>

If a user's configuration doesn't explicitly specify the cpufreq scaling governor then the code currently explicitly falls back to 'powersave'. This default is fine for notebooks and desktops, but

May I know if the processor is powerful desktop such as threadripper, whether it will be default to 'performance' or 'powersave'?

It's currently defaulting to 'powersave' for desktops and workstations.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Do you think we should adopt performance for these?

Yes, I didn't see any different use cases here between server and threadripper here. Or I missed anything?

Workstations and Desktops usually have to go through energy consumption certifications.  Couldn't setting it to performance be inappropriate for those?

Hmm, that makes sense. Energy consumption certification is sufficient reason.

Quoted 9 lines
Quoted 1 line

Do we have a way to separate them?

If Threadripper identified as

3 Workstation

I'd agree; but I'd think we're going to lump AM4/AM5 desktops along with Threadripper.  So should we still set all those to performance?

If we don't have good way to separate them, we can set them to powersave at this moment with your original patches. But I think we would better dig out a method in future.

Please add my Acks for these series in next version.

Quoted 43 lines
Quoted 43 lines

Thanks,
Ray

Quoted 39 lines
Quoted 39 lines

Thanks,
Ray

Quoted 36 lines

servers and undefined machines should default to 'performance'.

Look at the 'preferred_profile' field from the FADT to set this policy accordingly.

---
   drivers/cpufreq/amd-pstate.c | 7 +++++--
   1 file changed, 5 insertions(+), 2 deletions(-)
drivers/cpufreq/amd-pstate.c +5 -2
index ddd346a239e0..c9d296ebf81e 100644
@@ -1102,10 +1102,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
   	policy->max = policy->cpuinfo.max_freq;
 
   	/*
-	 * Set the policy to powersave to provide a valid fallback value in case
+	 * Set the policy to provide a valid fallback value in case
   	 * the default cpufreq governor is neither powersave nor performance.
   	 */
-	policy->policy = CPUFREQ_POLICY_POWERSAVE;
+	if (acpi_pm_profile_server() || acpi_pm_profile_undefined())
+		policy->policy = CPUFREQ_POLICY_PERFORMANCE;
+	else
+		policy->policy = CPUFREQ_POLICY_POWERSAVE;
 
   	if (boot_cpu_has(X86_FEATURE_CPPC)) {
   		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
Signature · 1 line
2.34.1