Skip to content

Instantly share code, notes, and snippets.

@amontalenti
Last active November 28, 2021 06:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amontalenti/f7fcac34b6af31ebf5ab to your computer and use it in GitHub Desktop.
Save amontalenti/f7fcac34b6af31ebf5ab to your computer and use it in GitHub Desktop.
#!/bin/sh
# on Ubuntu 14.04, set a pm-hibernate resume hook
# which is placed in /etc/pm/sleep.d/00_intel_pstate
# it sets up CPU intel pstate appropriately, which by default
# gets ruined by being scaled down to 50% of max CPU without the
# easy ability to change it back; also sets governor to performance
# for good measure, since apparently default is "powersave"
# I also recommend you do `sudo touch /etc/pm/sleep.d/94cpufreq` in order
# to disable the resume hook for cpu frequency scaling if you are using
# this Intel driver, as is now recommended
case "${1}" in
resume|thaw)
# sleep is necessary because Linux stinks
sleep 10
# set turbo mode and 100% of CPU scaling capability
echo 0 >/sys/devices/system/cpu/intel_pstate/no_turbo
echo 100 >/sys/devices/system/cpu/intel_pstate/max_perf_pct
# switch to "performance" governor
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
[ -f $CPUFREQ ] || continue
echo -n "performance" >$CPUFREQ
done
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment