How to use AMD P-State in Linux

Up to date guide is here

Linux 5.17 is here and just around the corner for Arch users who dont build their own Kernels and have it already. Even if you do here is the short and easy of using the new P-State Driver for AMD CPUs. Ondemand seems to deliver the best performance/power savings over schedutil with p-state at the moment.

It should be noted this is only for Zen2 and newer


  1. First check if support is already enabled with
    lscpu | grep cppc

    if you get no output then to 2

  2. Make sure CPPC is enabled in your BIOS/UEFI, some its on by default others its not.

  3. Most non-Epyc systems will need to add one or both of these to your kernel command line

    Enable shared mem mode (This is not Required for Ryzen 7000 series+ and most laptop 5000/6000 series)

    amd_pstate.shared_mem=1

    EDIT: amd-pstate=passive is now required for kernels 6.1+

    Pstate driver doesnt load automatically you can do this to load it on boot
    by creating a file

    /etc/modules-load.d/amd-pstate.conf

    in that file it should say

    # Load amd pstate at boot
    amd_pstate
    

    confirming its working you can do

    cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
    

    and it will say

    amd-pstate


and thats it, you should be using the new AMD P-State driver. Im not sure if the driver is lying to me but it reports that it allows my CPU to idle down to 550mhz. My main concern with this is just any little bit of power savings it can bring as thats its purpose. Enjoy the new driver

14 Likes

you forget a major point
activate cppc on your UEFI before !

2 Likes

Two other notes on this:

Make sure the module is enabled when building the kernel:

CONFIG_X86_AMD_PSTATE=m

And in case you run into issue and the module cannot be loaded, you can get some more detailed information when you do sudo modprobe amd_pstate dyndbg==pmf -v and then check what is logged with sudo dmesg

3 Likes

Just saw this posted and it reminded me of this thread, hopefully it helps a little bit:

3 Likes

Thank you, mine was enabled by default i didnt think about that

This isnt necessary if using Arch defconfig as that is the default for 5.17 builds. Only if youre using a custom config that disables it/ changes it would that be a worry. :+1:

1 Like

Yeah, true.

Interesting. With cpufreq I’m stuck at 1.4 GHz minimum. Unfortunately CPPC does not seem to be enabled on my laptop and there is no firmware/BIOS option to enable it hence I can’t use the new driver.

Do you see less power consumption with that in idle states?

Hard to measure exactly without hooking up to the motherboard itself. My UPS still measures around 80w system idle but its not exact and 1/2 to 2/3 of that is My Monitor+Speakers.

I’d say in a desktop system its a rather small difference at best. I’ll take even 1 watt difference, at least it lowers idle temps a couple degrees.

I decided to test but its not working for me… Not sure why, running a 5600x on a Asus motherboard.

BIOS/UEFI

image

Module/Kernel version/Kernel cmdline
# modprobe amd_pstate dyndbg==pmf -v
insmod /lib/modules/5.17.1-zen1-1-zen/kernel/drivers/cpufreq/amd_pstate.ko.zst shared_mem=1 enable=1 dyndbg==pmf

$ uname -a
Linux eos 5.17.1-zen1-1-zen #1 ZEN SMP PREEMPT Mon, 28 Mar 2022 21:56:46 +0000 x86_64 GNU/Linux

# dmesg | grep linux
[    0.000000] Linux version 5.17.1-zen1-1-zen (linux-zen@archlinux) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.38) #1 ZEN SMP PREEMPT Mon, 28 Mar 2022 21:56:46 +0000
[    0.000000] Command line: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=ba36f8b9-ac35-44c2-b5d9-0dfa868fba4a rw rootflags=subvol=@ quiet loglevel=3 nowatchdog nvme_load=YES amd_pstate.shared_mem=1 amd_pstate.enable=1
[    0.034567] Kernel command line: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen root=UUID=ba36f8b9-ac35-44c2-b5d9-0dfa868fba4a rw rootflags=subvol=@ quiet loglevel=3 nowatchdog nvme_load=YES amd_pstate.shared_mem=1 amd_pstate.enable=1
[    0.034620] Unknown kernel command line parameters "BOOT_IMAGE=/@/boot/vmlinuz-linux-zen nvme_load=YES", will be passed to user space.
[    0.560729] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    3.571384]     TERM=linux
[    3.571384]     BOOT_IMAGE=/@/boot/vmlinuz-linux-zen

$ lscpu | grep cppc
$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
acpi-cpufreq

Edit: Tried a few more things such as:
Enable that second option in BIOS (CPPC Preferred Cores)
Blacklist the module acpi_cpufreq by putting in my cmdline blacklist_module=acpi_cpufreq
Boot with both options amd_pstate.shared_mem=1 and amd_pstate.enable=1 or just the 1st one

But none of these actions worked, so I’ll give up for now…

I checked mine with and got no output. I set CPPC to enabled and also the CPPC cores to enabled. They were both set to auto?

Okay so i added the lines to the command line.

What else is there? I’m not following this.

Do you need this one?

blacklist_module=acpi_cpufreq

How do you confirm after if is working. My outputs are same as yours so far.

I tried to blacklist it as according to phoronix link, there is a possibility that acpi_cpufreq gets loaded during boot and amd-pstate doesn’t…

But whatever I do, it doesn’t work for me…
I guess that our amd_pstate module wasn’t enabled during the kernel build as mentioned by moson, not sure because I never compiled a kernel before, I’m pretty noob when it comes to it…

@ricklinux @anon49550872 The Pstate driver isnt loading automatically in this case. Ill add to the instructions but you can fix this by creating a file

/etc/modules-load.d/amd-pstate.conf

and in that file it will need to say

# Load amd pstate at boot
amd_pstate
1 Like

you shouldnt need to blacklist acpi, fixing the module loading and assuming you have the rest of the options enabled it should default to pstate with the fix from my previous post

confirming its working you can do


cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver

and it will say

amd-pstate

It worked :slight_smile: Really thanks Echoa

$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
amd-pstate
1 Like

Okay does this mean it’s working. What does this do for my Ryzen 3800X

[ricklinux@rick-ms7c37 ~]$ cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver
amd-pstate
[ricklinux@rick-ms7c37 ~]$ 
[ricklinux@rick-ms7c37 ~]$ cat /proc/cmdline                      
BOOT_IMAGE=/@/boot/vmlinuz-linux root=UUID=5763454c-2b31-4858-aeaa-b717a836c98d rw rootflags=subvol=@ blacklist_module=acpi_cpufreq amd_
pstate.enable=1 amd_pstate.shared_mem=1 loglevel=3 nowatchdog nvme_load=YES
[ricklinux@rick-ms7c37 ~]$
1 Like

lower idle speed/power and in theory the system has finer frequency control in relation to power/performance but its new and most of the work on it has been in relation to mobile/laptop use and things like the steam deck which Valve helped develop this for.

1 Like

Okay so i should take out the blacklist of cpufreq?

You shouldnt need it so you can remove the blacklist. I havent blacklisted anything in my setup

Okay i removed it. Thanks a lot. I’ll try this and see how the system works. My plasma runs so well. It instantly boots and shuts down and i have no issues.

1 Like