Wednesday, May 26, 2010

apm - Advanced Power Management control program

Apm is the Advanced Power Management control program for OpenBSD. it will dynamically increase and decrease the CPU speed of compatible processors in order to balance usable speed with low power and temps.
The reason to use apm is to reduce the cpu temperature of a server system and to slightly reduce the power consumption of that system. When tested on an AMD 4000 CPU one can expect a temperature reduction of 15F degrees and around 10 watts less system usage.This is _not_ a huge reduction, but it may help people at home reduce their electric bills or a small company with a tiny server "closet" save power and cooling costs.
If you want to try out apm then you first need to see if the CPU you have is compatible. Execute a "dmesg" and look for a line starting with "cpu0" that includes cpu speed stepping information. This is the output for a AMD 4000 and is speed stepping compatible. Apm will adjust the cpu speed anywhere from 2400MHz down to 1000MHz.
cpu0: Cool'n'Quiet K8 2403 MHz: speeds: 2400 2200 2000 1800 1000 MHz


Getting Started

To use apm all you have to do is decide how you want apm to act and start the daemon.
Option 1: apm -C will allow apm to increase or decrease the cpu speed depending on cpu load. The idea is that the cpu does not need to run at full speed while lightly loaded. Apm will increase the cpu speed 50% every second if the load is over 70% usage. Once the cpu load drops under 70%, apm will decrease the cpu speed 20% every second till the cpu is at its lowest speed.
Option 2: apm -L will lock the cpu at its lowest speed. The cpu will never increase speed in this mode. You may use this if you have a fast system, but want to reduce the temp/power and do not need the speed.
Option 3: apm -H will lock the cpu at its highest speed. This is useful when you temporarily want the system at full speed.
Once apm is running you can execute "apm" without arguments and see what speed the cpu is currently running at. Here we have the daemon running as "apm -C" and there is no load on the system. The two top lines are for laptops, but since this is a server test box they are useless. The bottom line is what you are looking for.
Battery state: unknown, 0% remaining, unknown life estimate
   A/C adapter state: not known
   Performance adjustment mode: cool running (1000 MHz)
Finally, to get apm to run at boot time you could put the "apm -C" line in the /etc/rc.local file.


For more information about OpenBSD's Pf firewall and HFSC quality of service options check out our PF Config (pf.conf) and PF quality of service HFSC "how to's".

No comments: