NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Script to adjust cpu frequency according to cpu temprature



just noticed Cem's email Date: Thu, 07 May 2009 16:09:31 +0300

I try optimizing:

- non-critical temperatures: let estd manage the processor frequency
- too hot: throttle the cpu frequency and wait for cool-down

Previously, I used this:

http://markoschuetz.wordpress.com/2008/04/29/enhanced-speedstep-and-thermal-monitoring-with-netbsd/

since then I found that estd is sometimes a bit stubborn going away,
so now I use:

/etc/envsys.conf:
coretemp0 {
        sensor0 {
                critical-max = 70C;
                warning-min = 57C;
        }
        refresh-timeout = 1s;
}
coretemp1 {
        sensor0 {
                critical-max = 70C;
                warning-min = 57C;
        }
        refresh-timeout = 1s;
}


/etc/powerd/scripts/sensor_temperature:
#!/bin/sh -
#
#       $NetBSD: sensor_temperature,v 1.3 2007/10/11 00:30:48 xtraeme Exp $
#
# Generic script for temperature sensors.
#
# Arguments passed by powerd(8):
#
#       script_path device event sensor

case "${2}" in
normal)
        logger -p warning "${0}: ($1) normal state entered [${3}]" >&1
        case "${1}" in
        coretemp*)
                echo "estd_flags=\"-l 35 -h 50 -b -M 1200\"" 
>/etc/rc.conf.d/estd
                /etc/rc.d/estd onestop
                pkill -f sbin/estd
                rm -f /var/run/estd.pid
                /etc/rc.d/estd onestart
                ;;
        esac
        exit 0
        ;;
critical)
        logger -p warning "${0}: ($1) critical state entered [${3}]" >&1
        exit 0
        ;;
critical-under)
        logger -p warning "${0}: ($1) dropped below critical limit [${3}]" >&1
        exit 0
        ;;
critical-over)
        logger -p warning "${0}: ($1) critical limit exceeded [${3}]" >&1
        case "${1}" in
        coretemp*)
                echo "estd_flags=\"-l 99 -h 100 -b -M 600\"" 
>/etc/rc.conf.d/estd
                /etc/rc.d/estd onestop
                pkill -f sbin/estd
                rm -f /var/run/estd.pid
                /etc/rc.d/estd onestart
                ;;
        esac
        exit 0
        ;;
warning-under)
        logger -p warning "${0}: ($1) dropped below warning limit [${3}]" >&1
        case "${1}" in
        coretemp*)
                echo "estd_flags=\"-l 35 -h 50 -b -M 1200\"" 
>/etc/rc.conf.d/estd
                /etc/rc.d/estd onestop
                pkill -f sbin/estd
                rm -f /var/run/estd.pid
                /etc/rc.d/estd onestart
                ;;
        esac
        exit 0
        ;;
warning-over)
        logger -p warning "${0}: ($1) warning limit exceeded [${3}]" >&1
        exit 0
        ;;
*)
        logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
        exit 1
        ;;
esac

Works nicely for me.

Best regards,

Marko

Attachment: pgpVmvWzG6HyJ.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index