9/18/2012

How to change CPU Dynamic Frequency Scaling

Using the Sys Interface

The files in /sys/devices/system/cpu/cpu0/cpufreq/ provide information and a means of controlling the frequency scaling subsystem. Seed values are given in Khz. You need to be root to access the /sys filesystem.
Your max speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq.
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
700000
Your min speed is at /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq.
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq
500000
If you are using the userspace governor, you can write to /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed to change the current speed.
# echo 700000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz : 697.252
# echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
# cat /proc/cpuinfo
cpu MHz : 976.152



Using Frequency Scaling Governors

You can get a list of available governors with (as root):
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand powersave userspace performance
Note: If the governors are compiled as modules, load them first:
# modprobe cpufreq_performance cpufreq_ondemand cpufreq_conservative cpufreq_powersave cpufreq_userspace
Now we set our governor: What is our current governor?
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
userspace
Set new governor and watch if it has changed
# echo conservative > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
conservative
Congrats! Your governor is active.
You may set the governor in your init.rc, to make it used on every boot.