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 (http://permalink.gmane.org/gmane.os.openbsd.misc/207078):

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:

</code>

<code>#!/bin/sh

TIME=5 #seconds
CPU_UP_TH=65
GPU_UP_TH=70
CPU_LOW_TH=55
GPU_LOW_TH=65

while :
do
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"
fi
fi

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

sleep ${TIME}
done</code>

<code>

It can be grabbed from http://pastebin.com/HG5rc9tQ

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 (https://nixbsd.wordpress.com/2012/07/03/openbsd-patch-apmd-for-smp-architectures/)

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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s