I’m using an AMD EPYC 7402P on a ASRock ROMED8-2T so I will talk about that. Intel_PSTATE is probably similar.
ACPI only allows my CPU to downlock to 1.5Ghz. AMD_PSTATE allows it to downclock to 400Mhz.
What is acpi cpufreq?
acpi cpufreq is a general driver that uses the Advanced Configuration and Power Interface (ACPI) to manage CPU performance states (P-states). It works with discrete P-states, making it compatible with both Intel and AMD processors. It’s often the default choice for systems without specialized drivers, providing basic frequency scaling for power management.
What is amd pstate?
amd pstate, on the other hand, is designed specifically for AMD processors, particularly those supporting the Collaborative Processor Performance Control (CPPC) interface. This driver allows for more dynamic and fine-grained control over CPU performance, potentially leading to improved energy efficiency and performance on supported hardware.
Key Differences
- Specificity: acpi cpufreq is a general-purpose driver, while amd pstate is optimized for AMD’s architecture.
- Performance Control: amd pstate uses CPPC for advanced management, whereas acpi cpufreq relies on standard ACPI P-state interfaces.
- Hardware Requirements: amd pstate requires CPPC support, which may need specific BIOS settings, while acpi cpufreq is more universally compatible.
Here is a one liner to monitor CPU clock per core and list max freqency observed ever 1 seconds.
bash -c 'while true; do freqs=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq); max=0; for f in $freqs; do [ $f -gt $max ] && max=$f; done; echo "Current (GHz): $(echo $freqs | tr " " "\n" | awk "{printf \"%.2f \", \$1/1000000}") | Max: $(echo $((max/1000)) | awk "{printf \"%.2f\", \$1/1000}") GHz"; sleep 1; done'
Looks like this…
Current (GHz): 0.40 3.00 2.31 2.29 3.01 2.24 3.09 3.22 2.38 0.40 0.40 0.40 2.31 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 2.26 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 2.30 0.40 0.40 0.40 0.40 2.46 0.40 0.40 1.77 3.20 3.35 2.30 2.28 3.35 | Max: 3.35 GHz
Current (GHz): 0.40 2.32 3.23 1.80 3.21 2.10 2.30 3.02 3.00 0.40 0.40 0.40 1.67 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 2.98 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 0.40 3.01 0.40 0.40 0.40 0.40 0.40 0.40 3.12 1.74 1.67 3.30 2.97 3.14 3.00 | Max: 3.30 GHz
You first need to make sure CPPC and EPP are enabled in the BIOS. Should be enabled by default but you never know.
In order to enable amd_pstate you need to run the following command
midclt call system.advanced.update '{ "kernel_extra_options": "amd_pstate=active" }'
If your CPU does not support EPP you will need to use guided instead. Guided does not have as granular control as I describe below.
midclt call system.advanced.update '{ "kernel_extra_options": "amd_pstate=guided" }'
What this does is call the function in the TrueNAS API that use to exsist under Advanced Settings > Kernel that no longer exsists for some reason.
You can confirm it is enabled by running…
cpupower frequency-info
Looks like this.
analyzing CPU 0:
driver: amd-pstate-epp
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: Cannot determine or is not supported.
hardware limits: 400 MHz - 3.35 GHz
available cpufreq governors: performance powersave
current policy: frequency should be within 400 MHz and 3.35 GHz.
The governor "performance" may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 400 MHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes
Boost States: 0
Total States: 3
Pstate-P0: 2800MHz
Pstate-P1: 2400MHz
Pstate-P2: 1500MHz
Then you can set the govenor between in this example ‘performance’ or ‘powersave’. ‘powersave’ allows you to set the energy_performance_preference
echo "powersave" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
energy_performance_preference allows the following options. In my testing all of these options allow for 400Mhz - 3.35 Ghz it just requires more or less cpu usage to get it to clock up to 3.35 Ghz.
- performance: Max frequency, less power saving.
- balance_performance: Slightly favors performance.
- balance_power: Balanced (default in many cases).
- power: Prioritizes power savings, lower frequencies.
Enable it by running…
echo "balance_power" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference
However setting the governor and EPP is not persistent with reboot. It will default to performance governor. However with my testing I don’t see a meaningful power consumtion reduction between ‘performance’ and ‘power’ (the most aggressive setting). So I didn’t test how to make it persistant through reboot.
I’m tired and need to sleep so hopefully this was coherent.