Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cpufreq [2013/04/10 19:03] (current)
Line 1: Line 1:
 +======= cpufreq =======
 +===== Synopsis ======
 +<​nowiki>​Configuring FreeBSD 6.x and later to use Intel SpeedStep or AMD PowerNow/​Cool'​n'​Quiet</​nowiki>​
  
 +====== Intro ======
 +
 +<​nowiki>​After helping several people with this, I decided to set up a small page detailing how to configure your FreeBSD to enable power savings, this is done via the cpufreq kernel module and the powerd program.</​nowiki>​
 +
 +====== cpufreq ======
 +
 +To control the cpustate you need to load the [[http://​www.freebsd.org/​cgi/​man.cgi?​query=cpufreq&​sektion=4|cpufreq(4)]] kernel module, this is done by running ''/​sbin/​kldload cpufreq.ko''​.
 +NOTE: You cannot load kernel modules if in securelevel 1 or above, see below on how to enable the kernel module on the next reboot.
 +
 +You can check if the module is loaded by using the kldstat utility
 +
 +Output of kldstat should be something like this.
 +
 +<​code>​
 +Id Refs Address ​   Size     Name
 + ​1 ​   7 0xc0400000 4a4970 ​  ​kernel
 + ​2 ​   1 0xc08bb000 a504     ​cpufreq.ko
 +</​code>​
 +
 +This will however only work until the next reboot, so you want to add the following line to /​etc/​loader.conf: ​
 +<​code>​
 +cpufreq_load="​YES"​
 +</​code>​
 +
 +This will allow you to view and set the CPU Frequency manually.
 +
 +This is done via the following sysctl'​s:​
 +
 +| dev.cpu.n.freq | The Current CPU Frequency in MHz ((n is the CPU number (starting at 0))).
 +| dev.cpu.n.freq_levels | CPU Frequency levels available in MHz/mW ((milliwatts)). |
 +
 +On some systems the latter part may be -1 for undefined.
 +====== Sample ======
 +
 +Pentium 4 2.8 GHz
 +<​code>​
 +$ sysctl dev.cpu.0.freq dev.cpu.0.freq_levels
 +dev.cpu.0.freq:​ 1050
 +dev.cpu.0.freq_levels:​ 2801/-1 2450/-1 2100/-1 1750/-1 1400/-1 1050/-1 700/-1 350/-1
 +</​code>​
 +
 +====== Setting CPU speed ======
 +
 +dev.cpu.0.freq can be used to view and/or set the current CPU speed, to view the cpuspeed just run sysctl dev.cpu.0.freq,​ to set the speed to something specific use sysctl dev.cpu.0.freq=350 (350 is selected from dev.cpu.0.freq_levels,​ select something available on your platform.
 +
 +====== Using powerd ======
 +
 +You can use powerd(8) to control the CPU speed automatically,​ lets face it - who wants to change the cpu speed manually every time you want to do the sligtest thing on most pc's (this can be good for some solutions however).
 +
 +insert the following line into ''/​etc/​rc.conf''​ ((or ''/​etc/​rc.conf.local''​))
 +<file txt rc.conf>
 +powerd_enable="​YES"​
 +</​file>​
 +
 +Next, run ''/​etc/​rc.d/​powerd''​ start This will start powerd, you should now see a powerd process running
 +Example:
 +
 +<​code>​
 +# ps -ax |grep powerd
 + ​2759 ​ ??  Ss     ​4:​38.18 /​usr/​sbin/​powerd
 +</​code>​
 +
 +====== Verifying the CPU Speed ====== ​
 +
 +You can now see the CPU speed constantly changing with the load of the machine by monitoring dev.cpu.n.freq sysctl.