lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f1964180-458f-4c22-90f6-bda2aee5dbf8@amd.com>
Date: Tue, 27 Feb 2024 09:36:34 -0600
From: Mario Limonciello <mario.limonciello@....com>
To: Meng Li <li.meng@....com>, "Rafael J . Wysocki"
 <rafael.j.wysocki@...el.com>, Huang Rui <ray.huang@....com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, x86@...nel.org,
 linux-acpi@...r.kernel.org, Shuah Khan <skhan@...uxfoundation.org>,
 linux-kselftest@...r.kernel.org, Nathan Fontenot <nathan.fontenot@....com>,
 Deepak Sharma <deepak.sharma@....com>,
 Alex Deucher <alexander.deucher@....com>,
 Shimmer Huang <shimmer.huang@....com>, Perry Yuan <Perry.Yuan@....com>,
 Xiaojian Du <Xiaojian.Du@....com>, Viresh Kumar <viresh.kumar@...aro.org>,
 Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH] cpufreq: amd-pstate: adjust min/max limit perf

On 2/27/2024 01:39, Meng Li wrote:
> The min/max limit perf values calculated based on frequency
> may exceed the reasonable range of perf(highest perf, lowest perf).
> 
> Signed-off-by: Meng Li <li.meng@....com>
Reviewed-by: Mario Limonciello <mario.limonciello@....com>
> ---
>   drivers/cpufreq/amd-pstate.c | 15 ++++++++++++++-
>   1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index aa5e57e27d2b..2015c9fcc3c9 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -484,12 +484,19 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy)
>   
>   static int amd_pstate_update_min_max_limit(struct cpufreq_policy *policy)
>   {
> -	u32 max_limit_perf, min_limit_perf;
> +	u32 max_limit_perf, min_limit_perf, lowest_perf;
>   	struct amd_cpudata *cpudata = policy->driver_data;
>   
>   	max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
>   	min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
>   
> +	lowest_perf = READ_ONCE(cpudata->lowest_perf);
> +	if (min_limit_perf < lowest_perf)
> +		min_limit_perf = lowest_perf;
> +
> +	if (max_limit_perf < min_limit_perf)
> +		max_limit_perf = min_limit_perf;
> +
>   	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
>   	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
>   	WRITE_ONCE(cpudata->max_limit_freq, policy->max);
> @@ -1387,6 +1394,12 @@ static void amd_pstate_epp_update_limit(struct cpufreq_policy *policy)
>   	max_limit_perf = div_u64(policy->max * cpudata->highest_perf, cpudata->max_freq);
>   	min_limit_perf = div_u64(policy->min * cpudata->highest_perf, cpudata->max_freq);
>   
> +	if (min_limit_perf < min_perf)
> +		min_limit_perf = min_perf;
> +
> +	if (max_limit_perf < min_limit_perf)
> +		max_limit_perf = min_limit_perf;
> +
>   	WRITE_ONCE(cpudata->max_limit_perf, max_limit_perf);
>   	WRITE_ONCE(cpudata->min_limit_perf, min_limit_perf);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ