grep -E '^model name|^cpu MHz' /proc/cpuinfo
model name : Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz
cpu MHz : 1600.000
...
or
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
cpu MHz : 1596.000
...
or even
model name : Intel(R) Core(TM)2 CPU 4400 @ 2.00GHz
cpu MHz : 1000.000
model name : Intel(R) Core(TM)2 CPU 4400 @ 2.00GHz
cpu MHz : 600.000
[root@boston07 ~]# uname -a
Linux boston07 2.6.18-164.6.1.el5 #1 SMP Tue Nov 3 16:18:27 EST 2009 i686 i686 i386 GNU/Linux
[root@boston07 ~]# pgrep -lf ondemand
1444 kondemand/0
1445 kondemand/1
[root@boston07 ~]# 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
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n performance > $CPUFREQ; done
[root@boston07 ~]# grep -E '^model name|^cpu MHz' /proc/cpuinfo
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
cpu MHz : 2394.000
model name : Intel(R) Core(TM)2 CPU 6600 @ 2.40GHz
cpu MHz : 2394.000
# service cpuspeed stop
# lsmod | grep ondemand
cpufreq_ondemand 8764 0
freq_table 3751 2 cpufreq_ondemand,acpi_cpufreq
# rmmod cpufreq_ondemand acpi_cpufreq freq_table
# pgrep -lf kondemand
#
echo -n ondemand > $CPUFREQ
to this:
echo -n performance > $CPUFREQ
rm -f /etc/rc?.d/S99ondemand
- On CentOS, just create a new script /etc/init.d/ondemand:
#! /bin/bash
#
# ondemand sets cpu govermor
#
# chkconfig: 2345 10 90
#
# description: Set the CPU Frequency Scaling governor to "performance"
#
### BEGIN INIT INFO
# Provides: $ondemand
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
case "$1" in
start)
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
[ -f $CPUFREQ ] || continue
echo -n performance > $CPUFREQ
done
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
then enable it:
chmod +x /etc/init.d/ondemand
chkconfig --add ondemand
service ondemand restart
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (3)
Commented:
With Ondemand, the CPU runs faster when it needs to, slower when it doesn't need to. This results in lower electrical use and temperatures, hence longer CPU life and lower electric and cooling bills.
If you do the "grep ... cpuinfo" enough times you will see several different results (presuming that your system actually has some sort of load). Better yet, add the cpu speed monitor to the panel so you can see it change as you do stuff. Of course, if your system isn't doing anything then usually it will show the lowest speed, while if it is fully loaded, it will almost always show the maximum speed. Your "grep ... cpuinfo" simply takes a snapshot, which may or may not be representative ... it's simply a roll of the dice.
For most workloads, Ondemand represents a nice balance between performance and energy use.. Performance supposedly leans towards performance a little more, but I have never been able to see a meaningful difference.
Simply locking the CPU speed at the max only means that you run the idle loop as fast as possible, while increasing CPU power consumption, CPU temperature and fan speed, while reducing the life of your CPU.
Personally, I've never been that concerned about seeing the idle loop run as fast as possible.
Author
Commented:Sometimes this matters how FAST your EVERY request is processed regardless of CPU load average.
Here is an example.
There are ping lowering services, like smoothping.com,where every milisecond of packet processing matters (users run ssh, that connects to server, then they use socks tunnel, provided by openssh, that helps to reduce ping, say from 300ms to 150ms, that is very important in online games).
If your load average is below 0.2 (even Atom 1.6Ghz can manage 100 ssh users with 0.2 LA), then your CPU runs on, say 600Mhz instead of 1.6Ghz, that makes every user connection a bit slower (if you don't beleave me - you can run tests). Does that make sense?
Regards,
Arty
Commented:
Thank you for writing this article. We just bought a bunch of servers with the new Sandybridge chipset and dual E5-2670's. We were expecting much more then they were performing and were not sure why. I researched the KONDEMAND process that was constantly at the top of the task list and found this page. We found that under heavy load the CPU's were only running at half speed.
After following the directions the CPU's are now running at full speed and performing much better. To comment on jjmcd... Well there is a big difference between a home (desktop) user and a data center manager. Most customers pay a fixed rate for power in any data center.