linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Meng, Li (Jassmine)" <Li.Meng@amd.com>
To: Lucas Lee Jing Yi <lucasleeeeeeeee@gmail.com>,
	"rafael@kernel.org" <rafael@kernel.org>
Cc: "Yuan, Perry" <Perry.Yuan@amd.com>,
	"Du, Xiaojian" <Xiaojian.Du@amd.com>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"Sharma, Deepak" <Deepak.Sharma@amd.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kselftest@vger.kernel.org"
	<linux-kselftest@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"Limonciello, Mario" <Mario.Limonciello@amd.com>,
	"Fontenot, Nathan" <Nathan.Fontenot@amd.com>,
	"oleksandr@natalenko.name" <oleksandr@natalenko.name>,
	"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>,
	"Huang, Ray" <Ray.Huang@amd.com>,
	"Huang, Shimmer" <Shimmer.Huang@amd.com>,
	"skhan@linuxfoundation.org" <skhan@linuxfoundation.org>,
	"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: RE: [PATCH] [PATCH] amd_pstate: fix erroneous highest_perf value on some CPUs
Date: Tue, 20 Feb 2024 07:23:09 +0000	[thread overview]
Message-ID: <DM4PR12MB63518FB49F94A8445D32780AF7502@DM4PR12MB6351.namprd12.prod.outlook.com> (raw)
In-Reply-To: <20240218161435.38312-2-lucasleeeeeeeee@gmail.com>

[AMD Official Use Only - General]

Hi Lucas:

> -----Original Message-----
> From: Lucas Lee Jing Yi <lucasleeeeeeeee@gmail.com>
> Sent: Monday, February 19, 2024 12:11 AM
> To: rafael@kernel.org
> Cc: Yuan, Perry <Perry.Yuan@amd.com>; Du, Xiaojian
> <Xiaojian.Du@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; bp@alien8.de; Sharma, Deepak
> <Deepak.Sharma@amd.com>; Meng, Li (Jassmine) <Li.Meng@amd.com>;
> linux-acpi@vger.kernel.org; linux-kernel@vger.kernel.org; linux-
> kselftest@vger.kernel.org; linux-pm@vger.kernel.org; Limonciello, Mario
> <Mario.Limonciello@amd.com>; Fontenot, Nathan
> <Nathan.Fontenot@amd.com>; oleksandr@natalenko.name;
> rafael.j.wysocki@intel.com; Huang, Ray <Ray.Huang@amd.com>; Huang,
> Shimmer <Shimmer.Huang@amd.com>; skhan@linuxfoundation.org;
> viresh.kumar@linaro.org; x86@kernel.org; Lucas Lee Jing Yi
> <lucasleeeeeeeee@gmail.com>
> Subject: [PATCH] [PATCH] amd_pstate: fix erroneous highest_perf value on
> some CPUs
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> On a Ryzen 7840HS the highest_perf value is 196, not 166 as AMD assumed.
> This leads to the advertised max clock speed to only be 4.35ghz instead of
> 5.14ghz , leading to a large degradation in performance.
>
> Fix the broken assumption and revert back to the old logic for getting
> highest_perf.
>
> TEST:
> Geekbench 6 Before Patch:
> Single Core:    2325 (-22%)!
> Multi Core:     11335 (-10%)
>
> Geekbench 6 AFTER Patch:
> Single Core:    2635
> Multi Core:     12487
>
> Signed-off-by: Lucas Lee Jing Yi <lucasleeeeeeeee@gmail.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 08e112444c27..54df68773620 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -50,7 +50,6 @@
>
>  #define AMD_PSTATE_TRANSITION_LATENCY  20000
>  #define AMD_PSTATE_TRANSITION_DELAY    1000
> -#define AMD_PSTATE_PREFCORE_THRESHOLD  166
>
>  /*
>   * TODO: We need more time to fine tune processors with shared memory
> solution @@ -299,15 +298,12 @@ static int pstate_init_perf(struct
> amd_cpudata *cpudata)
>                                      &cap1);
>         if (ret)
>                 return ret;
> -
> -       /* For platforms that do not support the preferred core feature, the
> -        * highest_pef may be configured with 166 or 255, to avoid max
> frequency
> -        * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1)
> value as
> -        * the default max perf.
> +
> +       /* Some CPUs have different highest_perf from others, it is safer
> +        * to read it than to assume some erroneous value, leading to
> performance issues.
>          */
> -       if (cpudata->hw_prefcore)
> -               highest_perf = AMD_PSTATE_PREFCORE_THRESHOLD;
> -       else
> +       highest_perf = amd_get_highest_perf();
> +       if(highest_perf > AMD_CPPC_HIGHEST_PERF(cap1))
>                 highest_perf = AMD_CPPC_HIGHEST_PERF(cap1);
>
>         WRITE_ONCE(cpudata->highest_perf, highest_perf); @@ -329,9 +325,11
> @@ static int cppc_init_perf(struct amd_cpudata *cpudata)
>         if (ret)
>                 return ret;
>
> -       if (cpudata->hw_prefcore)
> -               highest_perf = AMD_PSTATE_PREFCORE_THRESHOLD;
> -       else
> +       /* Some CPUs have different highest_perf from others, it is safer
> +        * to read it than to assume some erroneous value, leading to
> performance issues.
> +        */
> +       highest_perf = amd_get_highest_perf();
> +       if(highest_perf > cppc_perf.highest_perf)
>                 highest_perf = cppc_perf.highest_perf;
>
>         WRITE_ONCE(cpudata->highest_perf, highest_perf);
> --
> 2.43.2
[Meng, Li (Jassmine)]
Reviewed-by: Li Meng < li.meng@amd.com>

  reply	other threads:[~2024-02-20  7:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19  9:04 [PATCH V14 0/7] amd-pstate preferred core Meng Li
2024-01-19  9:04 ` [PATCH V14 1/7] x86: Drop CPU_SUP_INTEL from SCHED_MC_PRIO for the expansion Meng Li
2024-01-19  9:04 ` [PATCH V14 2/7] ACPI: CPPC: Add get the highest performance cppc control Meng Li
2024-01-19  9:04 ` [PATCH V14 3/7] cpufreq: amd-pstate: Enable amd-pstate preferred core supporting Meng Li
2024-01-19  9:04 ` [PATCH V14 4/7] cpufreq: Add a notification message that the highest perf has changed Meng Li
2024-01-19  9:05 ` [PATCH V14 5/7] cpufreq: amd-pstate: Update amd-pstate preferred core ranking dynamically Meng Li
2024-01-19  9:05 ` [PATCH V14 6/7] Documentation: amd-pstate: introduce amd-pstate preferred core Meng Li
2024-01-19  9:05 ` [PATCH V14 7/7] Documentation: introduce amd-pstate preferrd core mode kernel command line options Meng Li
2024-01-29 15:18 ` [PATCH V14 0/7] amd-pstate preferred core Rafael J. Wysocki
2024-01-29 15:33   ` Borislav Petkov
2024-01-31 13:58     ` Rafael J. Wysocki
2024-02-18 16:10       ` Lucas Lee Jing Yi
2024-02-18 16:10         ` [PATCH] [PATCH] amd_pstate: fix erroneous highest_perf value on some CPUs Lucas Lee Jing Yi
2024-02-20  7:23           ` Meng, Li (Jassmine) [this message]
2024-02-20  9:02           ` Oleksandr Natalenko
2024-02-21 17:19             ` Lucas Lee Jing Yi
2024-02-21 17:19               ` Lucas Lee Jing Yi
2024-02-21 18:47                 ` Mario Limonciello
2024-02-19  1:02         ` [PATCH V14 0/7] amd-pstate preferred core Meng, Li (Jassmine)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM4PR12MB63518FB49F94A8445D32780AF7502@DM4PR12MB6351.namprd12.prod.outlook.com \
    --to=li.meng@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Deepak.Sharma@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Nathan.Fontenot@amd.com \
    --cc=Perry.Yuan@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=Shimmer.Huang@amd.com \
    --cc=Xiaojian.Du@amd.com \
    --cc=bp@alien8.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lucasleeeeeeeee@gmail.com \
    --cc=oleksandr@natalenko.name \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=viresh.kumar@linaro.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).