This repository has been archived by the owner on May 9, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1545308: Run packet instances with performance CPU governor
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
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|