AMD P-States

TCWL

Dabbler
Joined
Dec 23, 2023
Messages
11
Has anyone here got amd-pstate working on their box? For some reason I can't get enabled on my system, at this point I am unsure whether the fault is in my bios, kernel or between the keyboard and the chair.

Here's what I did:
  1. Enabled CPPC in bios settings.
  2. Add flag to kernel parameters: midclt call system.advanced.update '{"kernel_extra_options": "amd_pstate=active"}'
  3. Reboot, check if it's working: cpupower frequency-info | grep driver - nope still using driver: acpi-cpufreq
  4. See if the cppc flag is found: lscpu | grep cppc - nope, it is not
I think it's quite a recent feature as far as bios & kernel support goes, so maybe there is just some software glitch currently and there's nothing I can do for now.

All advice and discussion around this topic welcome.
 
Last edited:

LarsR

Guru
Joined
Oct 23, 2020
Messages
719
MY 3700x has only 3 P-States, P0, P1, P2. With Dragonfish and the new 6.6 Kernel there should be support for more p-states, but since dragonfish is still in beta and i only have 1 nas i cant test it.
 

TCWL

Dabbler
Joined
Dec 23, 2023
Messages
11
UPDATE: Got it partially working by supplying amd_pstate=passive kernel flag. The processor cores now idle at 550 Mhz instead of 2200 Mhz as reported by watch -n 1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq, cpupower shows the desired driver: amd-pstate, although lscpu stils does not report cppc.

Still unsure why the active mode does not work. As per what these different modes do, I found this helpful post on bestlinux forums:

From ACPI spec below 3 modes for CPPC can be defined:

1. Non autonomous: OS scaling governor specifies operating frequency/performance level through `Desired Performance` register and PMFW follows that.

2. Guided autonomous: OS scaling governor specifies min and max frequencies/ performance levels through `Minimum Performance` and `Maximum Performance` register, and PMFW can autonomously select an operating frequency in this range.

3. Fully autonomous: OS only hints (via EPP) to PMFW for the required energy performance preference for the workload and PMFW autonomously scales the frequency.

Currently (1) is supported by amd_pstate as passive mode, and (3) is implemented by EPP support[2]. This change is to support (2).

In guided autonomous mode the min_perf is based on the input from the scaling governor. For example, in case of schedutil this value depends on the current utilization. And max_perf is set to max capacity.

To activate guided auto mode ``amd_pstate=guided`` command line parameter has to be passed in the kernel.

To activate fully auto mode ``amd_pstate=active`` command line parameter has to be passed in the kernel.

Need to do more research about the active mode to find the culprit, but this is already better than the default acpi-cpufreq driver.

Also kernel.org has a wealth of useful information:
amd-pstate is the AMD CPU performance scaling driver that introduces a new CPU frequency control mechanism on modern AMD APU and CPU series in Linux kernel. The new mechanism is based on Collaborative Processor Performance Control (CPPC) which provides finer grain frequency management than legacy ACPI hardware P-States. Current AMD CPU/APU platforms are using the ACPI P-states driver to manage CPU frequency and clocks with switching only in 3 P-states. CPPC replaces the ACPI P-states controls and allows a flexible, low-latency interface for the Linux kernel to directly communicate the performance hints to hardware.
 
Last edited:

Haldi

Cadet
Joined
Feb 28, 2024
Messages
8
went with a little help from Reddit: https://old.reddit.com/r/linux/comments/15p4bfs/amd_pstate_and_amd_pstate_epp_scaling_driver/

Running TrueNAS-SCALE-24.04-BETA.1 with Kerne 6.6.10
midclt call system.advanced.update '{"kernel_extra_options": "amd_pstate=guided"}'
switched to guided.

root@NAS[~]# cpupower frequency-info | grep driver
driver: amd-pstate

root@NAS[~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
amd-pstate

root@NAS[~]# watch -n 1 cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq
Every 1.0s: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq /sys/devices/system/cpu/cpu1/... NAS: Thu Mar 14 14:10:44 2024

550000
550000
3592745
550000
550000
550000
550000
3591159
550000
550000
550000
3590266



root@NAS[~]# turbostat
turbostat version 2022.10.04 - Len Brown <lenb@kernel.org>
Kernel command line: BOOT_IMAGE=/ROOT/24.04-BETA.1@/boot/vmlinuz-6.6.10-production+truenas root=ZFS=boot-pool/ROOT/24.04-BETA.1 ro libata.allow_tpm=1 amd_iommu=on iommu=pt kvm_amd.npt=1 kvm_amd.avic=1 intel_iommu=on zfsforce=1 nvme_core.multipath=N amd_pstate=guided
CPUID(0): AuthenticAMD 0x10 CPUID levels
CPUID(1): family:model:stepping 0x19:21:2 (25:33:2) microcode 0x0
CPUID(0x80000000): max_extended_levels: 0x80000023
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 No-Hybrid
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
cpu0: POLL: CPUIDLE CORE POLL IDLE
cpu0: C1: ACPI FFH MWAIT 0x0
cpu0: C2: ACPI IOPORT 0x414
cpu0: cpufreq driver: amd-pstate
cpu0: 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 IPC IRQ POLL C1 C2 POLL% C1% C2% CorWatt PkgWatt
- - 30 0.78 3827 3493 0.67 24339 4177 2159 11635 0.02 0.85 98.39 1.40 19.25
0 0 21 0.57 3710 3493 0.56 1362 4 48 828 0.00 0.25 99.21 0.19 19.25
0 6 29 0.72 4015 3493 0.82 1465 335 117 583 0.02 0.89 98.40
1 1 24 0.63 3735 3493 0.67 1729 2 143 1120 0.00 0.63 98.76 0.25
1 7 45 1.13 3954 3493 0.77 2638 282 249 1401 0.02 0.66 98.23
2 2 21 0.55 3817 3493 0.62 1514 242 255 685 0.01 1.87 97.59 0.26
2 8 38 0.99 3804 3493 0.57 3010 691 313 1314 0.06 1.06 97.98
3 3 21 0.56 3708 3493 0.44 1451 0 165 864 0.00 0.72 98.74 0.23
3 9 34 0.90 3755 3493 0.64 2590 680 215 1026 0.04 1.02 98.10
4 4 19 0.51 3830 3493 0.79 1490 325 130 651 0.02 0.71 98.80 0.25
4 10 41 1.09 3730 3493 0.61 3034 391 226 1633 0.02 1.17 97.77
5 5 30 0.72 4109 3493 0.82 743 14 99 420 0.00 0.40 98.89 0.22
5 11 38 1.01 3733 3493 0.70 3313 1211 199 1110 0.07 0.80 98.22


Before my AMD 5600 never went below 2200Mhz, now it goes to 550Mhz :)

Code:
PowerTOP 2.14     Overview   Idle stats   Frequency stats   Device stats   Tunables   WakeUp


           Pkg(OS)  |            Core(OS) |            CPU(OS) 0   CPU(OS) 6
POLL        0.0%    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
C1          0.8%    | C1          0.7%    | C1          0.8%    0.2 ms  0.6%    0.2 ms
C2         98.3%    | C2         98.4%    | C2         98.3%    5.8 ms 98.5%    5.8 ms

                    |            Core(OS) |            CPU(OS) 1   CPU(OS) 7
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          0.7%    | C1          0.7%    0.2 ms  0.6%    0.2 ms
                    | C2         98.4%    | C2         98.2%    3.6 ms 98.5%    5.1 ms

                    |            Core(OS) |            CPU(OS) 2   CPU(OS) 8
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          1.1%    | C1          1.3%    0.3 ms  1.0%    0.3 ms
                    | C2         97.7%    | C2         97.6%    3.9 ms 97.8%    5.5 ms

                    |            Core(OS) |            CPU(OS) 3   CPU(OS) 9
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          0.8%    | C1          0.6%    0.1 ms  1.0%    0.3 ms
                    | C2         98.3%    | C2         98.4%    3.6 ms 98.1%    4.8 ms

                    |            Core(OS) |            CPU(OS) 4   CPU(OS) 10
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          0.9%    | C1          0.9%    0.3 ms  0.9%    0.2 ms
                    | C2         98.4%    | C2         98.3%    4.7 ms 98.4%    7.0 ms

                    |            Core(OS) |            CPU(OS) 5   CPU(OS) 11
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          0.5%    | C1          0.3%    0.2 ms  0.7%    0.1 ms
                    | C2         98.8%    | C2         98.8%    4.4 ms 98.8%    7.7 ms



PowerTOP 2.14     Overview   Idle stats   Frequency stats   Device stats   Tunables   WakeUp


            Package |             Core    |            CPU 0       CPU 6
Idle        66.4%   | Idle        98.5%   | Idle        99.2%       99.3%
2.15 GHz     0.0%   | 2.15 GHz     0.0%   | 2.15 GHz     0.0%        0.6%
 550 MHz    32.8%   |  550 MHz     1.3%   |  550 MHz     0.7%        0.0%
2.37 GHz     0.0%   | 2.37 GHz     0.0%   | 2.37 GHz     0.0%        0.0%
2.22 GHz     0.0%   | 2.22 GHz     0.0%   | 2.22 GHz     0.0%        0.0%
2.24 GHz     0.0%   | 2.24 GHz     0.0%   | 2.24 GHz     0.0%        0.0%
1.90 GHz     0.0%   | 1.90 GHz     0.0%   | 1.90 GHz     0.0%        0.0%
1.75 GHz     0.0%   | 1.75 GHz     0.0%   | 1.75 GHz     0.0%        0.0%
1.61 GHz     0.0%   | 1.61 GHz     0.0%   | 1.61 GHz     0.0%        0.0%
1475 MHz     0.0%   | 1475 MHz     0.0%   | 1475 MHz     0.0%        0.0%
1357 MHz     0.0%   | 1357 MHz     0.0%   | 1357 MHz     0.0%        0.0%
1265 MHz     0.0%   | 1265 MHz     0.0%   |  772 MHz     0.0%        0.0%
 798 MHz     0.0%   |  798 MHz     0.0%   |  685 MHz     0.0%        0.0%
 772 MHz     0.0%   |  772 MHz     0.0%   |  676 MHz     0.0%        0.0%
 685 MHz     0.0%   |  685 MHz     0.0%   | 2.89 GHz     0.0%        0.0%
 676 MHz     0.0%   |  676 MHz     0.0%   | 2.76 GHz     0.0%        0.0%
2.89 GHz     0.0%   | 2.89 GHz     0.0%   | 3.06 GHz     0.0%        0.0%
2.64 GHz     0.0%   | 2.76 GHz     0.0%   | 2.77 GHz     0.0%        0.0%
2.76 GHz     0.0%   | 3.06 GHz     0.0%   | 3.09 GHz     0.0%        0.0%
3.06 GHz     0.0%   | 2.77 GHz     0.0%   | 2.69 GHz     0.0%        0.0%
2.77 GHz     0.0%   | 3.09 GHz     0.0%   | 2.97 GHz     0.0%        0.0%
3.09 GHz     0.0%   | 2.69 GHz     0.0%   | 4.47 GHz     0.0%        0.0%
2.69 GHz     0.0%   | 2.97 GHz     0.0%   | 3.88 GHz     0.0%        0.0%
2.97 GHz     0.0%   | 4.47 GHz     0.0%   | 3.51 GHz     0.0%        0.0%
4.47 GHz     0.0%   | 3.94 GHz     0.0%   | 3.23 GHz     0.0%        0.0%
3.94 GHz     0.0%   | 3.77 GHz     0.0%   | 3.15 GHz     0.0%        0.0%
2.69 GHz     0.0%   | 4.14 GHz     0.0%   | 3.02 GHz     0.0%        0.0%
1.63 GHz     0.0%   | 3.00 GHz     0.0%   | 2.96 GHz     0.0%        0.0%
4.03 GHz     0.0%   | 2.75 GHz     0.0%   | 2.67 GHz     0.0%        0.0%
3.00 GHz     0.0%   | 3.81 GHz     0.0%   | 2.75 GHz     0.0%        0.0%
1.72 GHz     0.0%   | 3.76 GHz     0.0%   | 2.48 GHz     0.0%        0.0%
3.84 GHz     0.0%   | 3.63 GHz     0.0%   | 2.65 GHz     0.0%        0.0%
3.77 GHz     0.0%   | 3.47 GHz     0.0%   | 1038 MHz     0.0%        0.0%
4.14 GHz     0.0%   | 3.53 GHz     0.0%   | 1.55 GHz     0.0%        0.0%
2.75 GHz     0.0%   | 3.51 GHz     0.0%   | 2.30 GHz     0.0%        0.0%
1.54 GHz     0.0%   | 3.24 GHz     0.0%   | 1187 MHz     0.0%        0.0%
3.76 GHz     0.0%   | 2.94 GHz     0.0%   | 1313 MHz     0.0%        0.0%
3.63 GHz     0.0%   | 2.33 GHz     0.0%   | 2.51 GHz     0.0%        0.0%
3.81 GHz     0.0%   | 2.14 GHz     0.0%   | 2.82 GHz     0.0%        0.0%
3.47 GHz     0.0%   | 3.31 GHz     0.0%   | 2.80 GHz     0.0%        0.0%
3.53 GHz     0.0%   | 2.98 GHz     0.0%   | 2.10 GHz     0.0%        0.0%
3.51 GHz     0.0%   | 2.70 GHz     0.0%   | 1.89 GHz     0.0%        0.0%
3.24 GHz     0.0%   | 1.97 GHz     0.0%   | 2.88 GHz     0.0%        0.0%
3.05 GHz     0.0%   | 2.71 GHz     0.0%   | 2.59 GHz     0.0%        0.0%
3.31 GHz     0.0%   | 2.74 GHz     0.0%   | 1.65 GHz     0.0%        0.0%
3.20 GHz     0.0%   | 2.65 GHz     0.0%   |  698 MHz     0.0%        0.0%
2.94 GHz     0.0%   | 2.53 GHz     0.0%   | 1396 MHz     0.0%        0.0%
2.33 GHz     0.0%   | 1.96 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
1296 MHz     0.0%   | 1.83 GHz     0.0%   | 2.85 GHz     0.0%        0.0%
1191 MHz     0.0%   | 2.49 GHz     0.0%   | 2.73 GHz     0.0%        0.0%
2.14 GHz     0.0%   | 2.52 GHz     0.0%   | 2.79 GHz     0.0%        0.0%
2.82 GHz     0.0%   | 1.68 GHz     0.0%   | 2.76 GHz     0.0%        0.0%


Compared to an old Powertop from Truenas 23.10.2

Code:
PowerTOP 2.14     Overview   Idle stats   Frequency stats   Device stats   Tunables   WakeUp


           Pkg(OS)  |            Core(OS) |            CPU(OS) 0   CPU(OS) 6
POLL        0.0%    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
C1          1.7%    | C1          1.4%    | C1          1.8%    0.2 ms  1.1%    0.2 ms
C2         96.7%    | C2         96.8%    | C2         96.4%    3.3 ms 97.0%    3.3 ms

                    |            Core(OS) |            CPU(OS) 1   CPU(OS) 7
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          2.3%    | C1          2.0%    0.6 ms  2.7%    0.2 ms
                    | C2         96.4%    | C2         96.4%    2.0 ms 96.4%    4.3 ms

                    |            Core(OS) |            CPU(OS) 2   CPU(OS) 8
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          1.4%    | C1          1.6%    0.2 ms  1.1%    0.3 ms
                    | C2         97.0%    | C2         97.6%    4.0 ms 96.4%    5.6 ms

                    |            Core(OS) |            CPU(OS) 3   CPU(OS) 9
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          2.0%    | C1          1.0%    0.2 ms  3.0%    0.1 ms
                    | C2         96.3%    | C2         96.8%    3.1 ms 95.8%    5.3 ms

                    |            Core(OS) |            CPU(OS) 4   CPU(OS) 10
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          1.9%    | C1          2.6%    0.4 ms  1.2%    0.3 ms
                    | C2         95.7%    | C2         95.0%    2.2 ms 96.3%    8.3 ms

                    |            Core(OS) |            CPU(OS) 5   CPU(OS) 11
                    | POLL        0.0%    | POLL        0.0%    0.0 ms  0.0%    0.0 ms
                    | C1          1.2%    | C1          1.9%    0.2 ms  0.5%    0.1 ms
                    | C2         96.9%    | C2         95.8%    3.5 ms 97.9%    4.3 ms



PowerTOP 2.14     Overview   Idle stats   Frequency stats   Device stats   Tunables   WakeUp


            Package |             Core    |            CPU 0       CPU 6
3.50 GHz     1.1%   | 3.50 GHz     0.5%   | 3.50 GHz     0.4%        0.1%
2.81 GHz     0.2%   | 2.81 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
2.21 GHz     8.7%   | 2.21 GHz     2.9%   | 2.21 GHz     1.3%        1.7%
Idle        90.1%   | Idle        96.7%   | Idle        98.3%       98.2%

                    |             Core    |            CPU 1       CPU 7
                    | 3.50 GHz     0.3%   | 3.50 GHz     0.1%        0.2%
                    | 2.81 GHz     0.1%   | 2.81 GHz     0.0%        0.1%
                    | 2.21 GHz     1.8%   | 2.21 GHz     1.3%        0.5%
                    | Idle        97.7%   | Idle        98.5%       99.1%

                    |             Core    |            CPU 2       CPU 8
                    | 3.50 GHz     0.4%   | 3.50 GHz     0.2%        0.2%
                    | 2.81 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
                    | 2.21 GHz     1.9%   | 2.21 GHz     0.5%        1.5%
                    | Idle        97.6%   | Idle        99.2%       98.3%

                    |             Core    |            CPU 3       CPU 9
                    | 3.50 GHz     0.1%   | 3.50 GHz     0.0%        0.1%
                    | 2.81 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
                    | 2.21 GHz     1.8%   | 2.21 GHz     0.9%        1.0%
                    | Idle        98.1%   | Idle        99.0%       98.9%

                    |             Core    |            CPU 4       CPU 10
                    | 3.50 GHz     0.3%   | 3.50 GHz     0.2%        0.0%
                    | 2.81 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
                    | 2.21 GHz     1.2%   | 2.21 GHz     0.9%        0.3%
                    | Idle        98.4%   | Idle        98.8%       99.6%

                    |             Core    |            CPU 5       CPU 11
                    | 3.50 GHz     0.3%   | 3.50 GHz     0.1%        0.2%
                    | 2.81 GHz     0.0%   | 2.81 GHz     0.0%        0.0%
                    | 2.21 GHz     2.1%   | 2.21 GHz     1.0%        1.2%
                    | Idle        97.5%   | Idle        98.8%       98.5%
 
Last edited:

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,995
Very inspiring results. Maybe you could file a recommendation to make this the default setting, if that makes sense.
 
Top