How to use AMD P-State in Linux

depends on what you want to achieve - but most options it offers are non-relevant now.

It can’t change the energy_performance_preference which is the only value that makes sense to modify now. I use a self-written systemd-service with a self-written bash script for that:

cat /etc/systemd/system/set_pstate_epp_preference.service             
[Unit]
Description=Set AMD P-State-EPP preference

[Service]
ExecStart=/usr/bin/set_balance_power.sh

[Install]
WantedBy=multi-user.target
cat /usr/bin/set_balance_power.sh                        
#!/usr/bin/env bash

sleep 5
echo balance_power > /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy2/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy3/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy4/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy5/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy6/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy7/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy8/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy9/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy10/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy11/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy12/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy13/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy14/energy_performance_preference
echo balance_power > /sys/devices/system/cpu/cpufreq/policy15/energy_performance_preference

I know that there are better ways to set those values, but I didn’t have time to write them.

that said - it does not make that much of a difference so using the default is ok, too.

1 Like

Mine shows the same as @anon49550872 balance_performance

[ricklinux@eos-plasma ~]$ cat /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference 
balance_performance

So i can just uninstall cpupower?

How are you getting it to show the cpu frequency? I set mine and cpupower service doesn’t seem to work.

I’m using cpupower to check the driver and the governor being used.
You can leave it installed and disabled just to check these values in case you need.

To check it, issue the following command: cpupower frequency-info

As you can see below, cpupower doesn’t provide the options such as, balance_power balance_performance…

$ cat /etc/default/cpupower
# Define CPUs governor
# valid governors: ondemand, performance, powersave, conservative, userspace.
#governor='ondemand'

Based on @BS686 posts, you would need to use another method to change the values, such as the script he provided.

To check the CPU frequency, I used:

watch -n1 "grep \"^[c]pu MHz\" /proc/cpuinfo"
1 Like

So i should leave this commented then because it’s now controlled by the kernel?

Edit: I get this when run.

[ricklinux@eos-plasma ~]$ cpupower frequency-info
analyzing CPU 12:
  driver: amd_pstate_epp
  CPUs which run at the same hardware frequency: 12
  CPUs which need to have their frequency coordinated by software: 12
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 550 MHz - 4.56 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 550 MHz and 4.56 GHz.
                  The governor "powersave" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.46 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: no
[ricklinux@eos-plasma ~]$ 

Does power-profiles-daemon show those options? Just being curios :cat:

powerprofilesctl list

My CPU or firmware on this laptop doesn’t support amd_pstate so I couldn’t check.

I’m not using it… I would leave it commented since governor “ondemand” is not available anymore for amd_pstate_epp, Actually, cpupower does not even show the options we are using now as available in that config file…

I suppose that cpupower.service is failing to launch because of that… You probably set a governor that amd_pstate_epp doesn’t support.

I had it set to ondemand before. But i commented it out now.

Not sure if this is what you asked

$ powerprofilesctl list
  performance:
    Driver:     amd_pstate
    Degraded:   no

* balanced:
    Driver:     amd_pstate

  power-saver:
    Driver:     amd_pstate
1 Like

Why does it show amd_pstate here when we have set?

amd_pstate_epp

hmm, did you set it in your kernel cmdline and run reinstall_kernels?

I’m on grub so i ran update grub command.

Edit: Is it supposed to be amd-pstate=active or amd_pstate=active

It should be working… At least this is all I have done here, updated my kernel cmdline, reinstalled kernels and next boot it was already set.
Are you using zen3?

amd_pstate=active

1 Like

Yes.
Since those options (balance_power balance_performance…) are not available for cpupower, I thought maybe one could switch between them using powerprofilesctl. But it doesn’t seem so … :thinking:

powerprofilesctl --help
Usage:
  powerprofilesctl COMMAND [ARGS…]

Commands:
  help       Print help
  version    Print version
  get        Print the currently active power profile
  set        Set the currently active power profile
  list       List available power profiles
  list-holds List current power profile holds
  launch     Launch a command while holding a power profile
1 Like

I didn’t even know that powerprofilectl existed… :rofl: I’ll check it… is this available in arch’s wiki?

1 Like

Mine shows this:

[ricklinux@eos-plasma ~]$ powerprofilesctl get
balanced

powerprofilectl is from power-profiles-daemon

1 Like

Yes.
Here >> https://wiki.archlinux.org/title/CPU_frequency_scaling#power-profiles-daemon

1 Like

hmm, something like TLP? Mostly for laptops?

hmm, thanks… It seems that for Gnome that option is located in the left upcorner menu.
It is set to balanced here, but if I change it to performance, nothing happens.
I suppose its main purpose is for devices that use a battery…

Edit:

Changed the option from balanced to performance in Gnome and now I can see this:

$ cat /sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference
performance

$ powerprofilesctl list
* performance:
    Driver:     amd_pstate
    Degraded:   no

  balanced:
    Driver:     amd_pstate

  power-saver:
    Driver:     amd_pstate

But according to cpupower frequency-info and watch -n1 "grep \"^[c]pu MHz\" /proc/cpuinfo" , it seems that nothing changed…

1 Like

Might be…
I need to do a bit of digging…

1 Like