turbostat doesn't work with AMD Cezanne APUs

Bug #1928183 reported by David Bartley
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Fix Released
Undecided
Unassigned
Hirsute
Fix Committed
Undecided
Unassigned

Bug Description

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=985681 describes the issue and necessary cherry-pick (https://git.kernel.org/linus/301b1d3a9104f4f3a8ab4171cf88d0f55d632b41).

ProblemType: Bug
DistroRelease: Ubuntu 21.04
Package: linux-tools-common 5.11.0-17.18
ProcVersionSignature: Ubuntu 5.11.0-17.18-generic 5.11.12
Uname: Linux 5.11.0-17-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.11-0ubuntu65
Architecture: amd64
AudioDevicesInUse:
 USER PID ACCESS COMMAND
 /dev/snd/controlC1: bartle 2287 F.... pulseaudio
 /dev/snd/controlC0: bartle 2287 F.... pulseaudio
CasperMD5CheckResult: unknown
CurrentDesktop: GNOME-Flashback:GNOME
Date: Wed May 12 01:04:15 2021
MachineType: To Be Filled By O.E.M. To Be Filled By O.E.M.
PackageArchitecture: all
ProcFB: 0 amdgpudrmfb
ProcKernelCmdLine: BOOT_IMAGE=/boot/vmlinuz-5.11.0-17-generic root=UUID=27b86d91-8e89-49da-ad17-45901581ce2f ro
RelatedPackageVersions:
 linux-restricted-modules-5.11.0-17-generic N/A
 linux-backports-modules-5.11.0-17-generic N/A
 linux-firmware 1.197
RfKill:
 0: phy0: Wireless LAN
  Soft blocked: no
  Hard blocked: yes
SourcePackage: linux
UpgradeStatus: Upgraded to hirsute on 2021-04-22 (19 days ago)
dmi.bios.date: 04/23/2021
dmi.bios.release: 5.17
dmi.bios.vendor: American Megatrends International, LLC.
dmi.bios.version: P2.10
dmi.board.name: B550 Phantom Gaming-ITX/ax
dmi.board.vendor: ASRock
dmi.chassis.asset.tag: To Be Filled By O.E.M.
dmi.chassis.type: 3
dmi.chassis.vendor: To Be Filled By O.E.M.
dmi.chassis.version: To Be Filled By O.E.M.
dmi.modalias: dmi:bvnAmericanMegatrendsInternational,LLC.:bvrP2.10:bd04/23/2021:br5.17:svnToBeFilledByO.E.M.:pnToBeFilledByO.E.M.:pvrToBeFilledByO.E.M.:rvnASRock:rnB550PhantomGaming-ITX/ax:rvr:cvnToBeFilledByO.E.M.:ct3:cvrToBeFilledByO.E.M.:
dmi.product.family: To Be Filled By O.E.M.
dmi.product.name: To Be Filled By O.E.M.
dmi.product.sku: To Be Filled By O.E.M.
dmi.product.version: To Be Filled By O.E.M.
dmi.sys.vendor: To Be Filled By O.E.M.

Revision history for this message
David Bartley (dtbartle) wrote :
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Status changed to Confirmed

This change was made by a bot.

Changed in linux (Ubuntu):
status: New → Confirmed
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Hello,
thanks for the bug report, can you give this 5.11 Hirsute kernel a try?
https://people.canonical.com/~phlin/kernel/lp-1928183-turbostat-cezanne/

Changed in linux (Ubuntu Hirsute):
status: New → Incomplete
Revision history for this message
David Bartley (dtbartle) wrote :

Nope, still doesn't work (specifically after installing the linux-tools-common deb). I'm assuming that just included the cherry-pick mentioned earlier?

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Hum...
yes this kernel contains 5.11.0-18 from the master-next branch + the commit mentioned in your bug description:

ubuntu-hirsute [master-next]$ git log --oneline
d96cbcb tools/power/turbostat: Fix turbostat for AMD Zen CPUs
8c01482 UBUNTU: Ubuntu-5.11.0-18.19

commit d96cbcb71e2a47f240dcadfc498db278fb2a0b56
Author: Bas Nieuwenhuizen <email address hidden>
Date: Wed Apr 28 17:09:03 2021 +0800

    tools/power/turbostat: Fix turbostat for AMD Zen CPUs

    BugLink: https://bugs.launchpad.net/bugs/1928183

    It was reported that on Zen+ system turbostat started exiting,
    which was tracked down to the MSR_PKG_ENERGY_STAT read failing because
    offset_to_idx wasn't returning a non-negative index.

    This patch combined the modification from Bingsong Si and
    Bas Nieuwenhuizen and addd the MSR to the index system as alternative for
    MSR_PKG_ENERGY_STATUS.

    Fixes: 9972d5d84d76 ("tools/power turbostat: Enable accumulate RAPL display")
    Reported-by: youling257 <email address hidden>
    Tested-by: youling257 <email address hidden>
    Tested-by: Kurt Garloff <email address hidden>
    Tested-by: Bingsong Si <email address hidden>
    Tested-by: Artem S. Tashkinov <email address hidden>
    Co-developed-by: Bingsong Si <email address hidden>
    Co-developed-by: Terry Bowman <email address hidden>
    Signed-off-by: Bas Nieuwenhuizen <email address hidden>
    Reviewed-by: Chen Yu <email address hidden>
    Signed-off-by: Len Brown <email address hidden>
    (cherry picked from commit 301b1d3a9104f4f3a8ab4171cf88d0f55d632b41)
    Signed-off-by: Po-Hsu Lin <email address hidden>

BTW it looks like you will need to install more than just linux-tools-common deb. On a 21.04 clean install, if I just install linux-tools-common the turbostat command will complain about:
$ turbostat
WARNING: turbostat not found for kernel 5.11.0-17

  You may need to install the following packages for this specific kernel:
    linux-tools-5.11.0-17-generic
    linux-cloud-tools-5.11.0-17-generic

I will have to install 5.11.0-18 kernel/header/module/module-extras debs and other two tools-5.11 deb files to make it work on 5.11.0-18
Can you give it a try?
Thanks

Revision history for this message
David Bartley (dtbartle) wrote :

Nope, still didn't work :(. I wonder if there was some subsequent patch as well? The version I have working is built off of master.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Hi David,

I found a laptop with AMD Ryzen 5 APU and gave it a try, before this patch turbostat will terminate with return code 243:

Welcome to Ubuntu Impish Indri (development branch) (GNU/Linux 5.11.0-16-generic x86_64)
$ sudo turbostat
turbostat version 20.09.30 - Len Brown <email address hidden>
CPUID(0): AuthenticAMD 0x10 CPUID levels; 0x80000020 xlevels; family:model:stepping 0x17:60:1 (23:96:1)
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
cpu4: POLL: CPUIDLE CORE POLL IDLE
cpu4: C1: ACPI FFH MWAIT 0x0
cpu4: C2: ACPI IOPORT 0x414
cpu4: C3: ACPI IOPORT 0x415
cpu4: cpufreq driver: acpi-cpufreq
cpu4: cpufreq governor: schedutil
cpufreq boost: 1
cpu0: MSR_RAPL_PWR_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.)
$ echo $?
243

After installing debs from https://people.canonical.com/~phlin/kernel/lp-1928183-turbostat-cezanne/ and reboot to 5.11.0-18, the turbostat command seems to be working (not terminate early with 243):
$ sudo turbostat
turbostat version 20.09.30 - Len Brown <email address hidden>
CPUID(0): AuthenticAMD 0x10 CPUID levels; 0x80000020 xlevels; family:model:stepping 0x17:60:1 (23:96:1)
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
cpu4: POLL: CPUIDLE CORE POLL IDLE
cpu4: C1: ACPI FFH MWAIT 0x0
cpu4: C2: ACPI IOPORT 0x414
cpu4: C3: ACPI IOPORT 0x415
cpu4: cpufreq driver: acpi-cpufreq
cpu4: 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 C3 POLL% C1% C2% C3% CorWatt PkgWatt
- - 2 0.08 1920 3716 542 22 67 0 457 0.00 0.06 0.00 99.81 0.01 3.66
0 0 2 0.10 1873 3717 50 0 3 0 48 0.00 0.04 0.00 99.84 0.00 3.66
0 1 0 0.03 1860 3717 15 0 0 0 15 0.00 0.00 0.00 99.93
1 2 1 0.04 2759 3717 28 0 2 0 26 0.00 0.01 0.00 99.91 0.00
1 3 0 0.02 2636 3717 12 1 1 0 10 0.00 0.01 0.00 99.93
2 4 1 0.02 3079 3717 22 1 6 0 15 0.00 0.01 0.00 99.92 0.00
2 5 1 0.04 2790 3717 30 0 13 0 20 0.00 0.37 0.00 99.55
4 6 2 0.14 1738 3717 74 4 12 0 60 0.00 0.07 0.00 99.79 0.00
4 7 2 0.10 1747 3717 48 4 9 0 35 0.02 0.05 0.00 99.82
5 8 1 0.04 2305 3717 19 0 0 0 19 0.00 0.00 0.00 99.93 0.00
5 9 2 0.09 1876 3717 46 3 5 0 38 0.00 0.04 0.00 99.84
6 10 2 0.09 2114 3717 50 4 7 0 39 0.02 0.07 0.00 99.81 0.00
6 11 5 0.31 1657 3717 148 5 9 0 132 0.01 0.08 0.00 99.65

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

This patch will be applied via stable update, bug 1928857

Changed in linux (Ubuntu):
status: Confirmed → Fix Released
Changed in linux (Ubuntu Hirsute):
status: Incomplete → Fix Committed
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.