machine_setup/ansible/roles/cpu/files/cpu_set_perf_perc_linux_amd
Tom Alexander 9ac2605912
Also set the platform profile for AMD.
The platform profile sets power settings for the EC/system but not the CPU.
2023-12-19 08:51:25 -05:00

30 lines
1.1 KiB
Bash

#!/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" -gt 80 ]; then
echo performance | tee /sys/firmware/acpi/platform_profile
elif [ "$perc" -ge 20 ]; then
echo balanced | tee /sys/firmware/acpi/platform_profile
else
echo low-power | tee /sys/firmware/acpi/platform_profile
fi
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