Archive for April, 2008

Enhanced SpeedStep and thermal monitoring with NetBSD

So there is my new laptop boasting a 2.4GHz dual processor
CPU. NetBSD is installed and it’s time to build all the packages
from pkgsrc that I regularly use. Finding myself compiling several
large packages in parallel, I know I want all the speed the CPU can
offer, but maybe it could run too hot in the build. Particularly,
since I do not like air-con…

With NetBSD I set up sysutils/estd to monitor the ratio between load
and idle states the OS records. Seting high- and low-water marks one
can control the load above or below which to switch to the next higher
or lower CPU frequency, respectively.

That takes care of using the speed available, but doesn’t take care of
limiting the temperature.

To this end I configure envsys(4) by putting into /etc/envsys.conf:

coretemp0 {
        sensor0 {
                critical-max = 65C;
        }
}
coretemp1 {
        sensor0 {
                critical-max = 65C;
        }
}

The configuration is activated by issuing

envstat -c /etc/envsys.conf

Now the envsys sytem will trigger critical events whenever the
temperature of one of these sensors goes above 65C. Such an event
results in executing the script /etc/powerd/sensor_temperarture.

In this script I put:

       .
       .
       .
case "${2}" in
normal)
        case "${1}" in
        coretemp*)
                echo "estd_flags=\"-l 40 -h 70 -b\"" >/etc/rc.conf.d/estd
                /etc/rc.d/estd restart
                ;;
        esac
        exit 0
        ;;
       .
       .
       .
critical-over)
        case "${1}" in
        coretemp*)
                /etc/rc.d/estd stop
                sysctl -w machdep.est.frequency.target=600
                ;;
        esac
        exit 0
        ;;
       .
       .
       .

It works nicely: the temperature sensor goes above 65C, the envsys
triggers a critical-over event, the script stops estd and sets the
frequency to the lowest possible value on this CPU. Under heavy load
it stays there long enough for the sensors to go down to about
52C-55C, before the normal event is triggered, estd is restarted and
the heat rises again…

Advertisements