Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muriloloffi/654c99c0839af0100b7fc4a1fce0c051 to your computer and use it in GitHub Desktop.
Save muriloloffi/654c99c0839af0100b7fc4a1fce0c051 to your computer and use it in GitHub Desktop.
This script changes, on Intel processors under GNU/Linux, the performance setting of a 'cpufreq' subsystem layer called 'scaling_governor'. It applies for each core of the system.
#!/bin/bash
# This script changes, on Intel processors under GNU/Linux, the performance setting of a 'cpufreq' subsystem layer called 'scaling_governor'.
# It applies to all cores of the system.
# For more details on the cpufreq subsystem, read the docs: https://docs.kernel.org/admin-guide/pm/cpufreq.html
# W.I.P: Write a script for "doas" self-configuration. The "doas" package is available in the repositories of most distros. This package is a requirement and must be already installed and configured to accept the parameters that specify the cores. Doas manual: https://man.openbsd.org/doas
numberOfSystemCores=$(($(grep -c ^processor /proc/cpuinfo)-1))
enumeratedSystemCores=$( seq 0 $numberOfSystemCores )
for i in $enumeratedSystemCores
do
pathToCpuCoreCpufreqGovernor=/sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
echo performance | doas tee $pathToCpuCoreCpufreqGovernor
done
# This piece of code is licensed under CC0 1.0. Therefore, it should be treated as public domain.
# Full license disclosure at: https://creativecommons.org/publicdomain/zero/1.0/legalcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment