diff --git a/.etckeeper b/.etckeeper index 655f6d0b..f538eb28 100755 --- a/.etckeeper +++ b/.etckeeper @@ -215,6 +215,7 @@ maybe chmod 0755 'default' maybe chmod 0644 'default/avahi-daemon' maybe chmod 0644 'default/bluetooth' maybe chmod 0644 'default/console-setup' +maybe chmod 0644 'default/cpu_governor' maybe chmod 0644 'default/crda' maybe chmod 0644 'default/cron' maybe chmod 0644 'default/dbus' diff --git a/default/cpu_governor b/default/cpu_governor new file mode 100644 index 00000000..e66974af --- /dev/null +++ b/default/cpu_governor @@ -0,0 +1,35 @@ +# +# Set default governor on all CPU cores. +# More info https://www.kernel.org/doc/Documentation/cpu-freq/governors.txt +# +# CPU_DEFAULT_GOVERNOR="ondemand" +# + +# +# ondemand governor: This defines what the average CPU usage between the +# samplings of 'sampling_rate' needs to be for the kernel to make a decision +# on whether it should increase the frequency. +# +# CPU_ONDEMAND_UP_THRESHOLD=50 +# + +# +# ondemand governor: How often you want the kernel to look at the CPU usage +# and to make decisions on what to do about the frequency. +# +# CPU_ONDEMAND_SAMPLING_RATE=100000 +# + +# +# ondemand governor: The rate at which the kernel makes a decision on when to +# decrease the frequency while running at top speed +# +# CPU_ONDEMAND_DOWN_SAMPLING_FACTOR=50 +# + +# +# ondemand governor: Include Input/Output (I/O) activity into CPU activity +# calculations when using ondemand CPU governor +# +# CPU_ONDEMAND_INCLUDE_IO_CALC=0 +# diff --git a/init.d/raspi-config b/init.d/raspi-config index 886273b1..deebb18b 100755 --- a/init.d/raspi-config +++ b/init.d/raspi-config @@ -11,20 +11,35 @@ . /lib/lsb/init-functions +if [ -f /etc/default/cpu_governor ]; then + . /etc/default/cpu_governor +fi + +CPU_DEFAULT_GOVERNOR="${CPU_DEFAULT_GOVERNOR:-ondemand}" +CPU_ONDEMAND_UP_THRESHOLD="${CPU_ONDEMAND_UP_THRESHOLD:-50}" +CPU_ONDEMAND_SAMPLING_RATE="${CPU_ONDEMAND_SAMPLING_RATE:-100000}" +CPU_ONDEMAND_DOWN_SAMPLING_FACTOR="${CPU_ONDEMAND_DOWN_SAMPLING_FACTOR:-50}" +CPU_ONDEMAND_INCLUDE_IO_CALC="${CPU_ONDEMAND_INCLUDE_IO_CALC:-0}" + case "$1" in start) log_daemon_msg "Checking if shift key is held down" if [ -x /usr/sbin/thd ] && timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT"; then - printf " Yes. Not enabling ondemand scaling governor" + printf " Yes. Not enabling $CPU_DEFAULT_GOVERNOR scaling governor" log_end_msg 0 else - printf " No. Switching to ondemand scaling governor" + printf " No. Switching to $CPU_DEFAULT_GOVERNOR scaling governor" SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor if [ -e $SYS_CPUFREQ_GOVERNOR ]; then - echo "ondemand" > $SYS_CPUFREQ_GOVERNOR - echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold - echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate - echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + for cpu_core in /sys/devices/system/cpu/cpu?/cpufreq/scaling_governor ; do + echo "$CPU_DEFAULT_GOVERNOR" > $cpu_core + done + if [ "$CPU_DEFAULT_GOVERNOR" = "ondemand" ]; then + echo "$CPU_ONDEMAND_UP_THRESHOLD" > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold + echo "$CPU_ONDEMAND_SAMPLING_RATE" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate + echo "$CPU_ONDEMAND_DOWN_SAMPLING_FACTOR" > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor + echo "$CPU_ONDEMAND_INCLUDE_IO_CALC" > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy + fi fi log_end_msg 0 fi