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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download) (as text)
Wed Oct 6 07:13:31 2004 UTC (9 years, 10 months ago) by swift
Branch: MAIN
Changes since 1.5: +4 -4 lines
File MIME type: application/xml
Some laptops/kernels use different naming of acpi.ac_adapter.AC.state

1 <?xml version='1.0' encoding="UTF-8"?>
2 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.5 2004/09/22 21:57:14 neysx Exp $ -->
4 <guide link="power-management-guide.xml">
5 <title>Power Management Guide</title>
6
7 <author title="Author">
8 <mail link="fragfred@gmx.de">Dennis Nienh&#252;ser</mail>
9 </author>
10
11 <abstract>
12 Power Management is the key to extend battery run time on mobile systems like
13 laptops. This guide assists you setting it up on your laptop.
14 </abstract>
15
16 <!-- The content of this document is licensed under the CC-BY-SA license -->
17 <!-- See http://creativecommons.org/licenses/by-sa/2.0 -->
18 <license/>
19
20 <version>1.16</version>
21 <date>October 06, 2004</date>
22
23 <chapter>
24 <title>Introduction</title>
25
26 <section>
27 <title>Why Power Management?</title>
28
29 <body>
30
31 <p>
32 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
34 each laptop generation introduces more devices hungry for energy. That's why
35 Power Management is more important than ever. Increasing battery run time
36 doesn't necessarily mean buying another battery. Much can be achieved applying
37 intelligent Power Management policies.
38 </p>
39
40 </body>
41 </section>
42
43 <section>
44 <title>A quick overview</title>
45 <body>
46
47 <p>
48 Please notice that this guide describes Power Management for <e>laptops</e>.
49 While some sections might also suite for <e>servers</e>, others do not and may
50 even cause harm. Please do not apply anything from this guide to a server
51 unless you really know what you are doing.
52 </p>
53
54 <p>
55 As this guide has become rather long, here's a short overview helping you to
56 find your way through it.
57 </p>
58
59 <p>
60 The <e>Prerequisites</e> chapter talks about some requirements that should be
61 met before any of the following device individual sections will work. This
62 includes BIOS settings, kernel configuration and some simplifications in user
63 land. The following three chapters focus on devices that typically consume most
64 energy - processor, display and hard drive. Each can be configured seperately.
65 <e>CPU Power Management</e> shows how to adjust the processor's frequency to
66 save a maximum of energy whithout losing too much performance. A few different
67 tricks prevent your hard drive from working unnecessarily often in <e>Disk Power
68 Management</e> (decreasing noise level as a nice side effect). Some notes on
69 Wireless LAN and USB finish the device section in <e>Power Management for other
70 devices</e> while another chapter is dedicated to the (rather experimental)
71 <e>sleep states</e>. Last not least <e>Troubleshooting</e> lists common
72 pitfalls.
73 </p>
74
75 </body>
76 </section>
77
78 <section>
79 <title>Power Budget for each component</title>
80 <body>
81
82 <figure link="/images/energy-budget.png" short="Which component consumes how
83 much energy?" caption="Power budget for each component"/>
84
85 <p>
86 Nearly every component can operate in different states - off, sleep, idle,
87 active to name a few - consuming a different amount of energy. Major parts are
88 consumed by the LCD display, CPU, chipset and hard drives. Often one is able to
89 activate OS-independent Power Management in the BIOS, but an intelligent setup
90 in the operating system adapting to different situations can achieve much more.
91 </p>
92
93 </body>
94 </section>
95 </chapter>
96
97 <chapter>
98 <title>Prerequisites</title>
99 <section>
100 <title>What has to be done first</title>
101 <body>
102
103 <p>
104 Before going into the details on making individual devices Power Management
105 aware, make sure certain requirements are met. After controlling the BIOS
106 settings, some kernel options want to be enabled - these are in short ACPI,
107 sleep states and CPU frequency scaling. As power saving most of the time comes
108 along with performance loss or increased latency, it should only be enabled
109 when running on batteries. That's where a new runlevel <e>battery</e> comes in
110 handy.
111 </p>
112
113 </body>
114 </section>
115 <section>
116 <title>The BIOS part</title>
117 <body>
118
119 <p>
120 First have a look into your BIOS Power Management settings. The best way is to
121 combine BIOS and operating system policies, but for the moment it's better to
122 disable most of the BIOS part. This makes sure it doesn't interfere with your
123 policies. Don't forget to re-check BIOS settings after you configured
124 everything else.
125 </p>
126
127 </body>
128 </section>
129 <section>
130 <title>Configuring the kernel</title>
131 <body>
132
133 <p>
134 ACPI (Advanced Configuration and Power Interface) support in the kernel is
135 still work in progress. Using a recent kernel will make sure you'll get the
136 most out of it.
137 </p>
138
139 <p>
140 In kernel config, activate at least these options:
141 </p>
142
143 <pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
144 Power Management Options ---&gt;
145 [*] Power Management Support
146 [ ] Software Suspend
147 [ ] Suspend-to-Disk Support
148
149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
150 [*] ACPI Support
151 [ ] Sleep States
152 &lt;M&gt; AC Adapter
153 &lt;M&gt; Battery
154 &lt;M&gt; Button
155 &lt;M&gt; Fan
156 &lt;M&gt; Processor
157 &lt;M&gt; Thermal Zone
158 &lt; &gt; ASUS/Medion Laptop Extras
159 &lt; &gt; Toshiba Laptop Extras
160 [ ] Debug Statements
161
162 CPU Frequency Scaling ---&gt;
163 [*] CPU Frequency scaling
164 Default CPUFreq governor (userspace)
165 &lt;*&gt; 'performance' governor
166 &lt;*&gt; 'powersave' governor
167 &lt;*&gt; CPU frequency table helpers
168 &lt;M&gt; ACPI Processor P-States driver
169 &lt;*&gt; <i>CPUFreq driver for your processor</i>
170 </pre>
171
172 <p>
173 Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk
174 and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop,
175 enable the appropriate section.
176 </p>
177
178 <p>
179 Compile your kernel, make sure the right modules get loaded at startup and boot
180 into your new ACPI-enabled kernel. Next run <c>emerge sys-apps/acpid</c> to get
181 the acpi daemon. This one informs you about events like switching from AC to
182 battery or closing the lid. Make sure the module <e>button</e> is loaded if you
183 didn't compile it into the kernel and start acpid with <c>/etc/init.d/acpid
184 start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
185 soon see how to use it.
186 </p>
187
188 <pre caption="Installing acpid">
189 # <i>emerge sys-apps/acpid</i>
190 # <i>modprobe button</i>
191 # <i>/etc/init.d/acpid start</i>
192 # <i>rc-update add acpid default</i>
193 </pre>
194
195 </body>
196 </section>
197 <section>
198 <title>Creating a "battery" runlevel</title>
199 <body>
200
201 <p>
202 The default policy will be to enable Power Management only when needed -
203 running on batteries. To make the switch between AC and battery convenient,
204 create a runlevel <e>battery</e> that holds all the scripts starting and
205 stopping Power Management.
206 </p>
207
208 <note>
209 You can safely skip this section if you don't like the idea of having another
210 runlevel. However, skipping this step will make the rest a bit trickier to set
211 up. The next sections assume a runlevel <e>battery</e> exists.
212 </note>
213
214 <pre caption="Creating a battery runlevel">
215 # <i>cd /etc/runlevels</i>
216 # <i>cp -a default battery</i>
217 </pre>
218
219 <p>
220 Finished. Your new runlevel <e>battery</e> contains everything like
221 <e>default</e>, but there is no automatic switch between both yet. Time to
222 change it.
223 </p>
224
225 </body>
226 </section>
227 <section>
228 <title>Reacting on ACPI events</title>
229 <body>
230
231 <p>
232 Typical ACPI events are closing the lid, changing the power source or pressing
233 the sleep button. Every acpi event recognized by the kernel is catched by acpid
234 which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification
235 supporting runlevel switching:
236 </p>
237
238 <pre caption="Event driven runlevel switching with acpid">
239 #!/bin/sh
240
241 set $*
242
243 group=${1/\/*/}
244 action=${1/*\//}
245
246 <comment># runlevel to use in AC mode</comment>
247 RLVL_AC="default"
248 <comment># runlevel to use in battery mode</comment>
249 RLVL_BATTERY="battery"
250
251 <comment># file indicating the AC state. Verify the filename before using</comment>
252 AC_STATE="/proc/acpi/ac_adapter/AC/state"
253 <comment># this string means running on AC</comment>
254 AC_ON="on-line"
255 <comment># this string means running on batteries</comment>
256 AC_OFF="off-line"
257
258 function SwitchRunlevel() {
259 if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]]
260 then
261 logger "Switching to ${RLVL_BATTERY} runlevel"
262 /sbin/rc ${RLVL_BATTERY}
263 elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]]
264 then
265 logger "Switching to ${RLVL_AC} runlevel"
266 /sbin/rc ${RLVL_AC}
267 fi
268 }
269
270
271 case "$group" in
272 battery)
273 case "$action" in
274 battery)
275 SwitchRunlevel
276 ;;
277 *)
278 logger "ACPI group battery / action $action is not defined"
279 ;;
280 esac
281 ;;
282
283 ac_adapter)
284 case "$action" in
285 ac_adapter)
286 SwitchRunlevel
287 ;;
288 *)
289 logger "ACPI group ac_adapter / action $action is not defined"
290 ;;
291 esac
292 ;;
293 *)
294 logger "ACPI group $group / action $action is not defined"
295 ;;
296 esac
297 </pre>
298
299 <p>
300 Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
301 mode" or "Switching to battery mode" messages.
302 </p>
303
304 <p>
305 Due to the nature of the event mechanism, your laptop will boot into runlevel
306 <e>default</e> regardless of the AC/battery state. You can add another entry
307 to the boot loader with <c>softlevel=boot</c>, but it's likely to forget
308 choosing it. A better way is faking an ACPI event in the end of the boot
309 process and let the <path>/etc/acpi/default.sh</path> script decide whether a
310 runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your
311 favourite editor and add these lines:
312 </p>
313
314 <pre caption="Runlevel switch at boot time by editing local.start">
315 <comment># Fake acpi event to switch runlevel if running on batteries</comment>
316 /etc/acpi/default.sh "battery/battery"
317 </pre>
318
319 <p>
320 Prepared like this you can activate Power Management policies for individual
321 devices.
322 </p>
323
324 </body>
325 </section>
326 </chapter>
327
328 <chapter>
329 <title>CPU Power Management</title>
330 <section>
331 <title>Setting the frequency manually</title>
332 <body>
333
334 <p>
335 Decreasing CPU speed and voltage has two advantages: On the one hand less
336 energy is consumed, on the other hand there is thermal improvement as your
337 system doesn't get as hot as running on full speed. The main disadvantage is
338 obviously the loss of performance. Decreasing processor speed is a trade off
339 between performance loss and energy saving.
340 </p>
341
342 <note>
343 Not every laptop supports frequency scaling. If unsure, have a look at the list
344 of supported processors in the <e>Troubleshooting</e> section to verify your's
345 is supported.
346 </note>
347
348 <p>
349 It's time to test whether CPU frequency changing works. To get comfortable with
350 the interface to the kernel, first do some manual speed modifications. To set
351 another CPU speed, use:
352 </p>
353
354 <pre caption="Manual CPU speed modifications">
355 <comment>(Get current frequency)</comment>
356 # <i>cat /proc/cpuinfo | grep "cpu MHz"</i>
357
358 <comment>(Lists supported frequencies. This might fail.)</comment>
359 # <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i>
360 # <i>cat scaling_available_frequencies</i>
361
362 <comment>(Change frequency to 1 GHz (1000000 KHz)
363 Replace with a frequency your laptop supports.)</comment>
364 # <i>echo -n userspace > scaling_governor</i>
365 # <i>echo -n 1000000 > scaling_setspeed</i>
366
367 <comment>(Verify frequency was changed)</comment>
368 # <i>cat /proc/cpuinfo | grep "cpu MHz"</i>
369 </pre>
370
371 <p>
372 If you are getting error messages, please refer to the <e>Troubleshooting</e>
373 chapter in the end of this guide.
374 </p>
375
376 <p>
377 You can also write to <path>scaling_max_freq</path> and
378 <path>scaling_min_freq</path> to set boundaries the frequency should stay in
379 between.
380 </p>
381
382 <note>
383 Some kernel seem to be buggy about updating <path>/proc/cpuinfo</path>. If you
384 don't see any change there, this doesn't neccessarily mean the CPU frequency
385 wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your
386 kernel as asked and check the current frequency with <c>x86info -mhz</c>.
387 </note>
388
389 </body>
390 </section>
391 <section>
392 <title>Automated frequency adaption</title>
393 <body>
394
395 <p>
396 The above is quite nice, but not doable in daily life. Better let your system
397 set the appropriate frequency automatically. A couple of user space programs
398 like to do it for you. The following table gives a quick overview to help you
399 decide on one of them.
400 </p>
401
402 <table>
403 <tr>
404 <th>Name</th>
405 <th>Pro</th>
406 <th>Con</th>
407 </tr>
408 <tr>
409 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
410 <ti>Also supports disk standby</ti>
411 <ti></ti>
412 </tr>
413 <tr>
414 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti>
415 <ti>Sophisticated setup possible</ti>
416 <ti>Complicated setup</ti>
417 </tr>
418 <tr>
419 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
420 <ti>
421 Small yet powerful<br />
422 Useful client/server interface
423 </ti>
424 <ti>Kernel 2.6 series only</ti>
425 </tr>
426 <tr>
427 <ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti>
428 <ti>Supports SMP</ti>
429 <ti></ti>
430 </tr>
431 </table>
432
433 <p>
434 While adjusting the frequency to the current load looks simple on the first
435 view, it's not such a trivial task. A bad algorithm can cause switching between
436 two frequencies all the time or wasting energy when setting frequency to an
437 unnecessary high level.
438 </p>
439
440 <p>
441 Which one to choose? If you have no idea about it, first try <c>speedfreq</c>:
442 </p>
443
444 <pre caption="Installing speedfreq">
445 # <i>emerge speedfreq</i>
446 # <i>rc-update add speedfreq battery</i>
447 </pre>
448
449 <p>
450 <c>speedfreq</c> can be configured by editing
451 <path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able
452 to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to
453 <c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon.
454 </p>
455
456 <pre caption="Starting speedfreq">
457 # <i>/etc/init.d/speedfreq start</i>
458 </pre>
459
460 <p>
461 Setting up cpufreq is a little bit more complicated.
462 </p>
463
464 <warn>
465 Do not run more than one of the above programs at the same time. It may cause
466 confusion like switching between two frequencies all the time. If you just
467 installed speedfreq, skip cpufreq now.
468 </warn>
469
470 <pre caption="Installing cpufreqd">
471 # <i>emerge cpufreqd</i>
472 # <i>rc-update add cpufreqd battery</i>
473 </pre>
474
475 <p>
476 <c>cpufreqd</c> comes with a default configuration in
477 <path>/etc/cpufreqd.conf</path>.
478 Change the config file to fit your needs. The following will save more energy
479 than the default one - at the cost of less performance, of course.
480 </p>
481
482 <pre caption="A sample cpufreqd config file">
483 [General]
484 pidfile=/var/run/cpufreqd.pid
485 poll_interval=2
486 pm_type=acpi
487 <comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5))
488 # acpi_workaround=1</comment>
489 verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
490
491 <comment># Full performance</comment>
492 [Profile]
493 name=ac
494 minfreq=600000
495 maxfreq=1400000
496 policy=performance
497
498 <comment># Maximum power saving</comment>
499 [Profile]
500 name=battery
501 minfreq=600000
502 maxfreq=900000
503 policy=powersave
504
505 <comment># Constant frequency</comment>
506 [Profile]
507 name=dvd
508 minfreq=900000
509 maxfreq=1100000
510 policy=powersave
511
512 <comment># Full performance when running on AC</comment>
513 [Rule]
514 name=ac_on
515 ac=on
516 profile=ac
517
518 <comment># Compiling should be fast if battery state is ok</comment>
519 [Rule]
520 name=compiling
521 ac=off
522 battery_interval=30-100
523 programs=emerge,make,gcc,cpp
524 cpu_interval=0-100
525 profile=ac
526
527 <comment># watching DVD's gets sluggish with slow CPU frequency
528 # Can also be used for games etc.</comment>
529 [Rule]
530 name=dvd_watching
531 ac=off
532 battery_interval=15-100
533 programs=xine,mplayer,avidemux,kaffeine,kmplayer
534 cpu_interval=0-100
535 profile=dvd
536
537 <comment># If above doesn't apply, maximise power saving</comment>
538 [Rule]
539 name=battery_on
540 ac=off
541 battery_interval=0-100
542 cpu_interval=0-100
543 profile=battery
544 </pre>
545
546 <p>
547 <c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
548 <c>speedfreq</c>.
549 </p>
550
551 <p>
552 The last thing to check is that your new policies do a good job. An easy way to
553 do so is monitoring the CPU speed while working with your laptop:
554 </p>
555
556 <pre caption="Monitoring CPU speed">
557 # <i>watch -n 1 cat /proc/cpuinfo | grep "cpu MHz"</i>
558 </pre>
559
560 <p>
561 If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU
562 frequency with:
563 </p>
564
565 <pre caption="Alternative CPU speed monitoring">
566 # <i>watch -n 1 x86info -mhz</i>
567 </pre>
568
569 <p>
570 Depending on your setup, CPU speed should increase on heavy load, decrease on
571 no activity or just stay at the same level.
572 </p>
573
574 </body>
575 </section>
576 </chapter>
577
578 <chapter>
579 <title>LCD Power Management</title>
580 <section>
581 <title>Energy consumer no. 1</title>
582 <body>
583
584 <p>
585 As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display
586 consumes the biggest part of energy (might not be the case for non-mobile
587 CPU's). Thus it's quite important not only to shut the display off when not
588 needed, but also to reduce it's backlight if possible. Most laptops offer the
589 possibility to control the backlight dimming.
590 </p>
591
592 <p>
593 First thing to check is the standby/suspend/off timings of the display. As this
594 depends heavily on your windowmanager, I'll let you figure it out yourself.
595 Just two common places: Blanking the terminal can be done with <c>setterm
596 -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and
597 <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>.
598 For Xorg, modify <path>/etc/X11/xorg.conf</path> similar to this:
599 </p>
600
601 <pre caption="LCD suspend settings in Xorg and XFree86">
602 Section "ServerLayout"
603 Identifier [...]
604 [...]
605 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
606 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
607 Option "SuspendTime" "20" <comment># Full suspend after 20 minutes</comment>
608 Option "OffTime" "30" <comment># Turn off after half an hour</comment>
609 [...]
610 EndSection
611
612 [...]
613
614 Section "Monitor"
615 Identifier [...]
616 Option "DPMS" "true"
617 [...]
618 EndSection
619 </pre>
620
621 <p>
622 This is the same for XFree86 and <path>/etc/X11/XF86Config</path>.
623 </p>
624
625 <p>
626 Probably more important is the backlight dimming. If you have access to the
627 dimming settings via a tool, write a small script that dims the backlight in
628 battery mode and place it in your <e>battery</e> runlevel.
629 </p>
630
631 </body>
632 </section>
633 </chapter>
634
635 <chapter>
636 <title>Disk Power Management</title>
637 <section>
638 <title>Sleep when idle</title>
639 <body>
640
641 <p>
642 Let's bring the hard disk to sleep as early as possible whenever it is not
643 needed. I'll show you two possibilities to do it. First <c>cpudyn</c> supports
644 Disk Power Management. Uncomment the lines in the "Disk Options" section in
645 <path>/etc/conf.d/cpudyn</path>. To put your first disk to sleep after 60
646 seconds of no activity, you would modify it like this:
647 </p>
648
649 <pre caption="Using cpudyn for disk standby">
650 <comment>################################################
651 # DISK OPTIONS
652 # (disabled by default)
653 ################################################
654
655 #
656 # Timeout to put the disk in standby mode if there was no
657 # io during that period (in seconds)
658 #
659 </comment>
660 TIMEOUT=60
661 <comment>
662 #
663 # Specified disks to spindown (comma separated devices)
664 #
665 </comment>
666 DISKS=/dev/hda
667 </pre>
668
669 <p>
670 The second possibility is using a small script and hdparm. Create
671 <path>/etc/init.d/pm.hda</path> like this:
672 </p>
673
674 <pre caption="Using hdparm for disk standby">
675 #!/sbin/runscript
676 start() {
677 ebegin "Activating Power Management for Hard Drives"
678 hdparm -q -S12 /dev/hda
679 eend $?
680 }
681
682 stop () {
683 ebegin "Deactivating Power Management for Hard Drives"
684 hdparm -q -S253 /dev/hda
685 eend $?
686 }
687 </pre>
688
689 <p>
690 See <c>man hdparm</c> for the options. If your script is ready, add it to the
691 battery runlevel.
692 </p>
693
694 <pre caption="Automate disk standby settings">
695 # <i>/sbin/depscan.sh</i>
696 # <i>rc-update add pm.hda battery</i>
697 </pre>
698
699 <impo>
700 Be careful with sleep/spin down settings of your hard drive. Setting it to
701 small values might wear out your drive and lose warranty.
702 </impo>
703
704 </body>
705 </section>
706 <section>
707 <title>Increasing idle time - laptop-mode</title>
708 <body>
709
710 <p>
711 Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches)
712 include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
713 written to disk on read calls or after 10 minutes (instead of 30 seconds). This
714 minimizes the time the hard disk needs to be spun up.
715 </p>
716
717 <p>
718 <!-- FIXME: bug #45593 -->
719 To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can
720 take the one included in
721 <path>/usr/src/linux/Documentation/laptop-mode.txt</path>. Onces it's ready,
722 make sure it gets called.
723 </p>
724
725 <pre caption="Automatic start of laptop-mode">
726 # <i>rc-update add laptop-mode battery</i>
727 </pre>
728
729 <warn>
730 Once again: Be careful with sleep/spin down settings of your hard drive.
731 Setting it to small values might wear out your drive and lose warranty. Be sure
732 to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode
733 before your battery runs out of power and data gets written to disk - otherwise
734 you will at least lose the last 10 minutes of your work.
735 </warn>
736
737 </body>
738 </section>
739 <section>
740 <title>Other tricks</title>
741 <body>
742
743 <p>
744 Besides putting your disk to sleep state as early as possible, it is a good
745 idea to minimize disk accesses. Have a look at processes that write to your
746 disk frequently - the syslogd is a good candidate. You probably don't want to
747 shut it down completely, but it's possible to modify the config file so that
748 "unnecessary" things don't get logged and thus don't create disk traffic. Cups
749 writes to disk periodically, so consider shutting it down and only enable it
750 manually when needed.
751 </p>
752
753 <pre caption="Disabling cups in battery mode">
754 # <i>rc-update del cupsd battery</i>
755 </pre>
756
757 <p>
758 Another possibility is to deactivate swap in battery mode. Before writing a
759 swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
760 heavily, otherwise you'll be in big problems.
761 </p>
762
763 <p>
764 If you don't want to use laptop-mode, it's still possible to minimize disk
765 access by mounting certain directories as <e>tmpfs</e> - write accesses are not
766 stored on a disk, but in main memory and get lost with unmounting. Often it's
767 useful to mount <path>/tmp</path> like this - you don't have to pay special
768 attention as it gets cleared on every reboot regardless whether it was mounted
769 on disk or in RAM. Just make sure you have enough RAM and no program (like a
770 download client or compress utility) needs extraordinary much space in
771 <path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
772 add a line to <path>/etc/fstab</path> like this:
773 </p>
774
775 <pre caption="Editing /etc/fstab to make /tmp even more volatile">
776 none /tmp tmpfs size=32m 0 0
777 </pre>
778
779 <warn>
780 Pay attention to the size parameter and modify it for your system. If you're
781 unsure, don't try this at all, it can become a perfomance bottleneck easily. In
782 case you want to mount <path>/var/log</path> like this, make sure to merge the
783 log files to disk before unmounting. They are essential. Don't attempt to mount
784 /var/tmp like this. Portage uses it for compiling...
785 </warn>
786
787 </body>
788 </section>
789 </chapter>
790
791 <chapter>
792 <title>Power Management for other devices</title>
793 <section>
794 <title>Wireless Power Management</title>
795 <body>
796
797 <p>
798 Wireless LAN cards consume quite a few energy. Put them in Power Management
799 mode in analogy to the pm.hda script.
800 </p>
801
802 <pre caption="WLAN Power Management automated">
803 #!/sbin/runscript
804 start() {
805 ebegin "Activating Power Management for Wireless LAN"
806 iwconfig wlan0 power on power max period 3
807 eend $?
808 }
809
810 stop () {
811 ebegin "Deactivating Power Management for Wireless LAN"
812 iwconfig wlan0 power off
813 eend $?
814 }
815 </pre>
816
817 <p>
818 Starting this script will put wlan0 in Power Management mode, going to sleep at
819 the latest three seconds after no traffic.
820 Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel
821 like the disk script above. See <c>man iwconfig</c> for details and more
822 options. If your driver and access point support changing the beacon time, this
823 is a good starting point to save even more energy.
824 </p>
825
826 </body>
827 </section>
828 <section>
829 <title>USB Power Management</title>
830 <body>
831
832 <p>
833 There are two problems with USB devices regarding energy consumption: First,
834 devices like USB mice, digital cameras or USB sticks consume energy while
835 plugged in. You cannot avoid this (nevertheless remove them in case they're not
836 needed). Second, when there are USB devices plugged in, the USB host controller
837 periodically accesses the bus which in turn prevents the CPU from going into
838 C3/4 sleep mode. The OS answer to this problem is the so called "USB selective
839 suspend", which has not yet been implemented in the kernel. USB selective
840 suspend only allows bus accesses in case the device is in use. The cruel
841 workaround until it's implemented is as following: Compile USB support and
842 devices as modules and remove them via a script while they are not in use (e.g.
843 when closing the lid).
844 </p>
845
846 </body>
847 </section>
848 </chapter>
849
850 <chapter>
851 <title>Sleep states: sleep, standby, suspend to disk</title>
852 <section>
853 <title>Overview</title>
854 <body>
855
856 <p>
857 ACPI defines different sleep states. The more important ones are
858 </p>
859
860 <ul>
861 <li>S1 aka Standby</li>
862 <li>S3 aka Suspend to RAM aka Sleep</li>
863 <li>S4 aka Suspend to Disk aka Hibernate</li>
864 </ul>
865
866 <p>
867 They can be called whenever the system is not in use, but a shutdown is not
868 wanted due to the long boot time.
869 </p>
870
871 </body>
872 </section>
873 <section>
874 <title>Sleep, Standby &amp; Hibernate</title>
875 <body>
876
877 <p>
878 The ACPI support for these sleep states is marked as experimental for good
879 reason. APM sleep states seem to be more stable, however you can't use APM and
880 ACPI together.
881 </p>
882
883 <warn>
884 Altough sleep state support is improving much, it's still rather experimental.
885 At last I got swsusp2 and suspend to RAM to work, but be warned: This will very
886 likely not work but damage your data/system.
887 </warn>
888
889 <p>
890 There are currently three implementations for S4. The original one is swsusp,
891 then there is swsusp2 which has the nicest interface (including bootsplash
892 support), but requires manual kernel patching. Last not least we have
893 Suspend-to-Disk, a fork of swsusp.
894 </p>
895
896 <p>
897 If this confused you, have a look at a <uri
898 link="http://softwaresuspend.berlios.de/features.html#compare">feature
899 comparison</uri>. If you still are confused and don't know which one to choose,
900 first give swsusp2 a try, it looks most promising.
901 </p>
902
903 <p>
904 The kernel part for this is as following:
905 </p>
906
907 <pre caption="Kernel configuration for the various suspend types">
908 Power Management Options ---&gt;
909
910 <comment>(sleep and standby)</comment>
911 ACPI( Advanced Configuration and Power Interface ) Support --->
912 [*] ACPI Support
913 [*] Sleep States
914
915 <comment>(hibernate with swsusp)</comment>
916 [*] Software Suspend (EXPERIMENTAL)
917
918 <comment>(hibernate with swsusp2)</comment>
919 Software Suspend 2
920 --- Image Storage (you need at least one writer)
921 [*] Swap Writer
922 --- Page Transformers
923 [*] LZF image compression
924 (/dev/"your-swap-here") Default resume device name
925
926 <comment>(hibernate with Suspend-to-Disk)</comment>
927 [*] Suspend-to-Disk Suport
928 (/dev/"your-swap-here") Default resume partition
929 </pre>
930
931 <p>
932 Compile your kernel with the appropriate options enabled and issue <c>cat
933 /proc/acpi/sleep</c> for 2.4 series respectively <c>cat /sys/power/state</c>
934 for 2.6 to find out what is supported. The latter gives me <c>standby mem
935 disk</c>. For swsusp, the kernel parameter <c>resume=/dev/"your-swap-here"</c>
936 has to be appended. If booting is not possible due to a broken image, use
937 <c>noresume</c> for swsusp, <c>pmdisk=off</c> for Suspend-to-Disk and
938 <c>noresume2</c> for swsusp2.
939 </p>
940
941 <p>
942 To put your system in one of the sleep states, use
943 </p>
944
945 <pre caption="Activating sleep states">
946 <comment>(kernel 2.4 series)</comment>
947 # <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
948 # <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
949
950 <comment>(kernel 2.6 series)</comment>
951 # <i>echo -n standby &gt; /sys/power/state</i> <comment>standby</comment>
952 # <i>echo -n mem &gt; /sys/power/state</i> <comment>sleep</comment>
953
954 <comment>(swsusp)</comment>
955 # <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>hibernate</comment>
956
957 <comment>(Suspend-to-Disk)</comment>
958 # <i>echo -n disk &gt; /sys/power/state</i> <comment>hibernate</comment>
959
960 <comment>(swsusp2)</comment>
961 # <i>echo &gt; /proc/swsusp/activate</i>
962 </pre>
963
964 <warn>
965 Backup your data before doing this. Run <c>sync</c> before executing one of the
966 commands to have cached data written to disk. First try it outside of X, then
967 with X running, but not logged in.
968 </warn>
969
970 <p>
971 If you experience kernel panics due to uhci or similar, try to compile USB
972 support as module and unload the modules before sending your laptop to sleep
973 mode.
974 </p>
975
976 <p>
977 While the above should be sufficient to get swsusp and Suspend-to-Disk running
978 (I didn't say working), swsusp2 needs special care.
979 The first thing to do is to patch the kernel with the patches provided at <uri
980 link="http://softwaresuspend.berlios.de/">
981 http://softwaresuspend.berlios.de/</uri>. Afterwards, install the hibernate
982 script from the same page.
983 </p>
984
985 </body>
986 </section>
987 </chapter>
988
989 <chapter>
990 <title>Troubleshooting</title>
991 <section>
992 <title>If things go wrong...</title>
993 <body>
994
995 <p>
996 <e>Q:</e> I'm trying to change the CPU frequency, but
997 <path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
998 exist.
999 </p>
1000
1001 <p>
1002 <e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1003 the right CPUFreq driver for your processor. Here is a list of processors that
1004 are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100,
1005 ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD
1006 mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm,
1007 Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4,
1008 Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX,
1009 Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several
1010 "PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible
1011 systems (only if "ACPI Processor Performance States" are available to the
1012 ACPI/BIOS interface).
1013 </p>
1014
1015 <p>
1016 <e>Q:</e> My laptop supports frequency scaling, but
1017 <path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1018 </p>
1019
1020 <p>
1021 <e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
1022 Try to update the BIOS, especially if a broken DSDT is reported. You can also
1023 try to fix it yourself (which is beyond the scope of this guide).
1024 </p>
1025
1026 <p>
1027 <e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo
1028 the speed never changes.
1029 </p>
1030
1031 <p>
1032 <e>A:</e> This seems to be a kernel bug. Run <c>emerge x86info</c>, update your
1033 kernel as asked and check the current frequency with <c>x86info -mhz</c>.
1034 </p>
1035
1036 <p>
1037 <e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1038 another OS.
1039 </p>
1040
1041 <p>
1042 <e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1043 minimum frequency. Notice that throttling doesn't save much energy and is
1044 mainly used for thermal management (keeping your laptop cool and quiet). You
1045 can read the current throttling state with <c>cat
1046 /proc/acpi/processor/CPU/throttling</c> and change it with <c>echo -n "0:x" >
1047 /proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in
1048 <path>/proc/acpi/processor/CPU/throttling</path>.
1049 </p>
1050
1051 <p>
1052 <e>Q:</e> Battery life time seems to be worse than before.
1053 </p>
1054
1055 <p>
1056 <e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
1057 settings.
1058 </p>
1059
1060 <p>
1061 <e>Q:</e> My battery is charged, but KDE reports there would be 0% left and
1062 immediately shuts down.
1063 </p>
1064
1065 <p>
1066 <e>A:</e> Check that battery support is compiled into your kernel. If you use
1067 it as a module, make sure the module is loaded.
1068 </p>
1069
1070 <p>
1071 <e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1072 </p>
1073
1074 <p>
1075 <e>A:</e> This seems to be a kernel bug. Read on <uri
1076 link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1077 </p>
1078
1079 <p>
1080 <e>Q:</e> I just bought a brand new battery, but it only lasts for some
1081 minutes! What am I doing wrong?
1082 </p>
1083
1084 <p>
1085 <e>A:</e> First follow your manufacturer's advice on how to charge the battery
1086 correctly.
1087 </p>
1088
1089 <p>
1090 <e>Q:</e> The above didn't help. What should I do then?
1091 </p>
1092
1093 <p>
1094 <e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
1095 </p>
1096
1097 <pre caption="Querying battery state">
1098 $ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
1099 design capacity: 47520 mWh
1100 last full capacity: 41830 mWh
1101 </pre>
1102
1103 <p>
1104 If the "last full capacity" differs significantly from the design capacity,
1105 your battery is probably broken. Try to claim your warranty.
1106 </p>
1107
1108 </body>
1109 </section>
1110 </chapter>
1111 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20