| 1 | <?xml version='1.0' encoding="UTF-8"?> |
1 | <?xml version='1.0' encoding="UTF-8"?> |
| 2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
2 | <!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
| 3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.11 2005/04/18 19:19:27 dertobi123 Exp $ --> |
3 | <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.12 2005/05/04 16:54:18 neysx Exp $ --> |
| 4 | <guide link="power-management-guide.xml"> |
4 | <guide link="power-management-guide.xml"> |
| 5 | <title>Power Management Guide</title> |
5 | <title>Power Management Guide</title> |
| 6 | |
6 | |
| 7 | <author title="Author"> |
7 | <author title="Author"> |
| 8 | <mail link="fragfred@gmx.de">Dennis Nienhüser</mail> |
8 | <mail link="fragfred@gmx.de">Dennis Nienhüser</mail> |
| … | |
… | |
| 15 | |
15 | |
| 16 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
16 | <!-- The content of this document is licensed under the CC-BY-SA license --> |
| 17 | <!-- See http://creativecommons.org/licenses/by-sa/2.0 --> |
17 | <!-- See http://creativecommons.org/licenses/by-sa/2.0 --> |
| 18 | <license/> |
18 | <license/> |
| 19 | |
19 | |
| 20 | <version>1.21</version> |
20 | <version>1.22</version> |
| 21 | <date>2005-04-18</date> |
21 | <date>2005-05-04</date> |
| 22 | |
22 | |
| 23 | <chapter> |
23 | <chapter> |
| 24 | <title>Introduction</title> |
24 | <title>Introduction</title> |
| 25 | |
|
|
| 26 | <section> |
25 | <section> |
| 27 | <title>Why Power Management?</title> |
26 | <title>Why Power Management?</title> |
| 28 | |
|
|
| 29 | <body> |
27 | <body> |
| 30 | |
28 | |
| 31 | <p> |
29 | <p> |
| 32 | Capacity and lifetime of laptop batteries has improved much in the last years. |
30 | Capacity and lifetime of laptop batteries has improved much in the last years. |
| 33 | Nevertheless modern processors consume much more energy than older ones and |
31 | Nevertheless modern processors consume much more energy than older ones and |
| … | |
… | |
| 147 | [ ] Suspend-to-Disk Support |
145 | [ ] Suspend-to-Disk Support |
| 148 | |
146 | |
| 149 | ACPI( Advanced Configuration and Power Interface ) Support ---> |
147 | ACPI( Advanced Configuration and Power Interface ) Support ---> |
| 150 | [*] ACPI Support |
148 | [*] ACPI Support |
| 151 | [ ] Sleep States |
149 | [ ] Sleep States |
| 152 | <M> AC Adapter |
150 | [*] AC Adapter |
| 153 | <M> Battery |
151 | [*] Battery |
| 154 | <M> Button |
152 | <M> Button |
| 155 | <M> Fan |
153 | <M> Fan |
| 156 | <M> Processor |
154 | <M> Processor |
| 157 | <M> Thermal Zone |
155 | <M> Thermal Zone |
| 158 | < > ASUS/Medion Laptop Extras |
156 | < > ASUS/Medion Laptop Extras |
| … | |
… | |
| 171 | </pre> |
169 | </pre> |
| 172 | |
170 | |
| 173 | <p> |
171 | <p> |
| 174 | Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and |
172 | Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and |
| 175 | Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable |
173 | Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable |
| 176 | the appropriate section. Recent kernel versions (2.6.9 and later) include an |
174 | the appropriate section. |
| 177 | <e>'ondemand' governor</e> for CPU Frequency Scaling, activate it as well when |
|
|
| 178 | using such a kernel. |
|
|
| 179 | </p> |
175 | </p> |
| 180 | |
176 | |
| 181 | <p> |
177 | <p> |
| 182 | The kernel has to know how to enable CPU frequency scaling on your processor. As |
178 | The kernel has to know how to enable CPU frequency scaling on your processor. As |
| 183 | each type of CPU has a different interface, you've got to choose the right |
179 | each type of CPU has a different interface, you've got to choose the right |
| … | |
… | |
| 188 | |
184 | |
| 189 | <p> |
185 | <p> |
| 190 | Compile your kernel, make sure the right modules get loaded at startup and boot |
186 | Compile your kernel, make sure the right modules get loaded at startup and boot |
| 191 | into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get |
187 | into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get |
| 192 | the acpi daemon. This one informs you about events like switching from AC to |
188 | the acpi daemon. This one informs you about events like switching from AC to |
| 193 | battery or closing the lid. Make sure the module <e>button</e> is loaded if you |
189 | battery or closing the lid. Make sure the modules are loaded if you didn't |
| 194 | didn't compile it into the kernel and start acpid with <c>/etc/init.d/acpid |
190 | compile them into the kernel and start acpid by executing |
| 195 | start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll |
191 | <c>/etc/init.d/acpid start</c>. Run <c>rc-update add acpid default</c> to load |
| 196 | soon see how to use it. |
192 | it on startup. You'll soon see how to use it. |
| 197 | </p> |
193 | </p> |
| 198 | |
194 | |
| 199 | <pre caption="Installing acpid"> |
195 | <pre caption="Installing acpid"> |
| 200 | # <i>emerge sys-power/acpid</i> |
196 | # <i>emerge sys-power/acpid</i> |
| 201 | # <i>modprobe button</i> |
|
|
| 202 | # <i>/etc/init.d/acpid start</i> |
197 | # <i>/etc/init.d/acpid start</i> |
| 203 | # <i>rc-update add acpid default</i> |
198 | # <i>rc-update add acpid default</i> |
| 204 | </pre> |
199 | </pre> |
| 205 | |
200 | |
| 206 | </body> |
201 | </body> |
| … | |
… | |
| 244 | the sleep button. An important event is changing the power source, which should |
239 | the sleep button. An important event is changing the power source, which should |
| 245 | cause a runlevel switch. Create the following files to switch between |
240 | cause a runlevel switch. Create the following files to switch between |
| 246 | <e>default</e> and <e>battery</e> runlevel depending on the power source: |
241 | <e>default</e> and <e>battery</e> runlevel depending on the power source: |
| 247 | </p> |
242 | </p> |
| 248 | |
243 | |
| 249 | <pre caption="/etc/acpi/switch_runlevel.sh"> |
244 | <pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> |
| 250 | #!/bin/bash |
245 | #!/bin/bash |
| 251 | |
246 | |
|
|
247 | <comment># BEGIN configuration</comment> |
| 252 | RUNLEVEL_AC="default" |
248 | RUNLEVEL_AC="default" |
| 253 | RUNLEVEL_BATTERY="battery" |
249 | RUNLEVEL_BATTERY="battery" |
|
|
250 | <comment># END configuration</comment> |
| 254 | |
251 | |
| 255 | function on_ac () { |
|
|
| 256 | if which on_ac_power &> /dev/null |
|
|
| 257 | then |
|
|
| 258 | on_ac_power |
|
|
| 259 | else |
|
|
| 260 | grep --quiet on-line /proc/acpi/ac_adapter/*/state |
|
|
| 261 | fi |
|
|
| 262 | } |
|
|
| 263 | |
252 | |
| 264 | function SwitchRunlevel () { |
|
|
| 265 | |
|
|
| 266 | if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] |
253 | if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] |
| 267 | then |
254 | then |
| 268 | logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." |
255 | logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." |
| 269 | exit 1 |
256 | exit 1 |
| 270 | fi |
257 | fi |
| 271 | |
258 | |
| 272 | |
|
|
| 273 | if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] |
259 | if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] |
| 274 | then |
260 | then |
| 275 | logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." |
261 | logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." |
| 276 | exit 1 |
262 | exit 1 |
| 277 | fi |
263 | fi |
| 278 | |
264 | |
| 279 | if on_ac |
265 | if on_ac_power |
|
|
266 | then |
| 280 | then if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] |
267 | if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] |
| 281 | then |
268 | then |
| 282 | logger "Switching to ${RUNLEVEL_AC} runlevel" |
269 | logger "Switching to ${RUNLEVEL_AC} runlevel" |
| 283 | /sbin/rc ${RUNLEVEL_AC} |
270 | /sbin/rc ${RUNLEVEL_AC} |
| 284 | fi |
271 | fi |
| 285 | elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] |
272 | elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] |
| 286 | then |
273 | then |
| 287 | logger "Switching to ${RUNLEVEL_BATTERY} runlevel" |
274 | logger "Switching to ${RUNLEVEL_BATTERY} runlevel" |
| 288 | /sbin/rc ${RUNLEVEL_BATTERY} |
275 | /sbin/rc ${RUNLEVEL_BATTERY} |
| 289 | fi |
276 | fi |
| 290 | } |
|
|
| 291 | </pre> |
277 | </pre> |
| 292 | |
278 | |
| 293 | <pre caption="/etc/acpi/events/pmg_ac_adapter"> |
279 | <pre caption="/etc/acpi/events/pmg_ac_adapter"> |
|
|
280 | <comment># replace "ac_adapter" below with the event generated on your laptop</comment> |
|
|
281 | <comment># See /var/log/acpid</comment> |
| 294 | event=ac_adapter.* |
282 | event=ac_adapter.* |
| 295 | action=/etc/acpi/actions/pmg_ac_adapter.sh %e |
283 | action=/etc/acpi/actions/pmg_switch_runlevel.sh %e |
| 296 | </pre> |
284 | </pre> |
| 297 | |
285 | |
| 298 | <pre caption="/etc/acpi/events/pmg_battery"> |
286 | <pre caption="/etc/acpi/events/pmg_battery"> |
|
|
287 | <comment># replace "battery" below with the event generated on your laptop</comment> |
|
|
288 | <comment># See /var/log/acpid</comment> |
| 299 | event=battery.* |
289 | event=battery.* |
| 300 | action=/etc/acpi/actions/pmg_battery.sh %e |
290 | action=/etc/acpi/actions/pmg_switch_runlevel.sh %e |
| 301 | </pre> |
291 | </pre> |
| 302 | |
292 | |
| 303 | <pre caption="/etc/acpi/actions/pmg_ac_adapter.sh"> |
|
|
| 304 | #!/bin/bash |
|
|
| 305 | |
|
|
| 306 | source /etc/acpi/switch_runlevel.sh |
|
|
| 307 | SwitchRunlevel |
|
|
| 308 | </pre> |
|
|
| 309 | |
|
|
| 310 | <pre caption="/etc/acpi/actions/pmg_battery.sh"> |
|
|
| 311 | #!/bin/bash |
|
|
| 312 | |
|
|
| 313 | source /etc/acpi/switch_runlevel.sh |
|
|
| 314 | SwitchRunlevel |
|
|
| 315 | </pre> |
|
|
| 316 | |
|
|
| 317 | <p> |
293 | <p> |
| 318 | Some of these files must be executable. Last not least restart acpid to have |
294 | Additionally you need the package sys-power/powermgmt-base which contains |
| 319 | it recognize the changes. |
295 | the <c>on_ac_power</c> utility. The file <path>pmg_switch_runlevel.sh</path> |
|
|
296 | must be executable. |
| 320 | </p> |
297 | </p> |
| 321 | |
298 | |
| 322 | <pre caption="Finishing runlevel switching with acpid"> |
299 | <pre caption="Finishing runlevel switching with acpid"> |
| 323 | <i># emerge powermgmt-base</i> |
300 | <i># emerge powermgmt-base</i> |
| 324 | <i># chmod +x /etc/acpi/switch_runlevel.sh</i> |
301 | <i># chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</i> |
| 325 | <i># chmod +x /etc/acpi/actions/pmg_*</i> |
|
|
| 326 | <i># /etc/init.d/acpid restart</i> |
302 | <i># /etc/init.d/acpid restart</i> |
| 327 | </pre> |
303 | </pre> |
| 328 | |
304 | |
| 329 | <p> |
305 | <p> |
| 330 | Give it a try: Plug AC in and out and watch syslog for the "Switching to AC |
306 | Give it a try: Plug AC in and out and watch syslog for the "Switching to AC |
| … | |
… | |
| 342 | favourite editor and add these lines: |
318 | favourite editor and add these lines: |
| 343 | </p> |
319 | </p> |
| 344 | |
320 | |
| 345 | <pre caption="Runlevel switch at boot time by editing local.start"> |
321 | <pre caption="Runlevel switch at boot time by editing local.start"> |
| 346 | <comment># Fake acpi event to switch runlevel if running on batteries</comment> |
322 | <comment># Fake acpi event to switch runlevel if running on batteries</comment> |
| 347 | /etc/acpi/actions/pmg_battery.sh "battery/battery" |
323 | /etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery" |
| 348 | </pre> |
324 | </pre> |
| 349 | |
325 | |
| 350 | <p> |
326 | <p> |
| 351 | Prepared like this you can activate Power Management policies for individual |
327 | Prepared like this you can activate Power Management policies for individual |
| 352 | devices. |
328 | devices. |
| … | |
… | |
| 371 | First of all, the kernel has to be able to change the processor's frequency. The |
347 | First of all, the kernel has to be able to change the processor's frequency. The |
| 372 | <e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus |
348 | <e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus |
| 373 | it's important to choose the right one in your kernel. You should already have |
349 | it's important to choose the right one in your kernel. You should already have |
| 374 | done it above. Once the kernel knows how to change frequencies, it has to know |
350 | done it above. Once the kernel knows how to change frequencies, it has to know |
| 375 | which frequency it should set. This is done according to the <e>policy</e> which |
351 | which frequency it should set. This is done according to the <e>policy</e> which |
| 376 | consists of <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are |
352 | consists of a <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are |
| 377 | just two numbers which define a range the frequency has to stay between - |
353 | just two numbers which define a range the frequency has to stay between - |
| 378 | minimal and maximal frequency. The governor now decides which of the available |
354 | minimal and maximal frequency. The governor now decides which of the available |
| 379 | frequencies in between minimal and maximal frequency to choose. For example, the |
355 | frequencies in between minimal and maximal frequency to choose. For example, the |
| 380 | <e>powersave governor</e> always chooses the lowest frequency available, the |
356 | <e>powersave governor</e> always chooses the lowest frequency available, the |
| 381 | <e>performance governor</e> the highest one. The <e>userspace governor</e> makes |
357 | <e>performance governor</e> the highest one. The <e>userspace governor</e> makes |
| … | |
… | |
| 387 | <p> |
363 | <p> |
| 388 | This doesn't sound like dynamic frequency changes yet and in fact it isn't. |
364 | This doesn't sound like dynamic frequency changes yet and in fact it isn't. |
| 389 | Dynamics however can be accomplished with various approaches. For example, |
365 | Dynamics however can be accomplished with various approaches. For example, |
| 390 | the <e>ondemand governor</e> makes its decisions depending on the current CPU |
366 | the <e>ondemand governor</e> makes its decisions depending on the current CPU |
| 391 | load. The same is done by various userland tools like <c>cpudyn</c>, |
367 | load. The same is done by various userland tools like <c>cpudyn</c>, |
| 392 | <c>speedfreq</c>, <c>powernowd</c> and many more. ACPI events can be used to |
368 | <c>cpufreqd</c>, <c>powernowd</c> and many more. ACPI events can be used to |
| 393 | enable or disable dynamic frequency changes depending on power source. |
369 | enable or disable dynamic frequency changes depending on power source. |
| 394 | </p> |
370 | </p> |
| 395 | |
371 | |
| 396 | </body> |
372 | </body> |
| 397 | </section> |
373 | </section> |
| … | |
… | |
| 412 | of supported processors in the <e>Troubleshooting</e> section to verify your's |
388 | of supported processors in the <e>Troubleshooting</e> section to verify your's |
| 413 | is supported. |
389 | is supported. |
| 414 | </note> |
390 | </note> |
| 415 | |
391 | |
| 416 | <p> |
392 | <p> |
| 417 | It's time to test whether CPU frequency changing works. To get comfortable with |
393 | It's time to test whether CPU frequency changing works. Let's install another |
| 418 | the interface to the kernel, first do some manual speed modifications. To set |
394 | tool which is very handy for debugging purposes: <c>sys-power/cpufrequtils</c> |
| 419 | another CPU speed, use: |
|
|
| 420 | </p> |
|
|
| 421 | |
|
|
| 422 | <pre caption="Manual CPU speed modifications"> |
|
|
| 423 | <comment>(Get current frequency)</comment> |
|
|
| 424 | # <i>grep "cpu MHz" /proc/cpuinfo</i> |
|
|
| 425 | |
|
|
| 426 | <comment>(Lists supported frequencies. This might fail.)</comment> |
|
|
| 427 | # <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i> |
|
|
| 428 | # <i>cat scaling_available_frequencies</i> |
|
|
| 429 | |
|
|
| 430 | <comment>(Change frequency to 1 GHz (1000000 KHz) |
|
|
| 431 | Replace with a frequency your laptop supports.)</comment> |
|
|
| 432 | # <i>echo -n userspace > scaling_governor</i> |
|
|
| 433 | # <i>echo -n 1000000 > scaling_setspeed</i> |
|
|
| 434 | |
|
|
| 435 | <comment>(Verify frequency was changed)</comment> |
|
|
| 436 | # <i>grep "cpu MHz" /proc/cpuinfo</i> |
|
|
| 437 | </pre> |
|
|
| 438 | |
|
|
| 439 | <p> |
395 | </p> |
| 440 | If you are getting error messages, please refer to the <e>Troubleshooting</e> |
396 | |
| 441 | chapter in the end of this guide. |
397 | <pre caption="Checking CPU frequency"> |
|
|
398 | # <i>emerge cpufrequtils</i> |
|
|
399 | # <i>cpufreq-info</i> |
|
|
400 | </pre> |
|
|
401 | |
| 442 | </p> |
402 | <p> |
| 443 | |
403 | Here is an example output: |
| 444 | <p> |
404 | </p> |
| 445 | You can also write to <path>scaling_max_freq</path> and |
405 | |
| 446 | <path>scaling_min_freq</path> to set boundaries the frequency should stay in |
406 | <pre caption="Sample output from cpufreq-info"> |
| 447 | between. |
407 | cpufrequtils 0.2: cpufreq-info (C) Dominik Brodowski 2004 |
|
|
408 | Report errors and bugs to linux@brodo.de, please. |
|
|
409 | analyzing CPU 0: |
|
|
410 | driver: centrino |
|
|
411 | CPUs which need to switch frequency at the same time: 0 |
|
|
412 | hardware limits: 600 MHz - 1.40 GHz |
|
|
413 | available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz |
|
|
414 | available cpufreq governors: ondemand, powersave, userspace, performance |
|
|
415 | current policy: frequency should be within 924 MHz and 1.40 GHz. |
|
|
416 | The governor "performance" may decide which speed to use |
|
|
417 | within this range. |
|
|
418 | current CPU frequency is 1.40 GHz (asserted by call to hardware). |
|
|
419 | </pre> |
|
|
420 | |
| 448 | </p> |
421 | <p> |
| 449 | |
422 | Now play around with <c>cpufreq-set</c> to make sure frequency switching works. |
| 450 | <note> |
423 | Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand |
| 451 | Some kernel seem to be buggy about updating <path>/proc/cpuinfo</path>. If you |
424 | governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as |
| 452 | don't see any change there, this doesn't neccessarily mean the CPU frequency |
425 | expected, you might find help in the Troubleshooting section in the end of this |
| 453 | wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your |
426 | guide. |
| 454 | kernel as asked and check the current frequency with <c>x86info -mhz</c>. |
427 | </p> |
| 455 | </note> |
|
|
| 456 | |
428 | |
| 457 | </body> |
429 | </body> |
| 458 | </section> |
430 | </section> |
| 459 | <section> |
431 | <section> |
| 460 | <title>Automated frequency adaption</title> |
432 | <title>Automated frequency adaption</title> |
| … | |
… | |
| 494 | </tr> |
466 | </tr> |
| 495 | <tr> |
467 | <tr> |
| 496 | <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> |
468 | <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> |
| 497 | <ti>Daemon</ti> |
469 | <ti>Daemon</ti> |
| 498 | <ti>CPU load</ti> |
470 | <ti>CPU load</ti> |
| 499 | <ti>None</ti> |
471 | <ti>Performance, powersave</ti> |
| 500 | <ti>Dynamic</ti> |
472 | <ti>Dynamic</ti> |
| 501 | <ti> |
473 | <ti> |
| 502 | Also supports disk standby - notice however that <e>laptop mode</e> in most |
474 | Also supports disk standby - notice however that <e>laptop mode</e> in most |
| 503 | cases will do a better job. |
475 | cases will do a better job. |
| 504 | </ti> |
476 | </ti> |
| … | |
… | |
| 508 | <ti>Daemon</ti> |
480 | <ti>Daemon</ti> |
| 509 | <ti>Battery state, CPU load, running programs</ti> |
481 | <ti>Battery state, CPU load, running programs</ti> |
| 510 | <ti>All available</ti> |
482 | <ti>All available</ti> |
| 511 | <ti>None</ti> |
483 | <ti>None</ti> |
| 512 | <ti> |
484 | <ti> |
| 513 | Sophisticated (but also complicated) setup. An optimal configuration |
485 | Sophisticated (but also complicated) setup. |
| 514 | requires detailed knowledge of your system. |
|
|
| 515 | </ti> |
486 | </ti> |
| 516 | </tr> |
487 | </tr> |
| 517 | <tr> |
488 | <tr> |
| 518 | <ti> |
489 | <ti> |
| 519 | <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> |
490 | <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> |
| … | |
… | |
| 532 | <ti>CPU load</ti> |
503 | <ti>CPU load</ti> |
| 533 | <ti>None</ti> |
504 | <ti>None</ti> |
| 534 | <ti>Dynamic, powersave, performance, fixed speed</ti> |
505 | <ti>Dynamic, powersave, performance, fixed speed</ti> |
| 535 | <ti> |
506 | <ti> |
| 536 | Small yet powerful with an useful client/server interface. Requires a 2.6 |
507 | Small yet powerful with an useful client/server interface. Requires a 2.6 |
| 537 | kernel. |
508 | kernel. Doesn't seem to be maintained anymore and will be removed from |
|
|
509 | Portage in the near future. |
| 538 | </ti> |
510 | </ti> |
| 539 | </tr> |
511 | </tr> |
| 540 | <tr> |
512 | <tr> |
| 541 | <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> |
513 | <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> |
| 542 | <ti>Graphical</ti> |
514 | <ti>Graphical</ti> |
| 543 | <ti>None</ti> |
515 | <ti>None</ti> |
| 544 | <ti>None</ti> |
516 | <ti>None</ti> |
| 545 | <ti>None</ti> |
517 | <ti>None</ti> |
| 546 | <ti> |
518 | <ti> |
| 547 | Gnome application, a graphical tool to set CPU frequency manually. It does |
519 | Gnome application, a graphical tool to set CPU frequency manually. It does |
| 548 | not offer any automation and is mainly listed for the sake of completeness. |
520 | not offer any automation. |
| 549 | </ti> |
521 | </ti> |
| 550 | </tr> |
522 | </tr> |
| 551 | <tr> |
523 | <tr> |
| 552 | <ti>klaptopdaemon</ti> |
524 | <ti>klaptopdaemon</ti> |
| 553 | <ti>Graphical</ti> |
525 | <ti>Graphical</ti> |
| … | |
… | |
| 566 | two frequencies all the time or wasting energy when setting frequency to an |
538 | two frequencies all the time or wasting energy when setting frequency to an |
| 567 | unnecessary high level. |
539 | unnecessary high level. |
| 568 | </p> |
540 | </p> |
| 569 | |
541 | |
| 570 | <p> |
542 | <p> |
| 571 | Which one to choose? If you have no idea about it, first try <c>speedfreq</c>: |
543 | Which one to choose? If you have no idea about it, try <c>cpufreqd</c>: |
| 572 | </p> |
|
|
| 573 | |
|
|
| 574 | <pre caption="Installing speedfreq"> |
|
|
| 575 | # <i>emerge speedfreq</i> |
|
|
| 576 | # <i>rc-update add speedfreq battery</i> |
|
|
| 577 | </pre> |
|
|
| 578 | |
|
|
| 579 | <p> |
544 | </p> |
| 580 | <c>speedfreq</c> can be configured by editing |
|
|
| 581 | <path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able |
|
|
| 582 | to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to |
|
|
| 583 | <c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon. |
|
|
| 584 | </p> |
|
|
| 585 | |
|
|
| 586 | <pre caption="Starting speedfreq"> |
|
|
| 587 | # <i>/etc/init.d/speedfreq start</i> |
|
|
| 588 | </pre> |
|
|
| 589 | |
|
|
| 590 | <p> |
|
|
| 591 | Setting up cpufreqd is a little bit more complicated. |
|
|
| 592 | </p> |
|
|
| 593 | |
|
|
| 594 | <warn> |
|
|
| 595 | Do not run more than one of the above programs at the same time. It may cause |
|
|
| 596 | confusion like switching between two frequencies all the time. If you just |
|
|
| 597 | installed speedfreq, skip cpufreqd now. |
|
|
| 598 | </warn> |
|
|
| 599 | |
545 | |
| 600 | <pre caption="Installing cpufreqd"> |
546 | <pre caption="Installing cpufreqd"> |
| 601 | # <i>emerge cpufreqd</i> |
547 | # <i>emerge cpufreqd</i> |
| 602 | # <i>rc-update add cpufreqd battery</i> |
|
|
| 603 | </pre> |
548 | </pre> |
| 604 | |
549 | |
| 605 | <p> |
|
|
| 606 | <c>cpufreqd</c> comes with a default configuration in |
|
|
| 607 | <path>/etc/cpufreqd.conf</path>. |
|
|
| 608 | Change the config file to fit your needs. The following will save more energy |
|
|
| 609 | than the default one - at the cost of less performance, of course. |
|
|
| 610 | </p> |
550 | <p> |
|
|
551 | <c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. |
|
|
552 | The default one that ships with cpufreqd may look a bit confusing. I recommend |
|
|
553 | replacing it with the one from Gentoo developer Henrik Brix Andersen (see |
|
|
554 | below). |
|
|
555 | </p> |
| 611 | |
556 | |
| 612 | <pre caption="A sample cpufreqd config file"> |
557 | <pre caption="/etc/cpufreqd.conf"> |
| 613 | [General] |
558 | [General] |
| 614 | pidfile=/var/run/cpufreqd.pid |
559 | pidfile=/var/run/cpufreqd.pid |
| 615 | poll_interval=2 |
560 | poll_interval=2 |
| 616 | pm_type=acpi |
561 | pm_type=acpi |
| 617 | <comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5)) |
562 | verbosity=5 |
| 618 | # acpi_workaround=1</comment> |
|
|
| 619 | verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment> |
|
|
| 620 | |
563 | |
| 621 | <comment># Full performance</comment> |
|
|
| 622 | [Profile] |
564 | [Profile] |
|
|
565 | name=ondemand |
|
|
566 | minfreq=0% |
|
|
567 | maxfreq=100% |
|
|
568 | policy=ondemand |
|
|
569 | |
|
|
570 | [Profile] |
|
|
571 | name=powersave |
|
|
572 | minfreq=0% |
|
|
573 | maxfreq=100% |
|
|
574 | policy=powersave |
|
|
575 | |
|
|
576 | [Profile] |
|
|
577 | name=performance |
|
|
578 | minfreq=0% |
|
|
579 | maxfreq=100% |
|
|
580 | policy=performance |
|
|
581 | |
|
|
582 | [Rule] |
|
|
583 | name=battery |
|
|
584 | ac=off |
|
|
585 | profile=ondemand |
|
|
586 | |
|
|
587 | [Rule] |
|
|
588 | name=battery_low |
|
|
589 | ac=off |
|
|
590 | battery_interval=0-10 |
|
|
591 | profile=powersave |
|
|
592 | |
|
|
593 | [Rule] |
| 623 | name=ac |
594 | name=ac |
|
|
595 | ac=on |
|
|
596 | profile=performance |
|
|
597 | </pre> |
|
|
598 | |
|
|
599 | <p> |
|
|
600 | You can't use a percentage value like above for min_freq and max_freq if you |
|
|
601 | are using kernel 2.6 with the sysfs interface (you probably do). Replace it |
|
|
602 | with the lowest and highest frequency as reported by <c>cpufreq-info |
|
|
603 | --hwlimits</c>. For example, on my 1.4 GHz Pentium M I put in |
|
|
604 | </p> |
|
|
605 | |
|
|
606 | <pre caption="Sample values for minfreq and maxfreq"> |
| 624 | minfreq=600000 |
607 | minfreq=600000 |
| 625 | maxfreq=1400000 |
608 | maxfreq=1400000 |
| 626 | policy=performance |
|
|
| 627 | |
|
|
| 628 | <comment># Maximum power saving</comment> |
|
|
| 629 | [Profile] |
|
|
| 630 | name=battery |
|
|
| 631 | minfreq=600000 |
|
|
| 632 | maxfreq=900000 |
|
|
| 633 | policy=powersave |
|
|
| 634 | |
|
|
| 635 | <comment># Constant frequency</comment> |
|
|
| 636 | [Profile] |
|
|
| 637 | name=dvd |
|
|
| 638 | minfreq=900000 |
|
|
| 639 | maxfreq=1100000 |
|
|
| 640 | policy=powersave |
|
|
| 641 | |
|
|
| 642 | <comment># Full performance when running on AC</comment> |
|
|
| 643 | [Rule] |
|
|
| 644 | name=ac_on |
|
|
| 645 | ac=on |
|
|
| 646 | profile=ac |
|
|
| 647 | |
|
|
| 648 | <comment># Compiling should be fast if battery state is ok</comment> |
|
|
| 649 | [Rule] |
|
|
| 650 | name=compiling |
|
|
| 651 | ac=off |
|
|
| 652 | battery_interval=30-100 |
|
|
| 653 | programs=emerge,make,gcc,cpp |
|
|
| 654 | cpu_interval=0-100 |
|
|
| 655 | profile=ac |
|
|
| 656 | |
|
|
| 657 | <comment># watching DVD's gets sluggish with slow CPU frequency |
|
|
| 658 | # Can also be used for games etc.</comment> |
|
|
| 659 | [Rule] |
|
|
| 660 | name=dvd_watching |
|
|
| 661 | ac=off |
|
|
| 662 | battery_interval=15-100 |
|
|
| 663 | programs=xine,mplayer,avidemux,kaffeine,kmplayer |
|
|
| 664 | cpu_interval=0-100 |
|
|
| 665 | profile=dvd |
|
|
| 666 | |
|
|
| 667 | <comment># If above doesn't apply, maximise power saving</comment> |
|
|
| 668 | [Rule] |
|
|
| 669 | name=battery_on |
|
|
| 670 | ac=off |
|
|
| 671 | battery_interval=0-100 |
|
|
| 672 | cpu_interval=0-100 |
|
|
| 673 | profile=battery |
|
|
| 674 | </pre> |
609 | </pre> |
| 675 | |
610 | |
| 676 | <p> |
|
|
| 677 | <c>cpudyn</c> and <c>powernowd</c> are installed in the same way as |
|
|
| 678 | <c>speedfreq</c>. |
|
|
| 679 | </p> |
611 | <p> |
|
|
612 | Last not least start the daemon. |
|
|
613 | </p> |
|
|
614 | |
|
|
615 | <pre caption="Starting cpufreqd"> |
|
|
616 | # <i>rc-update add cpufreqd default battery</i> |
|
|
617 | # <i>rc</i> |
|
|
618 | </pre> |
|
|
619 | |
|
|
620 | <warn> |
|
|
621 | Do not run more than one of the above programs at the same time. It may cause |
|
|
622 | confusion like switching between two frequencies all the time. |
|
|
623 | </warn> |
| 680 | |
624 | |
| 681 | </body> |
625 | </body> |
| 682 | </section> |
626 | </section> |
| 683 | |
627 | |
| 684 | <section> |
628 | <section> |
| … | |
… | |
| 690 | The last thing to check is that your new policies do a good job. An easy way to |
634 | The last thing to check is that your new policies do a good job. An easy way to |
| 691 | do so is monitoring CPU speed while working with your laptop: |
635 | do so is monitoring CPU speed while working with your laptop: |
| 692 | </p> |
636 | </p> |
| 693 | |
637 | |
| 694 | <pre caption="Monitoring CPU speed"> |
638 | <pre caption="Monitoring CPU speed"> |
| 695 | # <i>watch -n 1 'grep "cpu MHz" /proc/cpuinfo'</i> |
639 | # <i>watch grep "cpu MHz" /proc/cpuinfo</i> |
| 696 | </pre> |
640 | </pre> |
| 697 | |
641 | |
| 698 | <p> |
642 | <p> |
| 699 | If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU |
643 | If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting), |
| 700 | frequency with: |
644 | monitor the CPU frequency with: |
| 701 | </p> |
645 | </p> |
| 702 | |
646 | |
| 703 | <pre caption="Alternative CPU speed monitoring"> |
647 | <pre caption="Alternative CPU speed monitoring"> |
| 704 | # <i>watch -n 1 x86info -mhz</i> |
648 | # <i>watch x86info -mhz</i> |
| 705 | </pre> |
649 | </pre> |
| 706 | |
650 | |
| 707 | <p> |
651 | <p> |
| 708 | Depending on your setup, CPU speed should increase on heavy load, decrease on |
652 | Depending on your setup, CPU speed should increase on heavy load, decrease on |
| 709 | no activity or just stay at the same level. |
653 | no activity or just stay at the same level. When using cpufreqd and verbosity |
|
|
654 | set to 5 or higher in <path>cpufreqd.conf</path> you'll get additional |
|
|
655 | information about what's happening reported to syslog. |
| 710 | </p> |
656 | </p> |
| 711 | |
657 | |
| 712 | </body> |
658 | </body> |
| 713 | </section> |
659 | </section> |
| 714 | </chapter> |
660 | </chapter> |
| … | |
… | |
| 761 | </p> |
707 | </p> |
| 762 | |
708 | |
| 763 | <p> |
709 | <p> |
| 764 | Probably more important is the backlight dimming. If you have access to the |
710 | Probably more important is the backlight dimming. If you have access to the |
| 765 | dimming settings via a tool, write a small script that dims the backlight in |
711 | dimming settings via a tool, write a small script that dims the backlight in |
| 766 | battery mode and place it in your <e>battery</e> runlevel. |
712 | battery mode and place it in your <e>battery</e> runlevel. The following script |
|
|
713 | should work on most IBM Thinkpads. It needs the <c>app-laptop/ibm-acpi</c> |
|
|
714 | package or the appropriate option in your kernel has to be enabled. |
|
|
715 | </p> |
|
|
716 | |
|
|
717 | <warn> |
|
|
718 | Support for setting brightness is marked experimental in ibm-acpi. It accesses |
|
|
719 | hardware directly and may cause severe harm to your system. Please read the |
|
|
720 | <uri link="http://ibm-acpi.sourceforge.net/">ibm-acpi website</uri> |
|
|
721 | </warn> |
|
|
722 | |
| 767 | </p> |
723 | <p> |
|
|
724 | To be able to set the brightness level, the ibm_acpi module has to be loaded |
|
|
725 | with the experimental parameter. |
|
|
726 | </p> |
|
|
727 | |
|
|
728 | <pre caption="automatically loading the ibm_acpi module"> |
|
|
729 | <comment>(Please read the warnings above before doing this!)</comment> |
|
|
730 | <i># emerge ibm-acpi</i> |
|
|
731 | <i># echo "options ibm_acpi experimental=1" >> /etc/modules.d/ibm_acpi</i> |
|
|
732 | <i># /sbin/modules-update</i> |
|
|
733 | <i># echo ibm_acpi >> /etc/modules.autoload.d/kernel-2.6</i> |
|
|
734 | <i># modprobe ibm_acpi</i> |
|
|
735 | </pre> |
|
|
736 | |
|
|
737 | <p> |
|
|
738 | This should work without error messages and a file |
|
|
739 | <path>/proc/acpi/ibm/brightness</path> should be created after loading the |
|
|
740 | module. An init script will take care of choosing the brightness according |
|
|
741 | to the power source. |
|
|
742 | </p> |
|
|
743 | |
|
|
744 | <pre caption="/etc/conf.d/lcd-brightness"> |
|
|
745 | <comment># See /proc/acpi/ibm/brightness for available values</comment> |
|
|
746 | <comment># Please read /usr/share/doc/ibm-acpi-*/README.gz</comment> |
|
|
747 | |
|
|
748 | <comment># brigthness level in ac mode. Default is 7.</comment> |
|
|
749 | BRIGHTNESS_AC=7 |
|
|
750 | |
|
|
751 | <comment># brightness level in battery mode. Default is 4.</comment> |
|
|
752 | BRIGHTNESS_BATTERY=4 |
|
|
753 | </pre> |
|
|
754 | |
|
|
755 | <pre caption="/etc/init.d/lcd-brightness"> |
|
|
756 | #!/sbin/runscript |
|
|
757 | |
|
|
758 | set_brightness() { |
|
|
759 | if on_ac_power |
|
|
760 | then |
|
|
761 | LEVEL=${BRIGHTNESS_AC:-7} |
|
|
762 | else |
|
|
763 | LEVEL=${BRIGHTNESS_BATTERY:-4} |
|
|
764 | fi |
|
|
765 | |
|
|
766 | if [ -f /proc/acpi/ibm/brightness ] |
|
|
767 | then |
|
|
768 | ebegin "Setting LCD brightness" |
|
|
769 | echo "level ${LEVEL}" > /proc/acpi/ibm/brightness |
|
|
770 | eend $? |
|
|
771 | else |
|
|
772 | ewarn "Setting LCD brightness is not supported." |
|
|
773 | ewarn "Check that ibm_acpi is loaded into the kernel" |
|
|
774 | fi |
|
|
775 | } |
|
|
776 | |
|
|
777 | start() { |
|
|
778 | set_brightness |
|
|
779 | } |
|
|
780 | |
|
|
781 | stop () { |
|
|
782 | set_brightness |
|
|
783 | } |
|
|
784 | </pre> |
|
|
785 | |
|
|
786 | <p> |
|
|
787 | When done, make sure brightness is adjusted automatically by adding it to the |
|
|
788 | battery runlevel. |
|
|
789 | </p> |
|
|
790 | |
|
|
791 | <pre caption="Enabling automatic brightness adjustment"> |
|
|
792 | <i># chmod +x /etc/init.d/lcd-brightness</i> |
|
|
793 | <i># rc-update add lcd-brightness battery</i> |
|
|
794 | <i># rc</i> |
|
|
795 | </pre> |
| 768 | |
796 | |
| 769 | </body> |
797 | </body> |
| 770 | </section> |
798 | </section> |
| 771 | </chapter> |
799 | </chapter> |
| 772 | |
800 | |
| … | |
… | |
| 809 | <path>/etc/init.d/pm.hda</path> like this: |
837 | <path>/etc/init.d/pm.hda</path> like this: |
| 810 | </p> |
838 | </p> |
| 811 | |
839 | |
| 812 | <pre caption="Using hdparm for disk standby"> |
840 | <pre caption="Using hdparm for disk standby"> |
| 813 | #!/sbin/runscript |
841 | #!/sbin/runscript |
|
|
842 | |
|
|
843 | depend() { |
|
|
844 | after hdparm |
|
|
845 | } |
|
|
846 | |
| 814 | start() { |
847 | start() { |
| 815 | ebegin "Activating Power Management for Hard Drives" |
848 | ebegin "Activating Power Management for Hard Drives" |
| 816 | hdparm -q -S12 /dev/hda |
849 | hdparm -q -S12 /dev/hda |
| 817 | eend $? |
850 | eend $? |
| 818 | } |
851 | } |
| … | |
… | |
| 851 | include the so-called <e>laptop-mode</e>. When activated, dirty buffers are |
884 | include the so-called <e>laptop-mode</e>. When activated, dirty buffers are |
| 852 | written to disk on read calls or after 10 minutes (instead of 30 seconds). This |
885 | written to disk on read calls or after 10 minutes (instead of 30 seconds). This |
| 853 | minimizes the time the hard disk needs to be spun up. |
886 | minimizes the time the hard disk needs to be spun up. |
| 854 | </p> |
887 | </p> |
| 855 | |
888 | |
| 856 | <p> |
|
|
| 857 | <!-- TODO: bug #45593 --> |
|
|
| 858 | Besides kernel support you also need a script that controls starting and |
|
|
| 859 | stopping of laptop-mode. You kernel documentation in |
|
|
| 860 | <path>/usr/src/linux/Documentation/laptop-mode.txt</path> contains one as well |
|
|
| 861 | as the package <c>laptop-mode-tools</c>. None of them is easy to install |
|
|
| 862 | though. |
|
|
| 863 | </p> |
|
|
| 864 | |
|
|
| 865 | <p> |
|
|
| 866 | Ebuilds for laptop-mode-tools are not in Portage, because Gentoo developers |
|
|
| 867 | don't think they are production ready yet. Take that into consideration |
|
|
| 868 | before using the ebuilds which can be found in <uri |
|
|
| 869 | link="http://bugs.gentoo.org/show_bug.cgi?id=45593">Bugzilla</uri>. The Gentoo |
|
|
| 870 | Handbook tells you how to use external ebuilds if you don't know where to put |
|
|
| 871 | them. Once your PORTDIR_OVERLAY contains the ebuilds, install the |
|
|
| 872 | script: |
|
|
| 873 | </p> |
|
|
| 874 | |
|
|
| 875 | <warn> |
|
|
| 876 | This package is not seen as production ready and installing custom ebuilds from |
|
|
| 877 | Bugzilla is not recommended. Please don't use laptop-mode-tools if you're |
|
|
| 878 | unsure. |
|
|
| 879 | </warn> |
|
|
| 880 | |
|
|
| 881 | <pre caption="Automated start of laptop-mode"> |
889 | <pre caption="Automated start of laptop-mode"> |
| 882 | # <i>emerge laptop-mode-tools</i> |
890 | # <i>emerge laptop-mode-tools</i> |
| 883 | </pre> |
891 | </pre> |
| 884 | |
892 | |
| 885 | <p> |
893 | <p> |
| 886 | <c>laptop-mode-tools</c> has it's configuration file in |
894 | <c>laptop-mode-tools</c> has it's configuration file in |
| 887 | <path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it, |
895 | <path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it, |
| 888 | it's well commented. If you have <e>apm</e> or <e>acpi</e> in your USE flags, |
896 | it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it |
| 889 | laptop-mode will be started automatically in battery mode. Otherwise you can |
897 | automatically. |
| 890 | automate it by running <c>rc-update add laptop-mode battery</c>. |
|
|
| 891 | </p> |
898 | </p> |
| 892 | |
899 | |
| 893 | </body> |
900 | </body> |
| 894 | </section> |
901 | </section> |
| 895 | <section> |
902 | <section> |