mirror of
https://git.proxmox.com/git/systemd
synced 2026-02-04 19:45:13 +00:00
The latter does not exist any more when "initscripts" falls out of the default installation. This now does not do a fixed one-minute wait but uses "Type=idle" instead. This also becomes a no-op when the CPU supports "intel_pstate" (≤ 5 years old), as on these the ondemand/powersave schedulers are actually detrimental. LP: #1584124 LP: #1579278
55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 KiB
Bash
Executable File
#! /bin/sh
|
|
# Set the CPU Frequency Scaling governor to "ondemand"/"powersave" on old
|
|
# machines which don't support intel_pstate yet.
|
|
set -eu
|
|
|
|
FIRSTCPU=`cut -f1 -d- /sys/devices/system/cpu/online`
|
|
AVAILABLE="/sys/devices/system/cpu/cpu$FIRSTCPU/cpufreq/scaling_available_governors"
|
|
DOWN_FACTOR="/sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor"
|
|
|
|
[ -f $AVAILABLE ] || exit 0
|
|
|
|
# more modern processors that support intel_pstate behave worse with
|
|
# ondemand/powersave and should use performance
|
|
if [ `cat /sys/devices/system/cpu/cpu$FIRSTCPU/cpufreq/scaling_driver` = intel_pstate ]; then
|
|
echo 'CPU supports intel_pstate, keeping "performance"'
|
|
exit 0
|
|
fi
|
|
|
|
read governors < $AVAILABLE
|
|
case $governors in
|
|
*interactive*)
|
|
GOVERNOR="interactive"
|
|
break
|
|
;;
|
|
*ondemand*)
|
|
GOVERNOR="ondemand"
|
|
case $(uname -m) in
|
|
ppc64*)
|
|
SAMPLING=100
|
|
;;
|
|
esac
|
|
break
|
|
;;
|
|
*powersave*)
|
|
GOVERNOR="powersave"
|
|
break
|
|
;;
|
|
*)
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
[ -n "${GOVERNOR:-}" ] || exit 0
|
|
|
|
echo "Setting $GOVERNOR scheduler for all CPUs"
|
|
|
|
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
|
|
do
|
|
[ -f $CPUFREQ ] || continue
|
|
echo -n $GOVERNOR > $CPUFREQ
|
|
done
|
|
if [ -n "${SAMPLING:-}" ] && [ -f $DOWN_FACTOR ]; then
|
|
echo -n $SAMPLING > $DOWN_FACTOR
|
|
fi
|