How to use AMD P-State in Linux

i will add this complent with amd pstate

better to use mwait , not HALT for Ryzen Cpu

lscpu | grep cppc gives me this:

[yuanhao@yh-G14-GA402RK ~]$ lscpu | grep cppc
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca fsrm

is this ok?

It shows you have CPPC support, so I guess so? Depends what you mean by OK?

1 Like

That command doesn’t work for me. I just use lscpu and it gives me all the info.

1 Like

As long as you have a Ryzen 5000 or higher CPU on laptops you have CPPC support (its required for those systems afaik)

Ryzen 4000 on laptops is a hit or miss (depends on the BIOS) and 3000/5000 on desktop should work ok. I believe both will need amd_pstate.shared_mem=1 on the kernel cmdline to work with Pstate.

I am using 6000 series, and it works no problem without amd_pstate.shared_mem=1

you are also using a laptop which will work OOTB like i said lol :stuck_out_tongue: just gotta load pstate for those when ryzen 5000 or higher

1 Like

hmmm, more optimizations, up to 14% :slight_smile:

1 Like

The most interesting part here is the existing and new Pstate seem to give the best performance and power saving with ondemand governor

It may be wise for Pstate users to not use schedutil. Schedutil in some situation may be slightly better but with worse performance.

1 Like

I am using an Ryzen 6900HS in my lenovo laptop.

After booting I default to (cpupower frequency-info):

  driver: acpi-cpufreq

The minimum frequency is 1.6GHz and the maximum frequency is 3.3GHz. It says there are no boost PStates available, but turbostat shows it boosts correctly when stressing 1 or all cores, while cpupower doesn’t show the real frequency and displays the base clock 3.3GHz. I never get lower frequencies than 1.6GHz.

My system is using the linux-mainline kernel from chaotic-aur (6.0.0-rc4-1-mainline):

$ zless /proc/config.gz | grep AMD_PSTATE
CONFIG_X86_AMD_PSTATE=m

I have no kernel parameters set at all. Simply loading the module does nothing, my pstate driver does not change:

$ modprobe amd_pstate

But I made it work by removing the acpi-cpufreq module before I load the other one:

$ rmmod acpi-cpufreq
$ modprobe amd_pstate

Now I get this output of “cpupower frequency-info”:

CPU 0 wird analysiert:
  driver: amd-pstate
  CPUs, die mit der gleichen Hardwarefrequenz laufen: 0
  CPUs, die ihre Frequenz mit Software koordinieren mĂźssen: 0
  Maximale Dauer eines Taktfrequenzwechsels: 131 us
  Hardwarebegrenzungen: 400 MHz - 4.94 GHz
  verfĂźgbare cpufreq-Regler: conservative ondemand userspace powersave performance schedutil
  momentane Richtlinie: Frequenz sollte innerhalb 400 MHz und 4.94 GHz.
                    sein. Der Regler "schedutil" kann frei entscheiden,
                    welche Geschwindigkeit er in diesem Bereich verwendet.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 1.60 GHz (asserted by call to kernel)
  boost state support:
    UnterstĂźtzt: ja
    Aktiv: ja
    AMD PSTATE Highest Performance: 166. Maximum Frequency: 4.94 GHz.
    AMD PSTATE Nominal Performance: 111. Nominal Frequency: 3.30 GHz.
    AMD PSTATE Lowest Non-linear Performance: 37. Lowest Non-linear Frequency: 1.10 GHz.
    AMD PSTATE Lowest Performance: 14. Lowest Frequency: 400 MHz.

I have lower minimum frequencies available!


To keep the changes on reboot I did:

cat > /etc/modules-load.d/amd_pstate.conf
amd_pstate
Ctrl+D

I did not need to blacklist acpi-cpufreq, but I did it afterwards to be secure from randomness during boot:

cat > /etc/modprobe.d/blacklist.conf
blacklist acpi-cpufreq
Ctrl+D

“cpupower frequency-info” does now report current frequencies correctly.

I do not think that amd_pstate reduces power consumption for Desktop PC.

I’ve tested the PC power consumption with my electricity meter, but the result: amd_pstate and acpi-cpufreq actually consumed a similar amount of power in watt. But only the difference is CPU frequency. Maybe temperature is better than before.

I’ll wait and see if “P-state EPP” improves or not.

Peak shouldn’t really change, it seems to be geared towards idle and light workloads

I.e more common laptop workloads

new version of eep coming

@anon49550872 already posted that but appreciate it

Looking at the info I would suggest people use ondemand vs schedutil with even the current p-state

edit: I updated the OP to reflect that people should probably use p-state+ondemand vs schedutil

1 Like

Also using ondemand with p-state now

Ok, ondemand with p-state, I understand it.
But, how Gnome power settings works along with it?

According to Arch’s wiki, power-profiles-daemon is launched by gnome-shell, just checked and indeed the service is running.

So, I have a Scaling driver (amd_pstate), a governor (ondemand), and a power-profile-daemon that is tweaking the governor running with amd_pstate scaling driver?

Honestly not sure, it hasn’t touched the Governor on my system but I leave it default. I don’t know much about GNOMEs power settings beyond setting my system to suspend/sleep. AFAIK on desktops it really doesn’t do much.

1 Like

power-profile-daemon → https://gitlab.freedesktop.org/hadess/power-profiles-daemon
This is mainly designed to work with intel CPUs and if you do not want to use you can disable/mask it:
sudo systemctl mask power-profiles-daemon.service

I would use something like TLP instead on AMD CPU

1 Like
1 Like

Looks like he skipped testing Pstate+ondemand unfortunately. Would like to see some more performance #s from that front

1 Like