linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* turbostat: Fix Pkg Power on Zen
@ 2020-12-26 12:13 Kurt Garloff
  2021-02-01  9:01 ` Kurt Garloff
  0 siblings, 1 reply; 6+ messages in thread
From: Kurt Garloff @ 2020-12-26 12:13 UTC (permalink / raw)
  To: Len Brown, LKML

[-- Attachment #1: Type: text/plain, Size: 307 bytes --]

Hi Len,

find attached fix to avoid exiting with -13 on Zen. Patch is against turbostat as included in Linux-5.10.2.
Please merge.

PS: This is probably material for -stable, as it used to work before on Zen (Zen2 aka Ryzen 3000 in my case).

-- 
Kurt Garloff <kurt@garloff.de>
Cologne, Germany


[-- Attachment #2: turbostat-zen-pkgpower-510.diff --]
[-- Type: text/x-patch, Size: 1043 bytes --]

commit b82f8e4cfcfd5d503226ed99b30a68aca25b7e18
Author: Kurt Garloff <kurt@garloff.de>
Date:   Sat Dec 26 13:00:15 2020 +0100

    turbostat: Fix Pkg Power tracking on Zen
    
    AMD Zen processors use a different MSR (MSR_PKG_ENERGY_STAT) than intel
    (MSR_PKG_ENERGY_STATUS) to track package power; however we want to record
    it at the same offset in our package_data.
    offset_to_idx() however only recognized the intel MSR, erroring
    out with -13 on Zen.
    
    With this fix, it will support the Zen MSR.
    Tested successfully on Ryzen 3000.
    
    Signed-off-by: Kurt Garloff <kurt@garloff.de>

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index f3a1746f7f45..eb845421f492 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -325,6 +325,7 @@ int offset_to_idx(int offset)
 	int idx;
 
 	switch (offset) {
+	case MSR_PKG_ENERGY_STAT:
 	case MSR_PKG_ENERGY_STATUS:
 		idx = IDX_PKG_ENERGY;
 		break;

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

* Re: turbostat: Fix Pkg Power on Zen
  2020-12-26 12:13 turbostat: Fix Pkg Power on Zen Kurt Garloff
@ 2021-02-01  9:01 ` Kurt Garloff
  2021-02-01  9:06   ` [PATCH 1/1]: " Kurt Garloff
  2021-03-15 21:54   ` Christian Kastner
  0 siblings, 2 replies; 6+ messages in thread
From: Kurt Garloff @ 2021-02-01  9:01 UTC (permalink / raw)
  To: Len Brown, LKML

Hi Len,

Issue persists on Ryzen in 5.11-rc6:

kvmadmin@KurtSrv2018(//):~ [0]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat
turbostat version 20.09.30 - Len Brown <lenb@kernel.org>
CPUID(0): AuthenticAMD 0x10 CPUID levels; 0x80000023 xlevels; family:model:stepping 0x19:21:0 (25:33:0)
CPUID(1): SSE3 MONITOR - - - TSC MSR - HT -
CPUID(6): APERF, No-TURBO, No-DTS, No-PTM, No-HWP, No-HWPnotify, No-HWPwindow, No-HWPepp, No-HWPpkg, No-EPB
CPUID(7): No-SGX
RAPL: 234 sec. Joule Counter Range, at 280 Watts
/dev/cpu_dma_latency: 2000000000 usec (default)
current_driver: acpi_idle
current_governor: menu
current_governor_ro: menu
cpu22: POLL: CPUIDLE CORE POLL IDLE
cpu22: C1: ACPI FFH MWAIT 0x0
cpu22: C2: ACPI IOPORT 0x414
cpu22: cpufreq driver: acpi-cpufreq
cpu22: cpufreq governor: schedutil
cpufreq boost: 1
cpu0: MSR_RAPL_PWR_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.)
kvmadmin@KurtSrv2018(//):~ [243]$

                            ^^^ Exit code

With the patch:

kvmadmin@KurtSrv2018(//):~ [243]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat   
turbostat version 20.09.30 - Len Brown <lenb@kernel.org>                                                                               
CPUID(0): AuthenticAMD 0x10 CPUID levels; 0x80000023 xlevels; family:model:stepping 0x19:21:0 (25:33:0)
CPUID(1): SSE3 MONITOR - - - TSC MSR - HT -                                                                                            
CPUID(6): APERF, No-TURBO, No-DTS, No-PTM, No-HWP, No-HWPnotify, No-HWPwindow, No-HWPepp, No-HWPpkg, No-EPB         
CPUID(7): No-SGX                                                                                                                       
RAPL: 234 sec. Joule Counter Range, at 280 Watts                                                                                       
/dev/cpu_dma_latency: 2000000000 usec (default)                                                                                        
current_driver: acpi_idle                                                                                                              
current_governor: menu                                                                                                                 
current_governor_ro: menu                                                                                                              
cpu28: POLL: CPUIDLE CORE POLL IDLE                                                                                                    
cpu28: C1: ACPI FFH MWAIT 0x0                                                                                                          
cpu28: C2: ACPI IOPORT 0x414                                                                                                           
cpu28: cpufreq driver: acpi-cpufreq                                                                                                    
cpu28: cpufreq governor: schedutil                                                                                                     
cpufreq boost: 1                                                                                                                       
cpu0: MSR_RAPL_PWR_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.)                       
Core    CPU     Avg_MHz Busy%   Bzy_MHz TSC_MHz IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
-       -       27      1.04    2562    3411    16046   33      2931    12895   0.00    0.85    98.48   1.57    18.81
0       0       12      0.55    2193    3400    885     1       111     757     0.00    1.12    98.42   0.04    18.74
0       16      1       0.05    2351    3400    53      0       3       54      0.00    0.05    99.92      
1       1       20      0.89    2261    3400    478     0       39      427     0.00    0.37    98.80   0.06
1       17      9       0.40    2329    3400    308     0       38      282     0.00    0.35    99.29      
[...]

-- 
Kurt Garloff <kurt@garloff.de>
Cologne, Germany

On 26/12/2020 13:13, Kurt Garloff wrote:
> Hi Len,
>
> find attached fix to avoid exiting with -13 on Zen. Patch is against turbostat as included in Linux-5.10.2.
> Please merge.
>
> PS: This is probably material for -stable, as it used to work before on Zen (Zen2 aka Ryzen 3000 in my case).
>

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

* [PATCH 1/1]: turbostat: Fix Pkg Power on Zen
  2021-02-01  9:01 ` Kurt Garloff
@ 2021-02-01  9:06   ` Kurt Garloff
  2021-03-15 21:54   ` Christian Kastner
  1 sibling, 0 replies; 6+ messages in thread
From: Kurt Garloff @ 2021-02-01  9:06 UTC (permalink / raw)
  To: Len Brown, LKML

commit 5d399d05df42ffcaa2b3836b580631c4024487a0
Author: Kurt Garloff <kurt@garloff.de>
Date:   Mon Feb 1 09:01:47 2021 +0000

    turbostat: Fix Pkg Power tracking on Zen
   
    AMD Zen processors use a different MSR (MSR_PKG_ENERGY_STAT) than intel
    (MSR_PKG_ENERGY_STATUS) to track package power; however we want to record
    it at the same offset in our package_data.
    offset_to_idx() however only recognized the intel MSR, erroring
    out with -13 on Zen.
   
    With this fix, it will support the Zen MSR.
    Tested successfully on Ryzen 3000 & 5000.
   
    Signed-off-by: Kurt Garloff <kurt@garloff.de>

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 389ea5209a83..cb830e73d899 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -325,6 +325,7 @@ int offset_to_idx(int offset)
     int idx;
 
     switch (offset) {
+    case MSR_PKG_ENERGY_STAT:
     case MSR_PKG_ENERGY_STATUS:
         idx = IDX_PKG_ENERGY;
         break;

-- 
Kurt Garloff <kurt@garloff.de>
Cologne, Germany


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

* Re: turbostat: Fix Pkg Power on Zen
  2021-02-01  9:01 ` Kurt Garloff
  2021-02-01  9:06   ` [PATCH 1/1]: " Kurt Garloff
@ 2021-03-15 21:54   ` Christian Kastner
  2021-03-24 12:37     ` Salvatore Bonaccorso
  1 sibling, 1 reply; 6+ messages in thread
From: Christian Kastner @ 2021-03-15 21:54 UTC (permalink / raw)
  To: Kurt Garloff, Len Brown, LKML

Hi,

On 01.02.21 10:01, Kurt Garloff wrote:
> Issue persists on Ryzen in 5.11-rc6:
> 
> kvmadmin@KurtSrv2018(//):~ [0]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat
> [...]
> kvmadmin@KurtSrv2018(//):~ [243]$
> 
>                             ^^^ Exit code
> 
> With the patch:
> 
> kvmadmin@KurtSrv2018(//):~ [243]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat   
> [...]                   
> Core    CPU     Avg_MHz Busy%   Bzy_MHz TSC_MHz IRQ     POLL    C1      C2      POLL%   C1%     C2%     CorWatt PkgWatt
> -       -       27      1.04    2562    3411    16046   33      2931    12895   0.00    0.85    98.48   1.57    18.81
> 0       0       12      0.55    2193    3400    885     1       111     757     0.00    1.12    98.42   0.04    18.74
> 0       16      1       0.05    2351    3400    53      0       3       54      0.00    0.05    99.92      
> 1       1       20      0.89    2261    3400    478     0       39      427     0.00    0.37    98.80   0.06
> 1       17      9       0.40    2329    3400    308     0       38      282     0.00    0.35    99.29      
> [...]

I was seeing the same issue (no stats, program just exits with 243), and
Kurt's simple patch resolved it for me.

Best,
Christian

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

* Re: turbostat: Fix Pkg Power on Zen
  2021-03-15 21:54   ` Christian Kastner
@ 2021-03-24 12:37     ` Salvatore Bonaccorso
  2021-03-24 14:39       ` Doug Smythies
  0 siblings, 1 reply; 6+ messages in thread
From: Salvatore Bonaccorso @ 2021-03-24 12:37 UTC (permalink / raw)
  To: Len Brown; +Cc: Christian Kastner, Kurt Garloff, LKML, linux-pm

Hi Len,

On Mon, Mar 15, 2021 at 10:54:24PM +0100, Christian Kastner wrote:
> Hi,
> 
> On 01.02.21 10:01, Kurt Garloff wrote:
> > Issue persists on Ryzen in 5.11-rc6:
> > 
> > kvmadmin@KurtSrv2018(//):~ [0]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat
> > [...]
> > kvmadmin@KurtSrv2018(//):~ [243]$
> > 
> > ?????????????????????????????????????????????????????? ^^^ Exit code
> > 
> > With the patch:
> > 
> > kvmadmin@KurtSrv2018(//):~ [243]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat??????
> > [...]???????????????????????????????????? 
> > Core?????? CPU???????? Avg_MHz Busy%???? Bzy_MHz TSC_MHz IRQ???????? POLL?????? C1?????????? C2?????????? POLL%???? C1%???????? C2%???????? CorWatt PkgWatt
> > -???????????? -???????????? 27?????????? 1.04?????? 2562?????? 3411?????? 16046???? 33?????????? 2931?????? 12895???? 0.00?????? 0.85?????? 98.48???? 1.57?????? 18.81
> > 0???????????? 0???????????? 12?????????? 0.55?????? 2193?????? 3400?????? 885???????? 1???????????? 111???????? 757???????? 0.00?????? 1.12?????? 98.42???? 0.04?????? 18.74
> > 0???????????? 16?????????? 1???????????? 0.05?????? 2351?????? 3400?????? 53?????????? 0???????????? 3???????????? 54?????????? 0.00?????? 0.05?????? 99.92????????????
> > 1???????????? 1???????????? 20?????????? 0.89?????? 2261?????? 3400?????? 478???????? 0???????????? 39?????????? 427???????? 0.00?????? 0.37?????? 98.80???? 0.06
> > 1???????????? 17?????????? 9???????????? 0.40?????? 2329?????? 3400?????? 308???????? 0???????????? 38?????????? 282???????? 0.00?????? 0.35?????? 99.29????????????
> > [...]
> 
> I was seeing the same issue (no stats, program just exits with 243), and
> Kurt's simple patch resolved it for me.

Does Kurt's patch seems good to you and can be applied or is there
anything missing?

Regards,
Salvatore

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

* Re: turbostat: Fix Pkg Power on Zen
  2021-03-24 12:37     ` Salvatore Bonaccorso
@ 2021-03-24 14:39       ` Doug Smythies
  0 siblings, 0 replies; 6+ messages in thread
From: Doug Smythies @ 2021-03-24 14:39 UTC (permalink / raw)
  To: Salvatore Bonaccorso, Christian Kastner, Kurt Garloff
  Cc: Len Brown, LKML, Linux PM list, dsmythies

On Wed, Mar 24, 2021 at 5:38 AM Salvatore Bonaccorso <carnil@debian.org> wrote:
> On Mon, Mar 15, 2021 at 10:54:24PM +0100, Christian Kastner wrote:
> > On 01.02.21 10:01, Kurt Garloff wrote:
> > > Issue persists on Ryzen in 5.11-rc6:
> > > kvmadmin@KurtSrv2018(//):~ [0]$ sudo /casa/src/linux-stable/tools/power/x86/turbostat/turbostat

... deleted stuff that doesn't display properly ...

> > I was seeing the same issue (no stats, program just exits with 243), and
> > Kurt's simple patch resolved it for me.
>
> Does Kurt's patch seems good to you and can be applied or is there
> anything missing?

There were multiple patch submissions. Chen Yu kindly merged them into
one, which was put out for testing a couple of weeks ago. Try it and
report back. I'll forward it in a moment.

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

end of thread, other threads:[~2021-03-24 14:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-26 12:13 turbostat: Fix Pkg Power on Zen Kurt Garloff
2021-02-01  9:01 ` Kurt Garloff
2021-02-01  9:06   ` [PATCH 1/1]: " Kurt Garloff
2021-03-15 21:54   ` Christian Kastner
2021-03-24 12:37     ` Salvatore Bonaccorso
2021-03-24 14:39       ` Doug Smythies

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).