Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update etc scripts to include governor #241

Merged
merged 2 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions etc/governor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
set -eu

usage() {
generators="$1"
# example: USAGE: ./governor.sh <performance|powersave>
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
10 changes: 9 additions & 1 deletion etc/hyperthreading.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,5 +28,5 @@ case $1 in
cores=$(printf "$cores\n$coreid")
done
;;
*) echo "USAGE: hyperthreading.sh <on|off>"
*) usage
esac
11 changes: 11 additions & 0 deletions etc/machine.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
10 changes: 9 additions & 1 deletion etc/turboboost.sh
Original file line number Diff line number Diff line change
@@ -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