#!/bin/ash # # Script to set the CPU governor to ondemand on all cores # # source global config . /opt/openslx/config || \ { echo "ERROR: Could not source /opt/openslx/config."; exit 1; } # if scaling_driver is acpi-cpufreq: # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors # conservative ondemand userspace powersave performance schedutil # -> use ondemand and performance # if scaling_driver is intel_cpufreq: # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors # conservative ondemand userspace powersave performance schedutil # -> same as acpi # if scaling_driver is intel_pstate: # cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors # performance powersave # -> we only got two choices anyways :) # if scaling_driver is amd_pstate: # haven't seen this yet, relatively new as of 2024, but it should work # almost the same as intel_pstate, i.e. only performance and powersave # set the governor. Prioritize command-line argument, then SLX_GOVERNOR, # fall back to powersave. if [ -n "$1" ]; then wanted_gov="$1" elif [ -n "$SLX_GOVERNOR" ]; then wanted_gov="$SLX_GOVERNOR" else wanted_gov="powersave" fi echo "Trying to set CPU governor to $wanted_gov" for dir in /sys/devices/system/cpu/cpu*/cpufreq; do driver=$( cat "$dir/scaling_driver" ) newgov="$wanted_gov" if [ "$driver" != "intel_pstate" ] && [ "$driver" != "amd_pstate" ]; then [ "$newgov" = "powersave" ] && newgov="ondemand" fi echo "$newgov" > "$dir/scaling_governor" done exit 0