Tag Archives: CPUFREQ

How to utilize better processor work on Linux server by disable CPU scaling – Make Linux server CPU work on full speed

how-to-utilize-better-linux-cpu-by-disabling-cpu-scaling-make-linux-server-cpu-work-on-full-speed
I’ve learned a very useful system administration tip on how to utilize processor work on a Linux server. By default in newer Linux kernel releases, there is ondemand CPU function enabled that makes use of multi-CPU processors only in case if the CPU is needed. On busy servers this on-demand practice is very bad practice, because often when ondemand is enabled CPU is working on a lower CPU rate than maximum (to save power) and used only when necessery and this is time consuming and affects performance.
To check whether ondemand “kernel feature” is making your CPU work by default on its maximum capacity:

uname -a;
Linux pcfreak 2.6.32-5-amd64 #1 SMP Sun Sep 23 11:00:33 UTC 2012 x86_64 GNU/Linux

ps ax| grep kondemand
182 ? S 0:00 [kondemand/0]
183 ? S 0:00 [kondemand/1]
184 ? S 0:00 [kondemand/2]
185 ? S 0:00 [kondemand/3]
186 ? S 0:00 [kondemand/4]

This processes are controlled by kernel and control ondemand for each server CPU.

grep -E ‘^model name|^cpu MHz’ /proc/cpuinfo
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
cpu MHz : 1596.000
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
cpu MHz : 1596.000

As you can see even though the CPU has capacity to run 2.40Ghz only 1.6Ghz are used meaning you’re wasing computing speed and even if used it is slower (not to mention that for dedicated servers saving power is not a priority of the sysadmin).

If ondemand is enabled for CPUs usually this
To disable CPU ondemand function use following one liner:

for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n performance > $CPUFREQ; done

To make the ondemand disabled permanent, quickest way is to add it to /etc/rc.local right before the exit 0

On CentOS Linux to stop ondemand support:

service cpuspeed stop

On RHEL and Oracle Unbreakable Linux:

lsmod | grep ondemand
cpufreq_ondemand 8764 0
freq_table 3751 2 cpufreq_ondemand,acpi_cpufreq
rmmod cpufreq_ondemand acpi_cpufreq freq_table

Any other services that control CPU stepping like ‘cpuspeed’, ‘cpufreqd’, ‘powerd’ should be disabled.