Diff for /wikisrc/tutorials/how_to_balance_cpu_performance__44___temperature_and_power_drawn.mdwn between versions 1.1 and 1.2

version 1.1, 2011/11/20 20:55:21 version 1.2, 2012/02/05 07:14:36
Line 1 Line 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.  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. 
   
 Example:  Example: 
          
     estd -l 40 -h 70 -b      estd -l 40 -h 70 -b
          
   
 If the percentage of idle states goes below 40% lower the CPU frequency to conserve battery. If it goes above 70% increase the frequency.  If the percentage of idle states goes below 40% lower the CPU frequency to conserve battery. If it goes above 70% increase the frequency. 
   
 If you are using a multi-core CPU, estd will use the ratio between the sums over all CPUs of load versus idle states.  If you are using a multi-core CPU, estd will use the ratio between the sums over all CPUs of load versus idle states. 
   
 So, estd takes care of balancing battery power against performance.  So, estd takes care of balancing battery power against performance. 
   
 To control temperature you can use envsys(4).  To control temperature you can use envsys(4)
   
 Put into /etc/envsys.conf:  Put into /etc/envsys.conf: 
          
     coretemp0 {      coretemp0 {
      sensor0 {       sensor0 {
       critical-max = 65C;        critical-max = 65C;
      }       }
     }      }
     coretemp1 {      coretemp1 {
      sensor0 {       sensor0 {
       critical-max = 65C;        critical-max = 65C;
      }       }
     }      }
          
   
 The configuration is activated by issuing  The configuration is activated by issuing 
          
     envstat -c /etc/envsys.conf      envstat -c /etc/envsys.conf
          
   
 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.  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. 
   
 In this script I put:  In this script I put: 
          
      .       .
      .       .
      .       .
     case "${2}" in      case "${2}" in
     normal)      normal)
      case "${1}" in       case "${1}" in
      coretemp*)       coretemp*)
       echo "estd_flags=\"-l 40 -h 70 -b\"" >/etc/rc.conf.d/estd        echo "estd_flags=\"-l 40 -h 70 -b\"" >/etc/rc.conf.d/estd
       /etc/rc.d/estd restart        /etc/rc.d/estd restart
       ;;        ;;
      esac       esac
      exit 0       exit 0
      ;;       ;;
      .       .
      .       .
      .       .
     critical-over)      critical-over)
      case "${1}" in       case "${1}" in
      coretemp*)       coretemp*)
       /etc/rc.d/estd stop        /etc/rc.d/estd stop
       sysctl -w machdep.est.frequency.target=600        sysctl -w machdep.est.frequency.target=600
       ;;        ;;
      esac       esac
      exit 0       exit 0
      ;;       ;;
      .       .
      .       .
      .       .
          
   
 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...  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... 
   

Removed from v.1.1  
changed lines
  Added in v.1.2


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