I want to change the default governor on my pi from ondemand to performance. Is there a way of doing this?
I don't think you can change the default without recompiling the kernel. By that I mean, the one the kernel chooses when booted up.
However, you can tell it to use a different governor while running, so if you want to effectively set the default without recompiling, you can add something to
/etc/rc.local or some other start-up script.
/sys directory is not on disk; it's an in RAM fake filesystem that is actually an interface for getting information from and sending commands to the kernel. This is all relative to
> cd /sys/devices/system/cpu
You also need to be root to do the writes (
echo blahblah >). Anyway, relative to the above directory, to see the available governors:
> cat cpu0/cpufreq/scaling_available_governors conservative ondemand userspace powersave performance
Apparently yours is
ondemand (but read "Gotcha" below about this); to check:
> cat cpu0/cpufreq/scaling_governor ondemand
To change it:
echo performance > cpu0/cpufreq/scaling_governor
Note this either has to be done root, or like this
sudo sh -c "echo performance > cpu0/cpufreq/scaling_governor"
sudo will not work because there is a redirect,
You'll now notice the
/sys/devices/system/cpu/cpufreq directory, (NOT the same as
/sys/devices/system/cpu/cpu0/cpufreq!), which formerly contained filehandles for configuring the ondemand governor, is empty.
On Raspbian there is an init script, the confusingly named
raspi-config (no, it has nothing to do with the other one, which is run on first boot by the also confusingly named
apply_noobs_os_config.sh), which uses this technique to set the governor to
ondemand unless the shift key is held down (the stock Raspbian kernel has
powersave compiled in). It doesn't do anything else, so it is safe to disable this (
systemctl disable raspi-config), or you could edit it as per Gorkamorka's answer, but then you run the risk of having it un-edited by a system update, etc. -- who knows what anyone plans to do with that.
You could try adding the non-sudo version above to
/etc/rc.local. This may happen after the
raspi-config script has exited.
I made a small programm to change it and let it be changed every boot by automatically creating an init.d script.
similar question on RPi stack exchange here.
to paraphrase it, the on demand speed bumps up to max when cpu is at 95% busy. You can lower the amount of busy time to a lower percentage (meaning it'll be clocked higher when not as busy) by:
"writing an integer value to a file (you can put the following for example in the /etc/rc.local startup file): echo 60 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold"
so, theoretically...you could put this percentage at something incredibly low like 10 or 5, which would mean it would always be running at max.
Hope this helps. Be sure to up score the person who posted this in the linked article!
An alternative solution (if you are running Raspbian) could be to modify the init.d script in /etc/init.d/raspi-config to always disable the scaling governor. It's default behavior is to only enable it at startup if one of the shift-keys is being pressed down:
#!/bin/sh ### BEGIN INIT INFO # Provides: raspi-config # Required-Start: udev mountkernfs $remote_fs # Required-Stop: # Default-Start: S # Default-Stop: # Short-Description: Switch to ondemand cpu governor (unless shift key is pressed) # Description: ### END INIT INFO . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Checking if shift key is held down" timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT" if [ $? -eq 0 ]; then printf " Yes. Not enabling ondemand scaling governor" log_end_msg 0 else printf " No. Switching to ondemand scaling governor" SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor if [ -e $SYS_CPUFREQ_GOVERNOR ]; t hen 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 echo 1 | sudo tee /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy fi log_end_msg 0 fi ;; *) echo "Usage: $0 start" >&2 exit 3 ;; esac