Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Bug 1545308: Run packet instances with performance CPU governor
Browse files Browse the repository at this point in the history
By default, the CPU governor is set to powersave, and the cores can run
in very low frequencies. Setting to performance makes the cores run at
their maximum frequencies.
  • Loading branch information
walac committed May 31, 2019
1 parent 68339bd commit 0f3cef5
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions deploy/template/lib/systemd/set-cpufreq
@@ -0,0 +1,51 @@
#! /bin/sh
# Set the CPU Frequency Scaling governor to "ondemand"/"powersave" where available
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

read governors < $AVAILABLE
case $governors in
*performance*)
GOVERNOR="performance"
break
;;
*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

0 comments on commit 0f3cef5

Please sign in to comment.