mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore
@ 2024-07-02 17:15 Mario Limonciello
  2024-07-02 17:15 ` [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported Mario Limonciello
  2024-07-03  8:59 ` [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Gautham R.Shenoy
  0 siblings, 2 replies; 4+ messages in thread
From: Mario Limonciello @ 2024-07-02 17:15 UTC (permalink / raw)
  To: Gautham R . Shenoy
  Cc: Meng Li, Perry Yuan, open list:AMD PSTATE DRIVER, open list,
	Dhananjay Ugwekar, Mario Limonciello

If a system is using preferred cores the highest perf will be inconsistent
as it can change from system events.

Skip the checks for it.

Fixes: e571a5e2068e ("cpufreq: amd-pstate: Update amd-pstate preferred core ranking dynamically")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/cpufreq/amd-pstate-ut.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
index 66b73c308ce6..b7318669485e 100644
--- a/drivers/cpufreq/amd-pstate-ut.c
+++ b/drivers/cpufreq/amd-pstate-ut.c
@@ -160,14 +160,17 @@ static void amd_pstate_ut_check_perf(u32 index)
 			lowest_perf = AMD_CPPC_LOWEST_PERF(cap1);
 		}
 
-		if ((highest_perf != READ_ONCE(cpudata->highest_perf)) ||
-			(nominal_perf != READ_ONCE(cpudata->nominal_perf)) ||
+		if (highest_perf != READ_ONCE(cpudata->highest_perf) && !cpudata->hw_prefcore) {
+			pr_err("%s cpu%d highest=%d %d highest perf doesn't match\n",
+				__func__, cpu, highest_perf, cpudata->highest_perf);
+			goto skip_test;
+		}
+		if ((nominal_perf != READ_ONCE(cpudata->nominal_perf)) ||
 			(lowest_nonlinear_perf != READ_ONCE(cpudata->lowest_nonlinear_perf)) ||
 			(lowest_perf != READ_ONCE(cpudata->lowest_perf))) {
 			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
-			pr_err("%s cpu%d highest=%d %d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n",
-				__func__, cpu, highest_perf, cpudata->highest_perf,
-				nominal_perf, cpudata->nominal_perf,
+			pr_err("%s cpu%d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n",
+				__func__, cpu, nominal_perf, cpudata->nominal_perf,
 				lowest_nonlinear_perf, cpudata->lowest_nonlinear_perf,
 				lowest_perf, cpudata->lowest_perf);
 			goto skip_test;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported
  2024-07-02 17:15 [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Mario Limonciello
@ 2024-07-02 17:15 ` Mario Limonciello
  2024-07-03  8:58   ` Gautham R.Shenoy
  2024-07-03  8:59 ` [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Gautham R.Shenoy
  1 sibling, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2024-07-02 17:15 UTC (permalink / raw)
  To: Gautham R . Shenoy
  Cc: Meng Li, Perry Yuan, open list:AMD PSTATE DRIVER, open list,
	Dhananjay Ugwekar, Mario Limonciello

cpudata->boost_supported will only be configured when a CPU actually
supports core performance boost. Add an extra guard into the check
to ensure it only runs when CPB is present.

Fixes: 14eb1c96e3a3 ("cpufreq: amd-pstate: Add test module for amd-pstate driver")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/cpufreq/amd-pstate-ut.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
index b7318669485e..b011c729fcba 100644
--- a/drivers/cpufreq/amd-pstate-ut.c
+++ b/drivers/cpufreq/amd-pstate-ut.c
@@ -232,21 +232,21 @@ static void amd_pstate_ut_check_freq(u32 index)
 			goto skip_test;
 		}
 
-		if (cpudata->boost_supported) {
-			if ((policy->max == cpudata->max_freq) ||
-					(policy->max == nominal_freq_khz))
-				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
-			else {
+		if (cpu_feature_enabled(X86_FEATURE_CPB)) {
+			if (!cpudata->boost_supported) {
+				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
+				pr_err("%s cpu%d must support boost!\n", __func__, cpu);
+				goto skip_test;
+			}
+			if ((policy->max != cpudata->max_freq) &&
+			    (policy->max != nominal_freq_khz)) {
 				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
 				pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
 					__func__, cpu, policy->max, cpudata->max_freq,
 					nominal_freq_khz);
 				goto skip_test;
 			}
-		} else {
-			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
-			pr_err("%s cpu%d must support boost!\n", __func__, cpu);
-			goto skip_test;
+			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
 		}
 		cpufreq_cpu_put(policy);
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported
  2024-07-02 17:15 ` [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported Mario Limonciello
@ 2024-07-03  8:58   ` Gautham R.Shenoy
  0 siblings, 0 replies; 4+ messages in thread
From: Gautham R.Shenoy @ 2024-07-03  8:58 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Meng Li, Perry Yuan, open list:AMD PSTATE DRIVER, open list,
	Dhananjay Ugwekar, Mario Limonciello

Hello Mario,

Mario Limonciello <mario.limonciello@amd.com> writes:

> cpudata->boost_supported will only be configured when a CPU actually
> supports core performance boost. Add an extra guard into the check
> to ensure it only runs when CPB is present.
>
> Fixes: 14eb1c96e3a3 ("cpufreq: amd-pstate: Add test module for amd-pstate driver")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>  drivers/cpufreq/amd-pstate-ut.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
> index b7318669485e..b011c729fcba 100644
> --- a/drivers/cpufreq/amd-pstate-ut.c
> +++ b/drivers/cpufreq/amd-pstate-ut.c
> @@ -232,21 +232,21 @@ static void amd_pstate_ut_check_freq(u32 index)
>  			goto skip_test;
>  		}
>  
> -		if (cpudata->boost_supported) {
> -			if ((policy->max == cpudata->max_freq) ||
> -					(policy->max == nominal_freq_khz))
> -				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
> -			else {
> +		if (cpu_feature_enabled(X86_FEATURE_CPB)) {
> +			if (!cpudata->boost_supported) {
> +				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
> +				pr_err("%s cpu%d must support boost!\n", __func__, cpu);
> +				goto skip_test;
> +			}
> +			if ((policy->max != cpudata->max_freq) &&
> +			    (policy->max != nominal_freq_khz)) {

Writing a different value into
/sys/devices/system/cpu/cpuX/cpufreq/scaling_max_freq, updates the
policy->max for cpuX.

So if a user runs this test case after someone has changed the
scaling_max_freq, the test case will fail. While this is not due to your
patch, I wonder if this is valid test-case.

>  				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
>  				pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
>  					__func__, cpu, policy->max, cpudata->max_freq,
>  					nominal_freq_khz);
>  				goto skip_test;
>  			}
> -		} else {
> -			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
> -			pr_err("%s cpu%d must support boost!\n", __func__, cpu);
> -			goto skip_test;
> +			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
>  		}
>  		cpufreq_cpu_put(policy);
>  	}
> -- 
> 2.43.0
--
Thanks and Regards
gautham.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore
  2024-07-02 17:15 [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Mario Limonciello
  2024-07-02 17:15 ` [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported Mario Limonciello
@ 2024-07-03  8:59 ` Gautham R.Shenoy
  1 sibling, 0 replies; 4+ messages in thread
From: Gautham R.Shenoy @ 2024-07-03  8:59 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Meng Li, Perry Yuan, open list:AMD PSTATE DRIVER, open list,
	Dhananjay Ugwekar, Mario Limonciello

Mario Limonciello <mario.limonciello@amd.com> writes:

> If a system is using preferred cores the highest perf will be inconsistent
> as it can change from system events.
>
> Skip the checks for it.
>
> Fixes: e571a5e2068e ("cpufreq: amd-pstate: Update amd-pstate preferred core ranking dynamically")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>

> ---
>  drivers/cpufreq/amd-pstate-ut.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
> index 66b73c308ce6..b7318669485e 100644
> --- a/drivers/cpufreq/amd-pstate-ut.c
> +++ b/drivers/cpufreq/amd-pstate-ut.c
> @@ -160,14 +160,17 @@ static void amd_pstate_ut_check_perf(u32 index)
>  			lowest_perf = AMD_CPPC_LOWEST_PERF(cap1);
>  		}
>  
> -		if ((highest_perf != READ_ONCE(cpudata->highest_perf)) ||
> -			(nominal_perf != READ_ONCE(cpudata->nominal_perf)) ||
> +		if (highest_perf != READ_ONCE(cpudata->highest_perf) && !cpudata->hw_prefcore) {
> +			pr_err("%s cpu%d highest=%d %d highest perf doesn't match\n",
> +				__func__, cpu, highest_perf, cpudata->highest_perf);
> +			goto skip_test;
> +		}
> +		if ((nominal_perf != READ_ONCE(cpudata->nominal_perf)) ||
>  			(lowest_nonlinear_perf != READ_ONCE(cpudata->lowest_nonlinear_perf)) ||
>  			(lowest_perf != READ_ONCE(cpudata->lowest_perf))) {
>  			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
> -			pr_err("%s cpu%d highest=%d %d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n",
> -				__func__, cpu, highest_perf, cpudata->highest_perf,
> -				nominal_perf, cpudata->nominal_perf,
> +			pr_err("%s cpu%d nominal=%d %d lowest_nonlinear=%d %d lowest=%d %d, they should be equal!\n",
> +				__func__, cpu, nominal_perf, cpudata->nominal_perf,
>  				lowest_nonlinear_perf, cpudata->lowest_nonlinear_perf,
>  				lowest_perf, cpudata->lowest_perf);
>  			goto skip_test;
> -- 
> 2.43.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-03  9:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-02 17:15 [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Mario Limonciello
2024-07-02 17:15 ` [PATCH 2/2] cpufreq/amd-pstate-ut: Don't fail boost test case if CPB isn't supported Mario Limonciello
2024-07-03  8:58   ` Gautham R.Shenoy
2024-07-03  8:59 ` [PATCH 1/2] cpufreq/amd-pstate-ut: Don't check for highest perf matching on prefcore Gautham R.Shenoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®