Commit 95ff2971 authored by mlippautz's avatar mlippautz Committed by Commit bot

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

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32077}
parent 9b14e5bb
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment