volatile write

Setting the CPU governor via commandline

To set the CPU governor to ondemand, use the following:

echo "ondemand" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor


the governors available on most systems are : (check cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors)

ondemand
the CPU is running at the lowest possible frequency and only scales up as needed
consercative
like ondemand, but the scaling happens slowly, one step a time
performance
the CPU is running at the highest possible frequency
powersave
the CPU is running at the lowest possible frequency
userspace
the frequency can be set by the user, as long as the CPU supports the desired frequency (that is, you cannot overclock using the userspace governor)


As a important note, especially for laptop users: The governor with the least power consumption is almost every time the ondemand governor and not the powersave governor. Unlike powersave, ondemand allows the CPU to fall back to idle which consumes far less power than a CPU running at the slowest speed.

To scale the CPU in userspace mode, you can write the CPU frequency in specific files.

To get the possible frequencies, call

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies

To get the current setting, use

cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq

and to set the frequency, use a command similar to the opening one:

echo "1000000" | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed
Thoughts? Leave a comment