[tools] Allow specifying cores for cpu.sh script.

BUG=

Review URL: https://codereview.chromium.org/1458833004

Cr-Commit-Position: refs/heads/master@{#32077}
This commit is contained in:
mlippautz 2015-11-18 02:52:55 -08:00 committed by Commit bot
parent 9b14e5bb63
commit 95ff297113

View File

@ -14,26 +14,38 @@ set_governor() {
done
}
enable_cores() {
# $1: How many cores to enable.
for (( i=1; i<=$MAXID; i++ )); do
if [ "$i" -lt "$1" ]; then
echo 1 > $CPUPATH/cpu$i/online
else
echo 0 > $CPUPATH/cpu$i/online
fi
done
}
dual_core() {
echo "Switching to dual-core mode"
for (( i=2; i<=$MAXID; i++ )); do
echo 0 > $CPUPATH/cpu$i/online
done
enable_cores 2
}
single_core() {
echo "Switching to single-core mode"
for (( i=1; i<=$MAXID; i++ )); do
echo 0 > $CPUPATH/cpu$i/online
done
enable_cores 1
}
all_cores() {
echo "Reactivating all CPU cores"
for (( i=1; i<=$MAXID; i++ )); do
echo 1 > $CPUPATH/cpu$i/online
done
enable_cores $((MAXID+1))
}
limit_cores() {
# $1: How many cores to enable.
echo "Limiting to $1 cores"
enable_cores $1
}
case "$1" in
@ -55,8 +67,15 @@ case "$1" in
allcores | all)
all_cores
;;
limit_cores)
if [ $# -ne 2 ]; then
echo "Usage $0 limit_cores <num>"
exit 1
fi
limit_cores $2
;;
*)
echo "Usage: $0 fast|slow|default|singlecore|dualcore|all"
echo "Usage: $0 fast|slow|default|singlecore|dualcore|all|limit_cores"
exit 1
;;
esac