File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_balance_cpu_performance__44___temperature_and_power_drawn.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (8 years, 7 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD
dos2unix

    1: On a laptop you typically want to conserve battery power. With NetBSD you can set up sysutils/estd to configure the usage of Enhanced Speedstep technology. Estd monitors the ratio between load and idle states the OS records. Seting high- and low-water marks you can control the load above or below which to switch to the next higher or lower CPU frequency, respectively. 
    2: 
    3: Example: 
    4:     
    5:     estd -l 40 -h 70 -b
    6:     
    7: 
    8: If the percentage of idle states goes below 40% lower the CPU frequency to conserve battery. If it goes above 70% increase the frequency. 
    9: 
   10: If you are using a multi-core CPU, estd will use the ratio between the sums over all CPUs of load versus idle states. 
   11: 
   12: So, estd takes care of balancing battery power against performance. 
   13: 
   14: To control temperature you can use envsys(4). 
   15: 
   16: Put into /etc/envsys.conf: 
   17:     
   18:     coretemp0 {
   19:      sensor0 {
   20:       critical-max = 65C;
   21:      }
   22:     }
   23:     coretemp1 {
   24:      sensor0 {
   25:       critical-max = 65C;
   26:      }
   27:     }
   28:     
   29: 
   30: The configuration is activated by issuing 
   31:     
   32:     envstat -c /etc/envsys.conf
   33:     
   34: 
   35: Now the envsys system 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. 
   36: 
   37: In this script I put: 
   38:     
   39:      .
   40:      .
   41:      .
   42:     case "${2}" in
   43:     normal)
   44:      case "${1}" in
   45:      coretemp*)
   46:       echo "estd_flags=\"-l 40 -h 70 -b\"" >/etc/rc.conf.d/estd
   47:       /etc/rc.d/estd restart
   48:       ;;
   49:      esac
   50:      exit 0
   51:      ;;
   52:      .
   53:      .
   54:      .
   55:     critical-over)
   56:      case "${1}" in
   57:      coretemp*)
   58:       /etc/rc.d/estd stop
   59:       sysctl -w machdep.est.frequency.target=600
   60:       ;;
   61:      esac
   62:      exit 0
   63:      ;;
   64:      .
   65:      .
   66:      .
   67:     
   68: 
   69: It works nicely: the temperature sensor goes above 65C under heavy load, the envsys triggers a critical-over event, the script stops estd and sets the frequency to the lowest possible value on my 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... 
   70: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb