Blog

Posted 2011/05/07

Non-root changing cpufreq in Linux

We let collaborators onto our test cluster to do some power aware research. One thing they always want to do is change the CPU frequency. Rather than give everyone sudo we let any user on the machine change the frequency. This is done with a little bit of chmod magic:

Edit /etc/rc.local append:

echo userspace > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo userspace > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
echo 1800000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
echo 1800000 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_setspeed
chmod 666 /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
chmod 666 /sys/devices/system/cpu/cpu2/cpufreq/scaling_setspeed