From 335d34921f1713d62d08d2d9244601d1553acd7c Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Fri, 29 Sep 2023 21:18:28 -0400 Subject: [PATCH] ADD set_hwp --- dot_bin/executable_set_hwp | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dot_bin/executable_set_hwp diff --git a/dot_bin/executable_set_hwp b/dot_bin/executable_set_hwp new file mode 100644 index 0000000..b276709 --- /dev/null +++ b/dot_bin/executable_set_hwp @@ -0,0 +1,50 @@ +#!/bin/sh + +# set the HWP preference for all cpus in sysfs + +cpus="/sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference" + +usage() { + script=${0##*/} + echo + echo "Invalid usage of ${script}!" + echo + echo "The following options are allowed" + echo + echo "-----------" + echo "$script -1 : default" + echo "$script 0 : power" + echo "$script 1 : balance_power" + echo "$script 2 : balance_performance" + echo "$script 3 : performance" + echo "-----------" + echo + + exit 1 +} + +set_pref() { + for cpu in $cpus; do + echo "$1" > "$cpu" + done +} + +case "$1" in + -1) + set_pref "default" + ;; + 0) + set_pref "power" + ;; + 1) + set_pref "balance_power" + ;; + 2) + set_pref "balance_performance" + ;; + 3) + set_pref "performance" + ;; + *) + usage "invalid argument" +esac