aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-09-15 16:27:58 -0400
committerGravatar Jason Gross <jasongross9@gmail.com>2017-09-27 09:06:50 -0400
commit3eb500b11a3faf768cf96fd6034141eff6ffa83c (patch)
treed3438d79e0e35a4b39a7829f8adcaf3514775e82 /etc
parentd9cdac885b57f168581c4cbb566aadb45eda7d34 (diff)
Update etc scripts to include governor
It needs to be in performance, not powersave, to work well on my machine. While we're at it, also have the scripts print usage if you pass no arguments, rather than giving an error message about $1 being unset.
Diffstat (limited to 'etc')
-rwxr-xr-xetc/governor.sh25
-rwxr-xr-xetc/hyperthreading.sh10
-rwxr-xr-xetc/machine.sh11
-rwxr-xr-xetc/turboboost.sh10
4 files changed, 54 insertions, 2 deletions
diff --git a/etc/governor.sh b/etc/governor.sh
new file mode 100755
index 000000000..caabb9da8
--- /dev/null
+++ b/etc/governor.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ generators="$1"
+ echo "USAGE: $0 <$(echo "$generators" | tr ' ' '|')>"
+ exit 111
+}
+
+
+for cpu in "/sys/devices/system/cpu/cpu"[0-9]* ; do
+ if grep -vq '^1$' "$cpu/online" 2>/dev/null; then
+ continue
+ fi
+ generators="$(cat "$cpu/cpufreq/scaling_available_governors")"
+ if [ "$#" -eq 0 ] || [ -z "$1" ]; then
+ usage "$generators"
+ elif (echo -n "$generators" | tr ' ' '\n' | grep -q "^$1\$" 2>/dev/null); then
+ if grep -vq "^$1\$" "$cpu/cpufreq/scaling_governor" 2>/dev/null; then
+ echo "$1" > "$cpu/cpufreq/scaling_governor"
+ fi
+ else
+ usage "$generators"
+ fi
+done
diff --git a/etc/hyperthreading.sh b/etc/hyperthreading.sh
index 977942965..e003d8fb5 100755
--- a/etc/hyperthreading.sh
+++ b/etc/hyperthreading.sh
@@ -1,6 +1,14 @@
#!/bin/sh
set -eu
+usage() {
+ echo "USAGE: $0 <on|off>" ; exit 111
+}
+
+if [ "$#" -eq 0 ]; then
+ usage
+fi
+
case $1 in
on)
for f in "/sys/devices/system/cpu/cpu"[0-9]*/online; do
@@ -20,5 +28,5 @@ case $1 in
cores=$(printf "$cores\n$coreid")
done
;;
- *) echo "USAGE: hyperthreading.sh <on|off>"
+ *) usage
esac
diff --git a/etc/machine.sh b/etc/machine.sh
index 5fcb7289a..69edb149a 100755
--- a/etc/machine.sh
+++ b/etc/machine.sh
@@ -1,6 +1,15 @@
#!/bin/sh
set -eu
+online_governors() {
+ for cpu in "/sys/devices/system/cpu/cpu"[0-9]* ; do
+ if grep -vq '^1$' "$cpu/online" 2>/dev/null; then
+ continue
+ fi
+ cat "$cpu/cpufreq/scaling_governor"
+ done
+}
+
printf "$(hostname)"
printf -
grep -q '[^0-9]' /sys/devices/system/cpu/cpu[0-9]*/topology/thread_siblings_list && printf ht || printf noht
@@ -17,5 +26,7 @@ else
printf nops
fi
printf -
+printf "$(echo -n "$(online_governors | uniq)" | tr '\n' '_')"
+printf -
printf "$(gcc -march=native -Q --help=target|grep march | cut -d= -f2 | grep -ow '\S*')"
printf '\n'
diff --git a/etc/turboboost.sh b/etc/turboboost.sh
index f336660ec..69c5ba054 100755
--- a/etc/turboboost.sh
+++ b/etc/turboboost.sh
@@ -1,8 +1,16 @@
#!/bin/sh
set -eu
+usage() {
+ echo "USAGE: $0 <on|off>" ; exit 111
+}
+
+if [ "$#" -eq 0 ]; then
+ usage
+fi
+
case $1 in
on) echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo ;;
off) echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo ;;
- *) echo "USAGE: $0 <on|off>" ; exit 111
+ *) usage
esac