Set the energy performance preference for AMD.

This commit is contained in:
Tom Alexander 2023-12-18 20:08:06 -05:00
parent 94b379c717
commit c87ac216a9
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
5 changed files with 47 additions and 2 deletions

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# Tell hardware p-states whether to maximize CPU performance (100) or
# energy efficiency (0).
set -euo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
perc=$1
if [ "$perc" -ge 80 ]; then
echo "performance" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
elif [ "$perc" -ge 60 ]; then
echo "balance_performance" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
elif [ "$perc" -ge 40 ]; then
echo "default" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
elif [ "$perc" -ge 20 ]; then
echo "balance_power" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
else
echo "power" | tee /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference
fi

View File

@ -3,3 +3,27 @@
name:
- powertop
state: present
- name: Favor energy efficiency for Speed Shift
when: hwpstate is defined and hwpstate and cores is defined
template:
src: "templates/{{ item.src }}.j2"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: energy_performance_preference.conf
dest: /etc/tmpfiles.d/energy_performance_preference.conf
- name: Install scripts
when: hwpstate is defined and hwpstate
copy:
src: "files/{{ item.src }}"
dest: "{{ item.dest }}"
mode: 0755
owner: root
group: wheel
loop:
- src: cpu_set_perf_perc_linux_amd
dest: /usr/local/bin/cpu_set_perf_perc

View File

@ -35,5 +35,5 @@
owner: root
group: wheel
loop:
- src: cpu_set_perf_perc_linux
- src: cpu_set_perf_perc_linux_intel
dest: /usr/local/bin/cpu_set_perf_perc

View File

@ -1,4 +1,4 @@
# Favor energy efficiency for Speed Shift
# Favor energy efficiency for hardware p-states
{% for core in range(0, cores, 1) %}
w- /sys/devices/system/cpu/cpufreq/policy{{core}}/energy_performance_preference - - - - power
{% endfor %}