From 3eb500b11a3faf768cf96fd6034141eff6ffa83c Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 15 Sep 2017 16:27:58 -0400 Subject: 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. --- etc/governor.sh | 25 +++++++++++++++++++++++++ etc/hyperthreading.sh | 10 +++++++++- etc/machine.sh | 11 +++++++++++ etc/turboboost.sh | 10 +++++++++- 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100755 etc/governor.sh (limited to 'etc') 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 " ; 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 " + *) 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 " ; 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 " ; exit 111 + *) usage esac -- cgit v1.2.3