aboutsummaryrefslogtreecommitdiff
path: root/etc/hyperthreading.sh
diff options
context:
space:
mode:
authorGravatar Andres Erbsen <andreser@mit.edu>2017-07-05 13:26:29 -0400
committerGravatar Andres Erbsen <andreser@mit.edu>2017-07-05 13:26:29 -0400
commit15552175f8de1f03817c66a82bc93cb4e18dc809 (patch)
treec147ac82fe42362fde024668a3ee89606cc0d57d /etc/hyperthreading.sh
parent0a0a7db3bd132eab9a36c1f8fa901dc7ea20b8e7 (diff)
etc: add scripts to control turbo boost and hyper threading
Diffstat (limited to 'etc/hyperthreading.sh')
-rwxr-xr-xetc/hyperthreading.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/etc/hyperthreading.sh b/etc/hyperthreading.sh
new file mode 100755
index 000000000..82603c5a3
--- /dev/null
+++ b/etc/hyperthreading.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+set -eu
+
+case $1 in
+ on)
+ for f in "/sys/devices/system/cpu/cpu"[0-9]*/online; do
+ echo 1 > "$f"
+ done
+ ;;
+ off)
+ cores=""
+ for cpu in "/sys/devices/system/cpu/cpu"[0-9]* ; do
+ if grep -vq '^1$' "$cpu/online" 2>/dev/null; then
+ continue
+ fi
+ coreid=$(cat "$cpu/topology/core_id")
+ if echo "$cores" | grep -- "$coreid" ; then
+ echo 0 > "$cpu/online"
+ fi
+ cores=$(printf "$cores\n$coreid")
+ done
+ ;;
+ *) echo "USAGE: hyperthreading.sh <on|off>"
+esac