OpenBSD: Laptop cpu temperature control with APM

In OpenBSD, all versions I tested, I note a performance decrease (in such way as not smooth mouse movement, or web page scrolling) when the maching is doing any heavy reading/writing task or cpu compsuming (i.e. ziping/unziping/copying a big file), even when only one core is running this process and the other ones are running at low load.

In Marc Espie’s words (

Yes, there's something deeply fucked up somewhere in our 
scheduler/disk-handling/whatever. The issue is known.

It appears it is complicated to fix properly without replacing
it by a lot of other problems, some of which pertain to keeping
relatively old archs in working condition, or so I'm told.

A workaround to minimize this effect is running APM in automatic mode (maybe the preferred option for most people). I used to running it in Cooling mode to avoid temperature increases.

Now I use a script to control the APM working mode, automatic when the temperature is lower than a certain threshold, cooling when it increases.

The code is:



TIME=5 #seconds

while :
cpu0=`sysctl hw.sensors.cpu0.temp0 | cut -d= -f 2 | cut -d. -f 1`
gpu0=`sysctl hw.sensors.itherm0.temp4 | cut -d= -f 2 | cut -d. -f 1`
apm=`/usr/sbin/apm -P`

echo "CPU0: ${cpu0} GPU0: ${gpu0} APM: ${apm}"

if [ ${cpu0} -gt ${CPU_UP_TH} ] || [ ${gpu0} -gt ${GPU_UP_TH} ]; then
if [ ${apm} == 1 ]; then
/usr/sbin/apm -C
echo "apm -C"

if [ ${cpu0} -lt ${CPU_LOW_TH} ] || [ ${gpu0} -lt  ${GPU_LOW_TH} ]; then
if [ ${apm} == 2 ]; then
/usr/sbin/apm -A
echo "apm -A"

sleep ${TIME}


It can be grabbed from

Use it at your own risk :). Probably it needs to be modified, to adjust thresholds in other laptops.

It would be great if APM work in such way… even apmd needs to be patched in 5.4 for SMP machines (


About jjjesss

I'm a guy interested in technology, bsd fan and concerned about the world around.
This entry was posted in BSD, OpenBSD and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s