/[gentoo]/xml/htdocs/doc/en/power-management-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/power-management-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 Revision 1.15
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.14 2005/06/10 18:45:21 swift Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.15 2005/10/28 14:48:06 so Exp $ -->
4<guide link="power-management-guide.xml"> 4<guide link="/doc/en/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>
9</author> 9</author>
12Power Management is the key to extend battery run time on mobile systems like 12Power Management is the key to extend battery run time on mobile systems like
13laptops. This guide assists you setting it up on your laptop. 13laptops. This guide assists you setting it up on your laptop.
14</abstract> 14</abstract>
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.5 -->
18<license/> 18<license/>
19 19
20<version>1.24</version> 20<version>1.25</version>
21<date>2005-06-10</date> 21<date>2005-10-02</date>
22 22
23<chapter> 23<chapter>
24<title>Introduction</title> 24<title>Introduction</title>
25<section> 25<section>
26<title>Why Power Management?</title> 26<title>Why Power Management?</title>
27<body> 27<body>
28 28
29<p> 29<p>
30Capacity and lifetime of laptop batteries has improved much in the last years. 30Capacity and lifetime of laptop batteries have improved much in the last years.
31Nevertheless modern processors consume much more energy than older ones and 31Nevertheless modern processors consume much more energy than older ones and
32each laptop generation introduces more devices hungry for energy. That's why 32each laptop generation introduces more devices hungry for energy. That's why
33Power Management is more important than ever. Increasing battery run time 33Power Management is more important than ever. Increasing battery run time
34doesn't necessarily mean buying another battery. Much can be achieved applying 34doesn't necessarily mean buying another battery. Much can be achieved applying
35intelligent Power Management policies. 35intelligent Power Management policies.
56 56
57<p> 57<p>
58The <e>Prerequisites</e> chapter talks about some requirements that should be 58The <e>Prerequisites</e> chapter talks about some requirements that should be
59met before any of the following device individual sections will work. This 59met before any of the following device individual sections will work. This
60includes BIOS settings, kernel configuration and some simplifications in user 60includes BIOS settings, kernel configuration and some simplifications in user
61land. The following three chapters focus on devices that typically consume most 61land. The following three chapters focus on devices that typically consume
62energy - processor, display and hard drive. Each can be configured seperately. 62most energy - processor, display and hard drive. Each can be configured
63<e>CPU Power Management</e> shows how to adjust the processor's frequency to 63seperately. <e>CPU Power Management</e> shows how to adjust the processor's
64save a maximum of energy whithout losing too much performance. A few different 64frequency to save a maximum of energy whithout losing too much performance. A
65tricks prevent your hard drive from working unnecessarily often in <e>Disk Power 65few different tricks prevent your hard drive from working unnecessarily often
66Management</e> (decreasing noise level as a nice side effect). Some notes on 66in <e>Disk Power Management</e> (decreasing noise level as a nice side
67Wireless LAN and USB finish the device section in <e>Power Management for other 67effect). Some notes on graphics cards, Wireless LAN and USB finish the device
68devices</e> while another chapter is dedicated to the (rather experimental) 68section in <e>Power Management for other devices</e> while another chapter is
69<e>sleep states</e>. Last not least <e>Troubleshooting</e> lists common 69dedicated to the (rather experimental) <e>sleep states</e>. Last not least
70pitfalls. 70<e>Troubleshooting</e> lists common pitfalls.
71</p> 71</p>
72 72
73</body> 73</body>
74</section> 74</section>
75 75
133still work in progress. Using a recent kernel will make sure you'll get the 133still work in progress. Using a recent kernel will make sure you'll get the
134most out of it. 134most out of it.
135</p> 135</p>
136 136
137<p> 137<p>
138There are different kernel sources in Portage. I'd recommend using
139<c>gentoo-sources</c> or <c>suspend2-sources</c>. The latter contains patches
140for Software Suspend 2, see the chapter about sleep states for details. When
138In kernel config, activate at least these options: 141configuring the kernel, activate at least these options:
139</p> 142</p>
140 143
141<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)"> 144<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
142Power Management Options ---&gt; 145Power Management Options ---&gt;
143 [*] Power Management Support 146 [*] Power Management Support
144 [ ] Software Suspend 147 [ ] Software Suspend
145 [ ] Suspend-to-Disk Support
146 148
147 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
148 [*] ACPI Support 150 [*] ACPI Support
149 [ ] Sleep States 151 [ ] Sleep States
152 [ ] /proc/acpi/sleep (deprecated)
150 [*] AC Adapter 153 [*] AC Adapter
151 [*] Battery 154 [*] Battery
152 &lt;M&gt; Button 155 &lt;M&gt; Button
156 &lt;M&gt; Video
157 [ ] Generic Hotkey
153 &lt;M&gt; Fan 158 &lt;M&gt; Fan
154 &lt;M&gt; Processor 159 &lt;M&gt; Processor
155 &lt;M&gt; Thermal Zone 160 &lt;M&gt; Thermal Zone
156 &lt; &gt; ASUS/Medion Laptop Extras 161 &lt; &gt; ASUS/Medion Laptop Extras
162 &lt; &gt; IBM ThinkPad Laptop Extras
157 &lt; &gt; Toshiba Laptop Extras 163 &lt; &gt; Toshiba Laptop Extras
164 (0) Disable ACPI for systems before Jan 1st this year
158 [ ] Debug Statements 165 [ ] Debug Statements
166 [*] Power Management Timer Support
167 &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
159 168
160 CPU Frequency Scaling ---&gt; 169 CPU Frequency Scaling ---&gt;
161 [*] CPU Frequency scaling 170 [*] CPU Frequency scaling
171 [ ] Enable CPUfreq debugging
172 &lt; &gt; CPU frequency translation statistics
173 [ ] CPU frequency translation statistics details
162 Default CPUFreq governor (userspace) 174 Default CPUFreq governor (userspace)
163 &lt;*&gt; 'performance' governor 175 &lt;*&gt; 'performance' governor
164 &lt;*&gt; 'powersave' governor 176 &lt;*&gt; 'powersave' governor
165 &lt;*&gt; 'ondemand' cpufreq policy governor 177 &lt;*&gt; 'ondemand' cpufreq policy governor
178 &lt;*&gt; 'conservative' cpufreq governor
166 &lt;*&gt; CPU frequency table helpers 179 &lt;*&gt; CPU frequency table helpers
167 &lt;M&gt; ACPI Processor P-States driver 180 &lt;M&gt; ACPI Processor P-States driver
168 &lt;*&gt; <i>CPUFreq driver for your processor</i> 181 &lt;*&gt; <i>CPUFreq driver for your processor</i>
169</pre> 182</pre>
170 183
171<p> 184<p>
172Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and 185Decide yourself whether you want to enable Software Suspend, and Sleep States
173Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable 186(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
174the appropriate section. 187the appropriate section.
175</p> 188</p>
176 189
177<p> 190<p>
178The kernel has to know how to enable CPU frequency scaling on your processor. As 191The kernel has to know how to enable CPU frequency scaling on your processor. As
235<body> 248<body>
236 249
237<p> 250<p>
238Typical ACPI events are closing the lid, changing the power source or pressing 251Typical ACPI events are closing the lid, changing the power source or pressing
239the sleep button. An important event is changing the power source, which should 252the sleep button. An important event is changing the power source, which should
240cause a runlevel switch. Create the following files to switch between 253cause a runlevel switch. A small script will take care of it.
241<e>default</e> and <e>battery</e> runlevel depending on the power source: 254</p>
255
256<p>
257First you need a script which changes the runlevel to <c>default</c>
258respectively <c>battery</c> depending on the power source. The script uses the
259<c>on_ac_power</c> command from <c>sys-power/powermgmt-base</c> - make sure the
260package is installed on your system.
261</p>
262
263<pre caption="Installing powermgt-base">
264<i># emerge powermgmt-base</i>
265</pre>
266
267<p>
268You are now able to determine the power source by executing
269<c>on_ac_power &amp;&amp; echo AC available || echo Running on batteries</c> in
270a shell. The script below is responsible for changing runlevels. Save it as
271<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
242</p> 272</p>
243 273
244<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh"> 274<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
245#!/bin/bash 275#!/bin/bash
246 276
274 logger "Switching to ${RUNLEVEL_BATTERY} runlevel" 304 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
275 /sbin/rc ${RUNLEVEL_BATTERY} 305 /sbin/rc ${RUNLEVEL_BATTERY}
276fi 306fi
277</pre> 307</pre>
278 308
309<p>
310Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to
311make the script executable. The last thing that needs to be done is calling the
312script whenever the power source changes. That's done by catching ACPI events
313with the help of <c>acpid</c>. First you need to know which events are
314generated when the power source changes. The events are called
315<e>ac_adapter</e> and <e>battery</e> on most laptops, but it might be different
316on yours.
317</p>
318
319<pre caption="Determining ACPI events for changing the power source">
320<i># tail -f /var/log/acpid | grep "received event"</i>
321</pre>
322
323<p>
324Run the command above and pull the power cable. You should see something
325like this:
326</p>
327
328<pre caption="Sample output for power source changes">
329[Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000"
330[Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001"
331</pre>
332
333<p>
334The interesting part is the quoted string after <e>received event</e>. It will
335be matched by the event line in the files you are going to create below. Don't
336worry if your system generates multiple events or always the same. As long as
337any event is generated, runlevel changing will work.
338</p>
339
279<pre caption="/etc/acpi/events/pmg_ac_adapter"> 340<pre caption="/etc/acpi/events/pmg_ac_adapter">
280<comment># replace "ac_adapter" below with the event generated on your laptop</comment> 341<comment># replace "ac_adapter" below with the event generated on your laptop</comment>
281<comment># See /var/log/acpid</comment> 342<comment># For example, ac_adapter.* will match ac_adapter AC 00000080 00000000</comment>
282event=ac_adapter.* 343event=ac_adapter.*
283action=/etc/acpi/actions/pmg_switch_runlevel.sh %e 344action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
284</pre> 345</pre>
285 346
286<pre caption="/etc/acpi/events/pmg_battery"> 347<pre caption="/etc/acpi/events/pmg_battery">
287<comment># replace "battery" below with the event generated on your laptop</comment> 348<comment># replace "battery" below with the event generated on your laptop</comment>
288<comment># See /var/log/acpid</comment> 349<comment># For example, battery.* will match battery BAT0 00000080 00000001</comment>
289event=battery.* 350event=battery.*
290action=/etc/acpi/actions/pmg_switch_runlevel.sh %e 351action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
291</pre> 352</pre>
292 353
293<p> 354<p>
294Additionally you need the package sys-power/powermgmt-base which contains 355Finally acpid has to be restarted to recognize the changes.
295the <c>on_ac_power</c> utility. The file <path>pmg_switch_runlevel.sh</path>
296must be executable.
297</p> 356</p>
298 357
299<pre caption="Finishing runlevel switching with acpid"> 358<pre caption="Finishing runlevel switching with acpid">
300<i># emerge powermgmt-base</i>
301<i># chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</i>
302<i># /etc/init.d/acpid restart</i> 359<i># /etc/init.d/acpid restart</i>
303</pre> 360</pre>
304 361
305<p> 362<p>
306Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 363Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
308section if the script is not able to detect the power source correctly. 365section if the script is not able to detect the power source correctly.
309</p> 366</p>
310 367
311<p> 368<p>
312Due to the nature of the event mechanism, your laptop will boot into runlevel 369Due to the nature of the event mechanism, your laptop will boot into runlevel
313<e>default</e> regardless of the AC/battery state. You can add another entry 370<e>default</e> regardless of the AC/battery state. This is fine when running
314to the boot loader with <c>softlevel=battery</c>, but it's likely to forget 371from AC, but we'd like to boot into the battery runlevel otherwise. One
315choosing it. A better way is faking an ACPI event in the end of the boot 372solution would be to add another entry to the boot loader with the parameter
316process and let the <path>/etc/acpi/default.sh</path> script decide whether a 373<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
374is faking an ACPI event in the end of the boot process and letting
375<path>pmg_switch_runlevel.sh</path> script decide whether a
317runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your 376runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your
318favourite editor and add these lines: 377favourite editor and add these lines:
319</p> 378</p>
320 379
321<pre caption="Runlevel switch at boot time by editing local.start"> 380<pre caption="Runlevel adjustment at boot time by editing local.start">
322<comment># Fake acpi event to switch runlevel if running on batteries</comment> 381<comment># Fake acpi event to switch runlevel if running on batteries</comment>
323/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery" 382/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
324</pre> 383</pre>
325 384
326<p> 385<p>
342CPU frequency scaling brings up some technical terms that might be unknown to 401CPU frequency scaling brings up some technical terms that might be unknown to
343you. Here's a quick introduction. 402you. Here's a quick introduction.
344</p> 403</p>
345 404
346<p> 405<p>
347First of all, the kernel has to be able to change the processor's frequency. The 406First of all, the kernel has to be able to change the processor's frequency.
348<e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus 407The <e>CPUfreq processor driver</e> knows the commands to do it on your CPU.
349it's important to choose the right one in your kernel. You should already have 408Thus it's important to choose the right one in your kernel. You should
350done it above. Once the kernel knows how to change frequencies, it has to know 409already have done it above. Once the kernel knows how to change frequencies,
351which frequency it should set. This is done according to the <e>policy</e> which 410it has to know which frequency it should set. This is done according to the
352consists of a <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are 411<e>policy</e> which consists of a <e>CPUfreq policy</e> and a
353just two numbers which define a range the frequency has to stay between - 412<e>governor</e>. A CPUfreq policy are just two numbers which define a range
354minimal and maximal frequency. The governor now decides which of the available 413the frequency has to stay between - minimal and maximal frequency. The
355frequencies in between minimal and maximal frequency to choose. For example, the 414governor now decides which of the available frequencies in between minimal
356<e>powersave governor</e> always chooses the lowest frequency available, the 415and maximal frequency to choose. For example, the <e>powersave governor</e>
416always chooses the lowest frequency available, the <e>performance
357<e>performance governor</e> the highest one. The <e>userspace governor</e> makes 417governor</e> the highest one. The <e>userspace governor</e> makes no decision
358no decision but chooses whatever the user (or a program in userspace) wants - 418but chooses whatever the user (or a program in userspace) wants - which means
359which means it reads the frequency from 419it reads the frequency from
360<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>. 420<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
361</p> 421</p>
362 422
363<p> 423<p>
364This doesn't sound like dynamic frequency changes yet and in fact it isn't. 424This doesn't sound like dynamic frequency changes yet and in fact it isn't.
402<p> 462<p>
403Here is an example output: 463Here is an example output:
404</p> 464</p>
405 465
406<pre caption="Sample output from cpufreq-info"> 466<pre caption="Sample output from cpufreq-info">
407cpufrequtils 0.2: cpufreq-info (C) Dominik Brodowski 2004 467cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
408Report errors and bugs to linux@brodo.de, please. 468Report errors and bugs to linux@brodo.de, please.
409analyzing CPU 0: 469analyzing CPU 0:
410 driver: centrino 470 driver: centrino
411 CPUs which need to switch frequency at the same time: 0 471 CPUs which need to switch frequency at the same time: 0
412 hardware limits: 600 MHz - 1.40 GHz 472 hardware limits: 600 MHz - 1.40 GHz
413 available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz 473 available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
414 available cpufreq governors: ondemand, powersave, userspace, performance 474 available cpufreq governors: conservative, ondemand, powersave, userspace, performance
415 current policy: frequency should be within 924 MHz and 1.40 GHz. 475 current policy: frequency should be within 924 MHz and 1.40 GHz.
416 The governor "performance" may decide which speed to use 476 The governor "performance" may decide which speed to use
417 within this range. 477 within this range.
418 current CPU frequency is 1.40 GHz (asserted by call to hardware). 478 current CPU frequency is 1.40 GHz.
419</pre> 479</pre>
420 480
421<p> 481<p>
422Now play around with <c>cpufreq-set</c> to make sure frequency switching works. 482Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
423Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand 483Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
432<title>Automated frequency adaption</title> 492<title>Automated frequency adaption</title>
433<body> 493<body>
434 494
435<p> 495<p>
436The above is quite nice, but not doable in daily life. Better let your system 496The above is quite nice, but not doable in daily life. Better let your system
437set the appropriate frequency automatically. There are many different approaches 497set the appropriate frequency automatically. There are many different
438to do this. The following table gives a quick overview to help you decide on one 498approaches to do this. The following table gives a quick overview to help you
439of them. It's roughly seperated in three categories <e>kernel</e> for approaches 499decide on one of them. It's roughly seperated in three categories
440that only need kernel support, <e>daemon</e> for programs that run in the 500<e>kernel</e> for approaches that only need kernel support, <e>daemon</e> for
441background and <e>graphical</e> for programs that provide a GUI for easy 501programs that run in the background and <e>graphical</e> for programs that
442configuration and changes. 502provide a GUI for easy configuration and changes.
443</p> 503</p>
444 504
445<table> 505<table>
446<tr> 506<tr>
447 <th>Name</th> 507 <th>Name</th>
456 <ti>Kernel</ti> 516 <ti>Kernel</ti>
457 <ti>CPU load</ti> 517 <ti>CPU load</ti>
458 <ti>N.A.</ti> 518 <ti>N.A.</ti>
459 <ti>N.A.</ti> 519 <ti>N.A.</ti>
460 <ti> 520 <ti>
521 Chooses maximal frequency on CPU load and slowly steps down when the CPU is
461 Further tuning through files in 522 idle. Further tuning through files in
462 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires 523 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
463 userland tools (programs, scripts) if governor switching or similar is 524 userland tools (programs, scripts) if governor switching or similar is
464 desired. 525 desired.
526 </ti>
527</tr>
528<tr>
529 <ti>'conservative' governor</ti>
530 <ti>Kernel</ti>
531 <ti>CPU load</ti>
532 <ti>N.A.</ti>
533 <ti>N.A.</ti>
534 <ti>
535 Unlike the ondemand governor, conversative doesn't jump to maximum
536 frequency when CPU load is high, but increases the frequency step by
537 step. Further tuning through files in
538 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still
539 requires userland tools (programs, scripts) if governor switching or
540 similar is desired.
465 </ti> 541 </ti>
466</tr> 542</tr>
467<tr> 543<tr>
468 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> 544 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
469 <ti>Daemon</ti> 545 <ti>Daemon</ti>
476 </ti> 552 </ti>
477</tr> 553</tr>
478<tr> 554<tr>
479 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti> 555 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
480 <ti>Daemon</ti> 556 <ti>Daemon</ti>
481 <ti>Battery state, CPU load, running programs</ti> 557 <ti>Battery state, CPU load, temperature, running programs</ti>
482 <ti>All available</ti> 558 <ti>All available</ti>
483 <ti>None</ti> 559 <ti>None</ti>
484 <ti> 560 <ti>
485 Sophisticated (but also complicated) setup. 561 Sophisticated (but also complicated) setup.
486 </ti> 562 </ti>
496 <ti> 572 <ti>
497 Supports SMP. 573 Supports SMP.
498 </ti> 574 </ti>
499</tr> 575</tr>
500<tr> 576<tr>
577 <ti>
578 <uri link="http://fatcat.ftj.agh.edu.pl/~nelchael/index.php?cat=projs&amp;subcat=ncpufreqd&amp;language=en">ncpufreqd</uri>
579 </ti>
580 <ti>Daemon</ti>
581 <ti>Temperature</ti>
582 <ti>None</ti>
583 <ti>Powersave, performance</ti>
584 <ti>
585 Toggles the used governor between performance and powersave depending on
586 system temperature. Very useful on laptops with notorious heat problems.
587 </ti>
588</tr>
589<tr>
501 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti> 590 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
502 <ti>Daemon</ti> 591 <ti>Daemon</ti>
503 <ti>CPU load</ti> 592 <ti>CPU load</ti>
504 <ti>None</ti> 593 <ti>None</ti>
505 <ti>Dynamic, powersave, performance, fixed speed</ti> 594 <ti>Dynamic, powersave, performance, fixed speed</ti>
506 <ti> 595 <ti>
507 Small yet powerful with an useful client/server interface. Requires a 2.6 596 Easy to configure with a nice client/server interface. Requires a 2.6
508 kernel. Doesn't seem to be maintained anymore and will be removed from 597 kernel. Unmaintained, broken and thus removed from Portage. Please switch
509 Portage in the near future. 598 to cpufreqd if you're still using it.
510 </ti> 599 </ti>
511</tr> 600</tr>
512<tr> 601<tr>
513 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> 602 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
514 <ti>Graphical</ti> 603 <ti>Graphical</ti>
531 </ti> 620 </ti>
532</tr> 621</tr>
533</table> 622</table>
534 623
535<p> 624<p>
536While adjusting the frequency to the current load looks simple on the first 625While adjusting the frequency to the current load looks simple at a first
537view, it's not such a trivial task. A bad algorithm can cause switching between 626glance, it's not such a trivial task. A bad algorithm can cause switching
538two frequencies all the time or wasting energy when setting frequency to an 627between two frequencies all the time or wasting energy when setting frequency
539unnecessary high level. 628to an unnecessary high level.
540</p> 629</p>
541 630
542<p> 631<p>
543Which one to choose? If you have no idea about it, try <c>cpufreqd</c>: 632Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
544</p> 633</p>
566minfreq=0% 655minfreq=0%
567maxfreq=100% 656maxfreq=100%
568policy=ondemand 657policy=ondemand
569 658
570[Profile] 659[Profile]
660name=conservative
661minfreq=0%
662maxfreq=100%
663policy=conservative
664
665[Profile]
571name=powersave 666name=powersave
572minfreq=0% 667minfreq=0%
573maxfreq=100% 668maxfreq=100%
574policy=powersave 669policy=powersave
575 670
580policy=performance 675policy=performance
581 676
582[Rule] 677[Rule]
583name=battery 678name=battery
584ac=off 679ac=off
585profile=ondemand 680profile=conservative
586 681
587[Rule] 682[Rule]
588name=battery_low 683name=battery_low
589ac=off 684ac=off
590battery_interval=0-10 685battery_interval=0-10
591profile=powersave 686profile=powersave
592 687
593[Rule] 688[Rule]
594name=ac 689name=ac
595ac=on 690ac=on
596profile=performance 691profile=ondemand
597</pre> 692</pre>
598 693
599<p>
600You can't use a percentage value like above for min_freq and max_freq if you
601are using kernel 2.6 with the sysfs interface (you probably do). Replace it
602with 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> 694<p>
605 695Now you can start the cpufreqd daemon. Add it to the <e>default</e> and
606<pre caption="Sample values for minfreq and maxfreq"> 696<e>battery</e> runlevel as well.
607minfreq=600000
608maxfreq=1400000
609</pre>
610
611<p>
612Last not least start the daemon.
613</p> 697</p>
614 698
615<pre caption="Starting cpufreqd"> 699<pre caption="Starting cpufreqd">
616# <i>rc-update add cpufreqd default battery</i> 700# <i>rc-update add cpufreqd default battery</i>
617# <i>rc</i> 701# <i>rc</i>
677First thing to check is the standby/suspend/off timings of the display. As this 761First thing to check is the standby/suspend/off timings of the display. As this
678depends heavily on your windowmanager, I'll let you figure it out yourself. 762depends heavily on your windowmanager, I'll let you figure it out yourself.
679Just two common places: Blanking the terminal can be done with <c>setterm 763Just two common places: Blanking the terminal can be done with <c>setterm
680-blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and 764-blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and
681<c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. 765<c>setterm -powerdown &lt;number-of-minutesM&gt;</c>.
682For Xorg, modify <path>/etc/X11/xorg.conf</path> similar to this: 766For X.org, modify <path>/etc/X11/xorg.conf</path> similar to this:
683</p> 767</p>
684 768
685<pre caption="LCD suspend settings in Xorg and XFree86"> 769<pre caption="LCD suspend settings in X.org and XFree86">
686Section "ServerLayout" 770Section "ServerLayout"
687 Identifier [...] 771 Identifier [...]
688 [...] 772 [...]
689 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment> 773 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
690 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment> 774 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
952</chapter> 1036</chapter>
953 1037
954<chapter> 1038<chapter>
955<title>Power Management for other devices</title> 1039<title>Power Management for other devices</title>
956<section> 1040<section>
1041<title>Graphics cards</title>
1042<body>
1043
1044<p>
1045In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1046scaling for the the graphics processing unit GPU), you can activate this
1047feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable)
1048the <c>DynamicClocks</c> option in the Device section. Please notice that
1049this feature will lead to crashes on some systems.
1050</p>
1051
1052<pre caption="Enabling ATI PowerPlay support in X.org">
1053Section "Device"
1054[...]
1055Option "DynamicClocks" "on"
1056EndSection
1057</pre>
1058
1059</body>
1060</section>
1061<section>
957<title>Wireless Power Management</title> 1062<title>Wireless Power Management</title>
958<body> 1063<body>
959 1064
960<p> 1065<p>
961Wireless LAN cards consume quite a few energy. Put them in Power Management 1066Wireless LAN cards consume quite a few energy. Put them in Power Management
1002There are two problems with USB devices regarding energy consumption: First, 1107There are two problems with USB devices regarding energy consumption: First,
1003devices like USB mice, digital cameras or USB sticks consume energy while 1108devices like USB mice, digital cameras or USB sticks consume energy while
1004plugged in. You cannot avoid this (nevertheless remove them in case they're not 1109plugged in. You cannot avoid this (nevertheless remove them in case they're not
1005needed). Second, when there are USB devices plugged in, the USB host controller 1110needed). Second, when there are USB devices plugged in, the USB host controller
1006periodically accesses the bus which in turn prevents the CPU from going into 1111periodically accesses the bus which in turn prevents the CPU from going into
1007C3/4 sleep mode. The OS answer to this problem is the so called "USB selective 1112sleep mode. The kernel offers an experimental option to enable suspension of
1008suspend", which has not yet been implemented in the kernel. USB selective 1113USB devices through driver calls or one of the <path>power/state</path> files
1009suspend only allows bus accesses in case the device is in use. The cruel 1114in <path>/sys</path>.
1010workaround until it's implemented is as following: Compile USB support and 1115</p>
1011devices as modules and remove them via a script while they are not in use (e.g. 1116
1012when closing the lid). 1117<pre caption="Enabling USB suspend support in the kernel">
1118Device Drivers
1119 USB support
1120 [*] Support for Host-side USB
1121 [*] USB suspend/resume (EXPERIMENTAL)
1013</p> 1122</pre>
1014 1123
1015</body> 1124</body>
1016</section> 1125</section>
1017</chapter> 1126</chapter>
1018 1127
1038</p> 1147</p>
1039 1148
1040</body> 1149</body>
1041</section> 1150</section>
1042<section> 1151<section>
1043<title>Sleep, Standby &amp; Hibernate</title> 1152<title>Sleep (S3)</title>
1044<body> 1153<body>
1045 1154
1046<p> 1155<p>
1047The ACPI support for these sleep states is marked as experimental for good 1156The ACPI support for these sleep states is marked experimental for good reason.
1048reason. APM sleep states seem to be more stable, however you can't use APM and 1157APM sleep states seem to be more stable, however you can't use APM and ACPI
1049ACPI together. 1158together.
1159</p>
1160
1161<pre caption="Kernel configuration for the various suspend types">
1162 Power Management Options ---&gt;
1163 [*] Power Management support
1164 ACPI (Advanced Configuration and Power Interface) Support ---&gt;
1165 [*] ACPI Support
1166 [*] Sleep States
1167</pre>
1168
1169<p>
1170Once your kernel is prepared like above, you can use the
1171<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1172first.
1173</p>
1174
1175<pre caption="Installing the hibernate-script">
1176<i># emerge hibernate-script</i>
1177</pre>
1178
1179<p>
1180Some configuration has to be done in <path>/etc/hibernate</path> The default
1181package introduces two configuration files <path>hibernate.conf</path> and
1182<path>ram.conf</path>.
1183</p>
1184
1185<p>
1186To configure sleep, edit <path>ram.conf</path> in <path>/etc/hibernate</path>.
1187<c>UseSysfsPowerState mem</c> is already setup correctly, but you have to go
1188through the rest of the configuration file and set it up for your system. The
1189comments and option names will guide you. If you use nfs or samba shares over
1190the network, make sure to shutdown the appropriate init scripts to avoid
1191timeouts.
1192</p>
1193
1194<p>
1195Ready? Now is the last chance to backup any data you want to keep after
1196executing the next command. Notice that you probably have to hit a special key
1197like <e>Fn</e> to resume from sleep.
1198</p>
1199
1200<pre caption="Calling sleep">
1201<i># hibernate-ram</i>
1202</pre>
1203
1204<p>
1205If you're still reading, it seems to work. You can also setup standby (S1) in
1206a similar way by copying <path>ram.conf</path> to <path>standby.conf</path>
1207and creating a symlink <path>/usr/sbin/hibernate-standby</path> pointing to
1208<path>/usr/sbin/hibernate</path>. S3 and S4 are the more interesting sleep
1209states due to greater energy savings however.
1210</p>
1211
1212</body>
1213</section>
1214<section>
1215<title>Hibernate (S4)</title>
1216<body>
1217
1218<p>
1219This section introduces hibernation, where a snapshot of the running system is
1220written to disk before powering off. On resume, the snapshot is loaded and you
1221can go on working at exactly the point you called hibernate before.
1050</p> 1222</p>
1051 1223
1052<warn> 1224<warn>
1053Altough sleep state support is improving much, it's still rather experimental. 1225Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
1054At last I got swsusp2 and suspend to RAM to work, but be warned: This will very 1226a snapshot with a different kernel image than the one it was created with.
1055likely not work but damage your data/system. 1227Shutdown any NFS or samba server/client before hibernating.
1056</warn> 1228</warn>
1057 1229
1058<p> 1230<p>
1059There are currently three implementations for S4. The original one is swsusp, 1231There are two different implementations for S4. The original one is swsusp,
1060then there is swsusp2 which has the nicest interface (including bootsplash 1232then there is the newer suspend2 with a nicer interface (including
1061support), but requires manual kernel patching. Last not least we have 1233fbsplash support). A <uri link="http://suspend2.net/features.html#compare">
1062Suspend-to-Disk, a fork of swsusp. 1234feature comparison</uri> is available at the <uri link="http://suspend2.net">
1063</p> 1235suspend2 Homepage</uri>. There used to be Suspend-to-Disk (pmdisk), a fork of
1064 1236swsusp, but it has been merged back.
1065<p> 1237</p>
1066If this confused you, have a look at a <uri 1238
1067link="http://softwaresuspend.berlios.de/features.html#compare">feature
1068comparison</uri>. If you still are confused and don't know which one to choose,
1069first give swsusp2 a try, it looks most promising.
1070</p> 1239<p>
1071 1240Suspend2 is not included in the mainline kernel yet, therefore you either have
1241to patch your kernel sources with the patches provided by
1242<uri link="http://suspend2.net">suspend2.net</uri> or use
1243<c>sys-kernel/suspend2-sources</c>.
1072<p> 1244</p>
1073The kernel part for this is as following: 1245
1246<p>
1247The kernel part for both swusp and suspend2 is as follows:
1074</p> 1248</p>
1075 1249
1076<pre caption="Kernel configuration for the various suspend types"> 1250<pre caption="Kernel configuration for the various suspend types">
1077Power Management Options ---&gt; 1251Power Management Options ---&gt;
1078
1079 <comment>(sleep and standby)</comment>
1080 ACPI( Advanced Configuration and Power Interface ) Support --->
1081 [*] ACPI Support
1082 [*] Sleep States
1083
1084 <comment>(hibernate with swsusp)</comment> 1252 <comment>(hibernate with swsusp)</comment>
1085 [*] Software Suspend (EXPERIMENTAL) 1253 [*] Software Suspend
1254 <comment>(replace /dev/SWAP with your swap partition)</comment>
1255 (/dev/SWAP) Default resume partition
1086 1256
1087 <comment>(hibernate with swsusp2)</comment> 1257 <comment>(hibernate with suspend2)</comment>
1088 Software Suspend 2 1258 Software Suspend 2
1089 --- Image Storage (you need at least one writer) 1259 --- Image Storage (you need at least one writer)
1260 [*] File Writer
1090 [*] Swap Writer 1261 [*] Swap Writer
1091 --- Page Transformers 1262 --- General Options
1092 [*] LZF image compression 1263 [*] LZF image compression
1264 <comment>(replace /dev/SWAP with your swap partition)</comment>
1093 (/dev/"your-swap-here") Default resume device name 1265 (swap:/dev/SWAP) Default resume device name
1094 1266 [ ] Allow Keep Image Mode
1095 <comment>(hibernate with Suspend-to-Disk)</comment>
1096 [*] Suspend-to-Disk Suport
1097 (/dev/"your-swap-here") Default resume partition
1098</pre> 1267</pre>
1099 1268
1100<p>
1101Compile your kernel with the appropriate options enabled and issue <c>cat
1102/proc/acpi/sleep</c> for 2.4 series respectively <c>cat /sys/power/state</c>
1103for 2.6 to find out what is supported. The latter gives me <c>standby mem
1104disk</c>. For swsusp, the kernel parameter <c>resume=/dev/"your-swap-here"</c>
1105has to be appended. If booting is not possible due to a broken image, use
1106<c>noresume</c> for swsusp, <c>pmdisk=off</c> for Suspend-to-Disk and
1107<c>noresume2</c> for swsusp2.
1108</p> 1269<p>
1109 1270The configuration for swsusp is rather easy. If you didn't store the location
1271of your swap partition in the kernel config, you can also pass it as a
1272parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1273possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1274<c>hibernate-cleanup</c> init script invalidates swsusp images during the
1275boot process.
1110<p> 1276</p>
1111To put your system in one of the sleep states, use 1277
1278<pre caption="Invalidating swsusp images during the boot process">
1279<i># rc-update add hibernate-cleanup boot</i>
1280</pre>
1281
1112</p> 1282<p>
1113 1283To activate hibernate with swsusp, use the hibernate script and set
1114<pre caption="Activating sleep states"> 1284<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/hibernate.conf</path>.
1115<comment>(kernel 2.4 series)</comment>
1116# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
1117# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
1118
1119<comment>(kernel 2.6 series)</comment>
1120# <i>echo -n standby &gt; /sys/power/state</i> <comment>(standby)</comment>
1121# <i>echo -n mem &gt; /sys/power/state</i> <comment>(sleep)</comment>
1122
1123<comment>(swsusp)</comment>
1124# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>(hibernate)</comment>
1125
1126<comment>(Suspend-to-Disk)</comment>
1127# <i>echo -n disk &gt; /sys/power/state</i> <comment>(hibernate)</comment>
1128
1129<comment>(swsusp2)</comment>
1130# <i>/usr/sbin/hibernate</i> <comment>(hibernate, see below)</comment>
1131</pre> 1285</p>
1132 1286
1133<warn> 1287<warn>
1134Backup your data before doing this. Run <c>sync</c> before executing one of the 1288Backup your data before doing this. Run <c>sync</c> before executing one of the
1135commands to have cached data written to disk. First try it outside of X, then 1289commands to have cached data written to disk. First try it outside of X, then
1136with X running, but not logged in. 1290with X running, but not logged in.
1137</warn> 1291</warn>
1138 1292
1139<p> 1293<p>
1140If you experience kernel panics due to uhci or similar, try to compile USB 1294If you experience kernel panics due to uhci or similar, try to compile USB
1141support as module and unload the modules before sending your laptop to sleep 1295support as module and unload the modules before sending your laptop to sleep
1142mode. 1296mode. There are configuration options for this in <path>hibernate.conf</path>
1143</p>
1144
1145<p> 1297</p>
1146While the above should be sufficient to get swsusp and Suspend-to-Disk running
1147(I didn't say working), swsusp2 needs special care.
1148The first thing to do is patching the kernel with the patches provided at <uri
1149link="http://softwaresuspend.berlios.de/">
1150http://softwaresuspend.berlios.de/</uri>. Additionally you've got to emerge
1151<c>hibernate-script</c>. Once it is installed, configure
1152<path>/etc/hibernate/hibernate.conf</path> and try whether it works:
1153</p>
1154 1298
1155<pre caption="Configure hibernation"> 1299<pre caption="Hibernating with swsusp">
1156<i># emerge hibernate-script</i> 1300<i># nano -w /etc/hibernate.conf</i>
1157<i># $EDITOR /etc/hibernate/hibernate.conf</i> 1301<comment>(Make sure you have a backup of your data)</comment>
1158<comment>(Last chance to backup any data)</comment>
1159<i># hibernate</i> 1302<i># hibernate</i>
1160</pre> 1303</pre>
1304
1305<p>
1306The following section discusses the setup of suspend2 including fbsplash
1307support for a nice graphical progress bar during suspend and resume.
1308</p>
1309
1310<p>
1311The first part of the configuration is similar to the configuration of
1312swsusp. In case you didn't store the location of your swap partition in the
1313kernel config, you have to pass it as a kernel parameter with the
1314<c>resume2=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1315broken image, append the <c>noresume2</c> parameter. Additionally, the
1316<c>hibernate-cleanup</c> init script invalidates suspend2 images during the
1317boot process.
1318</p>
1319
1320<pre caption="Invalidating suspend2 images during the boot process">
1321<i># rc-update add hibernate-cleanup boot</i>
1322</pre>
1323
1324<p>Now edit <path>/etc/hibernate/hibernate.conf</path>, enable the
1325<e>suspend2</e> section and comment everything in the <e>sysfs_power_state</e>
1326and <e>acpi_sleep</e> sections. Do not enable the fbsplash part in global
1327options yet.
1328</p>
1329
1330<pre caption="Hibernating with suspend2">
1331<i># nano -w /etc/hibernate.conf</i>
1332<comment>(Make sure you have a backup of your data)</comment>
1333<i># hibernate</i>
1334</pre>
1335
1336<p>
1337Please configure fbsplash now if you didn't do already. To enable fbsplash
1338support during hibernation, the <c>sys-apps/suspend2-userui</c> package is
1339needed. Additionally, you've got to enable the <e>fbsplash</e> USE flag.
1340</p>
1341
1342<pre caption="Installing suspend2-userui">
1343<i># mkdir -p /etc/portage</i>
1344<i># echo sys-apps/suspend2-userui fbsplash >> /etc/portage/package.use</i>
1345<i># emerge suspend2-userui</i>
1346</pre>
1347
1348<p>
1349The ebuild tells you to make a symlink to the theme you want to use. For
1350example, to use the <c>livecd-2005.1</c> theme, run the following command:
1351</p>
1352
1353<pre caption="Using the livecd-2005.1 theme during hibernation">
1354<i># ln -sfn /etc/splash/livecd-2005.1 /etc/splash/suspend2</i>
1355</pre>
1356
1357<p>
1358If you don't want a black screen in the first part of the resume process, you
1359have to add the <c>suspend2ui_fbsplash</c> tool to your initrd image. Assuming
1360you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1361<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do
1362that.
1363</p>
1364
1365<pre caption="Adding suspend2ui_fbsplash to an initrd image">
1366<i># mount /boot</i>
1367<i># mkdir ~/initrd.d</i>
1368<i># cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1369<i># cd ~/initrd.d</i>
1370<i># gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1371<i># rm fbsplash-emergence-1024x768</i>
1372<i># cp /usr/sbin/suspend2ui_fbsplash sbin/</i>
1373<i># find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-suspend2-emergence-1024x768</i>
1374</pre>
1375
1376<p>
1377Afterwards adjust <path>grub.conf</path> respectively <path>lilo.conf</path>
1378so that your suspend2 kernel uses
1379<path>/boot/fbsplash-suspend2-emergence-1024x768</path> as initrd image. You
1380can now test a dry run to see if everything is setup correctly.
1381</p>
1382
1383<pre caption="Test run for fbsplash hibernation">
1384<i># suspend2ui_fbsplash -t</i>
1385</pre>
1386
1387<p>
1388Afterwards open <path>/etc/hibernate/hibernate.conf</path> again and activate
1389the fbsplash options. Execute <c>hibernate</c> and enjoy.
1390</p>
1161 1391
1162</body> 1392</body>
1163</section> 1393</section>
1164</chapter> 1394</chapter>
1165 1395
1265<e>A:</e> This seems to be a kernel bug. Read on <uri 1495<e>A:</e> This seems to be a kernel bug. Read on <uri
1266link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>. 1496link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1267</p> 1497</p>
1268 1498
1269<p> 1499<p>
1500<e>Q:</e> I activated the DynamicClocks option in <path>xorg.conf</path> and
1501now X.org crashes / the screen stays black / my laptop doesn't shutdown
1502properly.
1503</p>
1504
1505<p>
1506<e>A:</e> This happens on some systems. You have to disable DynamicClocks.
1507</p>
1508
1509<p>
1510<e>Q:</e> I want to use suspend2, but it tells me my swap partition is too
1511small. Resizing is not an option.
1512</p>
1513
1514<p>
1515<e>A:</e> If there is enough free space on your system, you can use the
1516filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it
1517as well. More information can be found in
1518<path>/usr/src/linux/Documentation/power/suspend2.txt</path>.
1519</p>
1520
1521<p>
1270<e>Q:</e> I just bought a brand new battery, but it only lasts for some 1522<e>Q:</e> I just bought a brand new battery, but it only lasts for some
1271minutes! What am I doing wrong? 1523minutes! What am I doing wrong?
1272</p> 1524</p>
1273 1525
1274<p> 1526<p>

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20