mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dhananjay Ugwekar <Dhananjay.Ugwekar@amd.com>
To: <rafael@kernel.org>, <viresh.kumar@linaro.org>,
	<gautham.shenoy@amd.com>, <mario.limonciello@amd.com>,
	<perry.yuan@amd.com>, <skhan@linuxfoundation.org>,
	<li.meng@amd.com>, <ray.huang@amd.com>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Dhananjay Ugwekar" <Dhananjay.Ugwekar@amd.com>
Subject: [PATCH v2 0/2] AMD Pstate driver fixes
Date: Tue, 2 Jul 2024 08:14:12 +0000	[thread overview]
Message-ID: <20240702081413.5688-1-Dhananjay.Ugwekar@amd.com> (raw)

1. Handle the nominal freq units inconsistency in amd-pstate-ut, which was
leading to the below error on inserting the amd-pstate-ut module.

[ 4982.498864] amd_pstate_ut: 1    amd_pstate_ut_acpi_cpc_valid  success!
[ 4982.498873] amd_pstate_ut: 2    amd_pstate_ut_check_enabled   success!
[ 4982.509151] amd_pstate_ut: 3    amd_pstate_ut_check_perf      success!
[ 4982.509155] amd_pstate_ut: amd_pstate_ut_check_freq cpu0 max=3709000  >= nominal=2401 > lowest_nonlinear=1903000 > min=400000 > 0, the formula is incorrect!
[ 4982.509157] amd_pstate_ut: 4    amd_pstate_ut_check_freq      fail!

2. Setting the scaling_max_freq on shared memory CPPC systems was
broken in amd-pstate-epp driver(amd_pstate=active mode). The
scaling_max_freq value was not being propagated to the shared memory area, 
so the frequency capping was not being honored.

Tested on a AMD Zen3 Milan machine(shared memory CPPC): 

stress-ng is running on the system to keep the CPU utilization at 100%
to test the scaling_max_freq capping.

Before the patch:
We can see below, setting the scaling_max_freq is not taking effect.
 
linux/tools/power/x86/turbostat# ./turbostat --Summary
turbostat version 2023.11.07 - Len Brown <lenb@kernel.org>
[Snip]
cpu0: cpufreq driver: amd-pstate-epp
cpu0: cpufreq governor: performance
[Snip]
Avg_MHz Busy%   Bzy_MHz TSC_MHz IPC     IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
2620    100.00  2620    2026    0.80    164935  0       0       0       0.00    0.00    0.00    176.07  249.18
2580    100.00  2580    1995    0.80    162208  0       0       0       0.00    0.00    0.00    173.27  245.37
2584    100.00  2584    1998    0.79    162379  0       0       0       0.00    0.00    0.00    173.42  245.68
2577    100.00  2577    1996    0.79    162146  0       0       0       0.00    0.00    0.00    173.15  245.41
2578    100.00  2578    1996    0.80    162025  0       0       0       0.00    0.00    0.00    173.07  245.46
2575    100.00  2575    1996    0.80    162115  0       0       0       0.00    0.00    0.00    172.96  245.41
2576    100.00  2576    1996    0.79    161998  0       0       0       0.00    0.00    0.00    172.87  245.32
linux/tools/power/x86/turbostat# echo 2000000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
2000000
linux/tools/power/x86/turbostat# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq | uniq
2000000
linux/tools/power/x86/turbostat# ./turbostat --Summary
turbostat version 2023.11.07 - Len Brown <lenb@kernel.org>
[Snip]
cpu0: cpufreq driver: amd-pstate-epp
cpu0: cpufreq governor: performance
[Snip]
Avg_MHz Busy%   Bzy_MHz TSC_MHz IPC     IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
2620    100.00  2620    2038    0.79    166103  0       0       2       0.00    0.00    0.00    175.44  250.96
2566    100.00  2566    1996    0.79    162038  0       0       0       0.00    0.00    0.00    171.79  245.23
2566    100.00  2566    1996    0.79    162289  0       0       0       0.00    0.00    0.00    171.76  245.59
2571    100.00  2571    1996    0.80    162034  0       0       0       0.00    0.00    0.00    171.69  245.44
2566    100.00  2566    1996    0.79    162179  0       0       0       0.00    0.00    0.00    171.62  245.41
2567    100.00  2567    1996    0.79    162028  0       0       0       0.00    0.00    0.00    171.57  245.46
2567    100.00  2567    1996    0.80    162037  0       0       0       0.00    0.00    0.00    171.53  245.41

After applying the patch:
On setting scaling_max_freq at 2GHz, the CPU frequency gets capped at 2GHz.

linux/tools/power/x86/turbostat# ./turbostat --Summary
turbostat version 2023.11.07 - Len Brown <lenb@kernel.org>
[Snip]
cpu0: cpufreq driver: amd-pstate-epp
cpu0: cpufreq governor: performance
[Snip]
Avg_MHz Busy%   Bzy_MHz TSC_MHz IPC     IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
2551    100.00  2551    1956    0.80    165998  0       0       0       0.00    0.00    0.00    171.34  231.22
2713    100.00  2713    2078    0.79    175801  0       0       0       0.00    0.00    0.00    181.92  266.13
2594    100.00  2594    1991    0.79    162183  0       0       1       0.00    0.00    0.00    173.99  244.50
2606    100.00  2606    2003    0.79    162632  0       0       0       0.00    0.00    0.00    174.81  246.51
2599    100.00  2599    1996    0.79    162168  0       0       0       0.00    0.00    0.00    174.05  245.46
linux/tools/power/x86/turbostat# echo 2000000 | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq
2000000
linux/tools/power/x86/turbostat# cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq | uniq
2000000
linux/tools/power/x86/turbostat# ./turbostat --Summary
turbostat version 2023.11.07 - Len Brown <lenb@kernel.org>
[Snip]
cpu0: cpufreq driver: amd-pstate-epp
cpu0: cpufreq governor: performance
[Snip]
Avg_MHz Busy%   Bzy_MHz TSC_MHz IPC     IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
2010    100.00  2010    2030    0.80    165565  0       0       0       0.00    0.00    0.00    101.22  173.52
1975    100.00  1975    1995    0.80    162042  0       0       0       0.00    0.00    0.00    99.03   169.88
1977    100.00  1977    1998    0.80    162559  0       0       0       0.00    0.00    0.00    99.16   170.20
1976    100.00  1976    1996    0.80    162243  0       0       0       0.00    0.00    0.00    99.09   170.08
1976    100.00  1976    1996    0.80    162490  0       0       0       0.00    0.00    0.00    99.17   170.16
1976    100.00  1976    1996    0.80    162056  0       0       0       0.00    0.00    0.00    99.11   170.17

Dhananjay Ugwekar (2):
  cpufreq/amd-pstate-ut: Convert nominal_freq to khz during comparisons
  cpufreq/amd-pstate: Fix the scaling_max_freq setting on shared memory
    CPPC systems

 drivers/cpufreq/amd-pstate-ut.c | 12 +++++----
 drivers/cpufreq/amd-pstate.c    | 43 ++++++++++++++++++---------------
 2 files changed, 30 insertions(+), 25 deletions(-)

-- 
2.34.1


             reply	other threads:[~2024-07-02  8:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02  8:14 Dhananjay Ugwekar [this message]
2024-07-02  8:14 ` [PATCH v2 1/2] cpufreq/amd-pstate-ut: Convert nominal_freq to khz during comparisons Dhananjay Ugwekar
2024-07-02  8:14 ` [PATCH v2 2/2] cpufreq/amd-pstate: Fix the scaling_max_freq setting on shared memory CPPC systems Dhananjay Ugwekar
2024-07-02 17:49   ` Mario Limonciello
2024-09-03 17:51     ` Jones, Morgan
2024-09-03 17:54       ` Mario Limonciello
2024-09-03 20:07         ` [EXTERNAL] " Jones, Morgan
2024-09-03 20:09           ` Mario Limonciello
2024-09-03 20:51             ` Mario Limonciello
2024-09-03 20:52               ` Jones, Morgan
2024-09-03 22:21               ` Jones, Morgan
2024-09-03 22:24               ` Jones, Morgan
2024-09-04 13:57                 ` Mario Limonciello
2024-09-05 15:11                   ` Mario Limonciello
2024-09-05 21:09                     ` Jones, Morgan
2024-09-05 21:14                       ` linux-6.6.y regression on amd-pstate Mario Limonciello
2024-09-08 14:05                         ` Greg Kroah-Hartman
2024-09-08 14:12                           ` Christian Heusel
2024-09-08 14:29                             ` Greg Kroah-Hartman
2025-07-31 20:44                               ` [EXTERNAL] " Jones, Morgan
2025-08-01 12:32                                 ` Mario Limonciello
2024-09-03 20:52             ` [EXTERNAL] Re: [PATCH v2 2/2] cpufreq/amd-pstate: Fix the scaling_max_freq setting on shared memory CPPC systems Jones, Morgan
2024-07-03  5:46   ` Gautham R.Shenoy
2024-07-02  8:24 ` [PATCH v2 0/2] AMD Pstate driver fixes Dhananjay Ugwekar
2024-07-02 17:54   ` Mario Limonciello

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=20240702081413.5688-1-Dhananjay.Ugwekar@amd.com \
    --to=dhananjay.ugwekar@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=li.meng@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=perry.yuan@amd.com \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=skhan@linuxfoundation.org \
    --cc=viresh.kumar@linaro.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

all inboxes | Powered by JetHome®