Skip to contentSkip to conversation

cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor

PATCH Superseded Perry Yuan 2 participants 3 messages Jul 7, 2022 – Jul 9, 2022

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Perry Yuan

author reviewer
#0 lore raw

PATCH 7/12 cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor

The patch will fix the invalid desired perf value for powersave governor. This issue is found when testing on one AMD EPYC system, the actual des_perf is smaller than the min_perf value, that is invalid value. because the min_perf is the lowest_perf system can support in idle state.

---
 drivers/cpufreq/amd-pstate.c | 1 +
 1 file changed, 1 insertion(+)
drivers/cpufreq/amd-pstate.c +1 -0
index 7c51f4125263..154eed849f38 100644
@@ -317,6 +317,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
 	des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf,
 				     cpudata->max_freq);
 
+	des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
 	cpufreq_freq_transition_begin(policy, &freqs);
 	amd_pstate_update(cpudata, min_perf, des_perf,
 			  max_perf, false);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 16 lines · Perry Yuan

The patch will fix the invalid desired perf value for powersave governor. This issue is found when testing on one AMD EPYC system, the actual des_perf is smaller than the min_perf value, that is invalid value. because the min_perf is the lowest_perf system can support in idle state.

---
 drivers/cpufreq/amd-pstate.c | 1 +
 1 file changed, 1 insertion(+)
drivers/cpufreq/amd-pstate.c +0 -0
index 7c51f4125263..154eed849f38 100644

drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy *policy, · line 323

Quoted 7 lines
drivers/cpufreq/amd-pstate.c +1 -0
@@ -317,6 +317,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
 	des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf,
 				     cpudata->max_freq);
 
+	des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
 	cpufreq_freq_transition_begin(policy, &freqs);
 	amd_pstate_update(cpudata, min_perf, des_perf,
 			  max_perf, false);

The clamping of the desired perf value should be moved to amd_pstate_update(). The only other caller of amd_pstate_update() is amd_pstate_adjust_perf() which already clamps the desired perf value before making the call.

-Nathan

author reviewer
#2 lore raw

[AMD Official Use Only - General]

Hi Nathan:

Quoted 48 lines

-----Original Message-----
From: Fontenot, Nathan <[email protected]>
Sent: Friday, July 8, 2022 3:57 AM
To: Yuan, Perry <[email protected]>; [email protected]; [email protected]; Huang, Ray <[email protected]>; Rafael J. Wysocki <[email protected]>; [email protected]; linux- [email protected]
Cc: Sharma, Deepak <[email protected]>; Limonciello, Mario <[email protected]>; Fontenot, Nathan <[email protected]>; Deucher, Alexander <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Huang, Shimmer <[email protected]>; Du, Xiaojian <[email protected]>; Meng, Li (Jassmine) <[email protected]>
Subject: Re: [PATCH 07/12] cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor

Quoted 6 lines · Perry Yuan

The patch will fix the invalid desired perf value for powersave governor. This issue is found when testing on one AMD EPYC system, the actual des_perf is smaller than the min_perf value, that is invalid value. because the min_perf is the lowest_perf system can support in idle state.

Quoted 7 lines
---
 drivers/cpufreq/amd-pstate.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/drivers/cpufreq/amd-pstate.c index 7c51f4125263..154eed849f38

100644

drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy

Quoted 3 lines
drivers/cpufreq/amd-pstate.c +0 -0
@@ -317,6 +317,7 @@ static int amd_pstate_target(struct cpufreq_policy

*policy,

drivers/cpufreq/amd-pstate.c static int amd_pstate_target(struct cpufreq_policy *policy, · line 323

Quoted 7 lines
drivers/cpufreq/amd-pstate.c +1 -0
 	des_perf = DIV_ROUND_CLOSEST(target_freq * cap_perf,
 				     cpudata->max_freq);
 
+	des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
 	cpufreq_freq_transition_begin(policy, &freqs);
 	amd_pstate_update(cpudata, min_perf, des_perf,
 			  max_perf, false);

The clamping of the desired perf value should be moved to amd_pstate_update(). The only other caller of amd_pstate_update() is amd_pstate_adjust_perf() which already clamps the desired perf value before making the call.

Quoted 1 line

-Nathan

Thanks for your suggestion.
Add this change into V2.

Perry.