/[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.18 - (hide annotations) (download) (as text)
Thu Feb 16 18:45:09 2006 UTC (8 years, 5 months ago) by nightmorph
Branch: MAIN
Changes since 1.17: +4 -2 lines
File MIME type: application/xml
Fixed <no cpufreqd found> error for bug 123062

1 swift 1.1 <?xml version='1.0' encoding="UTF-8"?>
2     <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 nightmorph 1.17 <!-- $Header: $ -->
4 so 1.15 <guide link="/doc/en/power-management-guide.xml">
5 swift 1.1 <title>Power Management Guide</title>
6    
7 swift 1.4 <author title="Author">
8 nightmorph 1.17 <mail link="earthwings@gentoo.org">Dennis Nienhüser</mail>
9 swift 1.1 </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 so 1.15 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
18 swift 1.1 <license/>
19    
20 nightmorph 1.18 <version>1.27</version>
21     <date>2006-02-16</date>
22 swift 1.1
23     <chapter>
24     <title>Introduction</title>
25     <section>
26     <body>
27    
28     <p>
29 so 1.15 Capacity and lifetime of laptop batteries have improved much in the last years.
30 swift 1.1 Nevertheless modern processors consume much more energy than older ones and
31     each laptop generation introduces more devices hungry for energy. That's why
32     Power Management is more important than ever. Increasing battery run time
33     doesn't necessarily mean buying another battery. Much can be achieved applying
34     intelligent Power Management policies.
35     </p>
36    
37     </body>
38     </section>
39    
40     <section>
41     <title>A quick overview</title>
42     <body>
43    
44     <p>
45     Please notice that this guide describes Power Management for <e>laptops</e>.
46     While some sections might also suite for <e>servers</e>, others do not and may
47     even cause harm. Please do not apply anything from this guide to a server
48     unless you really know what you are doing.
49     </p>
50    
51     <p>
52     As this guide has become rather long, here's a short overview helping you to
53     find your way through it.
54     </p>
55    
56     <p>
57     The <e>Prerequisites</e> chapter talks about some requirements that should be
58     met before any of the following device individual sections will work. This
59     includes BIOS settings, kernel configuration and some simplifications in user
60 so 1.15 land. The following three chapters focus on devices that typically consume
61     most energy - processor, display and hard drive. Each can be configured
62     seperately. <e>CPU Power Management</e> shows how to adjust the processor's
63     frequency to save a maximum of energy whithout losing too much performance. A
64     few different tricks prevent your hard drive from working unnecessarily often
65     in <e>Disk Power Management</e> (decreasing noise level as a nice side
66     effect). Some notes on graphics cards, Wireless LAN and USB finish the device
67     section in <e>Power Management for other devices</e> while another chapter is
68     dedicated to the (rather experimental) <e>sleep states</e>. Last not least
69     <e>Troubleshooting</e> lists common pitfalls.
70 swift 1.1 </p>
71    
72     </body>
73     </section>
74    
75     <section>
76     <title>Power Budget for each component</title>
77     <body>
78    
79 swift 1.2 <figure link="/images/energy-budget.png" short="Which component consumes how
80 swift 1.1 much energy?" caption="Power budget for each component"/>
81    
82     <p>
83     Nearly every component can operate in different states - off, sleep, idle,
84     active to name a few - consuming a different amount of energy. Major parts are
85     consumed by the LCD display, CPU, chipset and hard drives. Often one is able to
86     activate OS-independent Power Management in the BIOS, but an intelligent setup
87     in the operating system adapting to different situations can achieve much more.
88     </p>
89    
90     </body>
91     </section>
92     </chapter>
93    
94     <chapter>
95     <title>Prerequisites</title>
96     <section>
97     <body>
98    
99     <p>
100 nightmorph 1.17 Before discussing the details of making individual devices Power Management
101     aware, make sure certain requirements are met. After controlling BIOS
102 swift 1.1 settings, some kernel options want to be enabled - these are in short ACPI,
103     sleep states and CPU frequency scaling. As power saving most of the time comes
104     along with performance loss or increased latency, it should only be enabled
105     when running on batteries. That's where a new runlevel <e>battery</e> comes in
106     handy.
107     </p>
108    
109     </body>
110     </section>
111     <section>
112     <title>The BIOS part</title>
113     <body>
114    
115     <p>
116     First have a look into your BIOS Power Management settings. The best way is to
117     combine BIOS and operating system policies, but for the moment it's better to
118     disable most of the BIOS part. This makes sure it doesn't interfere with your
119     policies. Don't forget to re-check BIOS settings after you configured
120     everything else.
121     </p>
122    
123     </body>
124     </section>
125     <section>
126 nightmorph 1.17 <title>Setting USE flags</title>
127     <body>
128    
129     <p>
130     Please check that the <c>acpi</c> USE flag is set in
131     <path>/etc/make.conf</path>. Other USE flags that might be interesting for your
132     system are <c>apm</c>, <c>lm_sensors</c>, <c>nforce2</c>, <c>nvidia</c>,
133     <c>pmu</c>. See <path>/usr/portage/profiles/use*.desc</path> for details. If
134     you forgot to set one of these flags, you can recompile affected packages using
135     the <c>--newuse</c> flag in <c>emerge</c>, see <c>man 1 emerge</c>.
136     </p>
137    
138     </body>
139     </section>
140     <section>
141 swift 1.1 <title>Configuring the kernel</title>
142     <body>
143    
144     <p>
145     ACPI (Advanced Configuration and Power Interface) support in the kernel is
146     still work in progress. Using a recent kernel will make sure you'll get the
147     most out of it.
148     </p>
149    
150     <p>
151 so 1.15 There are different kernel sources in Portage. I'd recommend using
152     <c>gentoo-sources</c> or <c>suspend2-sources</c>. The latter contains patches
153     for Software Suspend 2, see the chapter about sleep states for details. When
154     configuring the kernel, activate at least these options:
155 swift 1.1 </p>
156    
157     <pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
158     Power Management Options ---&gt;
159     [*] Power Management Support
160     [ ] Software Suspend
161    
162     ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
163     [*] ACPI Support
164     [ ] Sleep States
165 so 1.15 [ ] /proc/acpi/sleep (deprecated)
166 neysx 1.12 [*] AC Adapter
167     [*] Battery
168 swift 1.1 &lt;M&gt; Button
169 so 1.15 &lt;M&gt; Video
170     [ ] Generic Hotkey
171 swift 1.1 &lt;M&gt; Fan
172     &lt;M&gt; Processor
173     &lt;M&gt; Thermal Zone
174     &lt; &gt; ASUS/Medion Laptop Extras
175 so 1.15 &lt; &gt; IBM ThinkPad Laptop Extras
176 swift 1.1 &lt; &gt; Toshiba Laptop Extras
177 so 1.15 (0) Disable ACPI for systems before Jan 1st this year
178 swift 1.1 [ ] Debug Statements
179 so 1.15 [*] Power Management Timer Support
180     &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
181 swift 1.1
182     CPU Frequency Scaling ---&gt;
183     [*] CPU Frequency scaling
184 so 1.15 [ ] Enable CPUfreq debugging
185     &lt; &gt; CPU frequency translation statistics
186     [ ] CPU frequency translation statistics details
187 swift 1.1 Default CPUFreq governor (userspace)
188     &lt;*&gt; 'performance' governor
189     &lt;*&gt; 'powersave' governor
190 swift 1.8 &lt;*&gt; 'ondemand' cpufreq policy governor
191 so 1.15 &lt;*&gt; 'conservative' cpufreq governor
192 swift 1.1 &lt;*&gt; CPU frequency table helpers
193     &lt;M&gt; ACPI Processor P-States driver
194     &lt;*&gt; <i>CPUFreq driver for your processor</i>
195     </pre>
196    
197     <p>
198 so 1.15 Decide yourself whether you want to enable Software Suspend, and Sleep States
199     (see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
200 neysx 1.12 the appropriate section.
201 swift 1.8 </p>
202    
203     <p>
204     The kernel has to know how to enable CPU frequency scaling on your processor. As
205     each type of CPU has a different interface, you've got to choose the right
206     driver for your processor. Be careful here - enabling <e>Intel Pentium 4 clock
207     modulation</e> on a Pentium M system will lead to strange results for example.
208     Consult the kernel documentation if you're unsure which one to take.
209 swift 1.1 </p>
210    
211     <p>
212     Compile your kernel, make sure the right modules get loaded at startup and boot
213 yoswink 1.10 into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get
214 swift 1.1 the acpi daemon. This one informs you about events like switching from AC to
215 neysx 1.12 battery or closing the lid. Make sure the modules are loaded if you didn't
216     compile them into the kernel and start acpid by executing
217     <c>/etc/init.d/acpid start</c>. Run <c>rc-update add acpid default</c> to load
218     it on startup. You'll soon see how to use it.
219 swift 1.1 </p>
220    
221     <pre caption="Installing acpid">
222 yoswink 1.10 # <i>emerge sys-power/acpid</i>
223 swift 1.1 # <i>/etc/init.d/acpid start</i>
224     # <i>rc-update add acpid default</i>
225     </pre>
226    
227     </body>
228     </section>
229     <section>
230     <title>Creating a "battery" runlevel</title>
231     <body>
232    
233     <p>
234     The default policy will be to enable Power Management only when needed -
235     running on batteries. To make the switch between AC and battery convenient,
236     create a runlevel <e>battery</e> that holds all the scripts starting and
237     stopping Power Management.
238     </p>
239    
240     <note>
241     You can safely skip this section if you don't like the idea of having another
242     runlevel. However, skipping this step will make the rest a bit trickier to set
243     up. The next sections assume a runlevel <e>battery</e> exists.
244     </note>
245    
246     <pre caption="Creating a battery runlevel">
247     # <i>cd /etc/runlevels</i>
248     # <i>cp -a default battery</i>
249     </pre>
250    
251     <p>
252     Finished. Your new runlevel <e>battery</e> contains everything like
253     <e>default</e>, but there is no automatic switch between both yet. Time to
254     change it.
255     </p>
256    
257     </body>
258     </section>
259     <section>
260     <title>Reacting on ACPI events</title>
261     <body>
262    
263     <p>
264     Typical ACPI events are closing the lid, changing the power source or pressing
265 swift 1.8 the sleep button. An important event is changing the power source, which should
266 so 1.15 cause a runlevel switch. A small script will take care of it.
267     </p>
268    
269     <p>
270     First you need a script which changes the runlevel to <c>default</c>
271     respectively <c>battery</c> depending on the power source. The script uses the
272     <c>on_ac_power</c> command from <c>sys-power/powermgmt-base</c> - make sure the
273     package is installed on your system.
274     </p>
275    
276     <pre caption="Installing powermgt-base">
277     <i># emerge powermgmt-base</i>
278     </pre>
279    
280     <p>
281     You are now able to determine the power source by executing
282     <c>on_ac_power &amp;&amp; echo AC available || echo Running on batteries</c> in
283     a shell. The script below is responsible for changing runlevels. Save it as
284     <path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
285 swift 1.8 </p>
286    
287 neysx 1.12 <pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
288 swift 1.8 #!/bin/bash
289    
290 neysx 1.12 <comment># BEGIN configuration</comment>
291 swift 1.8 RUNLEVEL_AC="default"
292     RUNLEVEL_BATTERY="battery"
293 neysx 1.12 <comment># END configuration</comment>
294 swift 1.8
295 swift 1.1
296 neysx 1.12 if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
297     then
298 nightmorph 1.17 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
299     exit 1
300 neysx 1.12 fi
301 swift 1.8
302 neysx 1.12 if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
303     then
304 nightmorph 1.17 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
305     exit 1
306 neysx 1.12 fi
307 swift 1.1
308 neysx 1.12 if on_ac_power
309     then
310     if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
311 nightmorph 1.17 then
312     logger "Switching to ${RUNLEVEL_AC} runlevel"
313     /sbin/rc ${RUNLEVEL_AC}
314     fi
315 neysx 1.12 elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
316     then
317 nightmorph 1.17 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
318     /sbin/rc ${RUNLEVEL_BATTERY}
319 neysx 1.12 fi
320 swift 1.8 </pre>
321    
322 so 1.15 <p>
323     Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to
324     make the script executable. The last thing that needs to be done is calling the
325     script whenever the power source changes. That's done by catching ACPI events
326     with the help of <c>acpid</c>. First you need to know which events are
327     generated when the power source changes. The events are called
328     <e>ac_adapter</e> and <e>battery</e> on most laptops, but it might be different
329     on yours.
330     </p>
331    
332     <pre caption="Determining ACPI events for changing the power source">
333     <i># tail -f /var/log/acpid | grep "received event"</i>
334     </pre>
335    
336     <p>
337     Run the command above and pull the power cable. You should see something
338     like this:
339     </p>
340    
341     <pre caption="Sample output for power source changes">
342     [Tue Sep 20 17:39:06 2005] received event "ac_adapter AC 00000080 00000000"
343     [Tue Sep 20 17:39:06 2005] received event "battery BAT0 00000080 00000001"
344     </pre>
345    
346     <p>
347     The interesting part is the quoted string after <e>received event</e>. It will
348     be matched by the event line in the files you are going to create below. Don't
349     worry if your system generates multiple events or always the same. As long as
350     any event is generated, runlevel changing will work.
351     </p>
352    
353 swift 1.8 <pre caption="/etc/acpi/events/pmg_ac_adapter">
354 neysx 1.12 <comment># replace "ac_adapter" below with the event generated on your laptop</comment>
355 so 1.15 <comment># For example, ac_adapter.* will match ac_adapter AC 00000080 00000000</comment>
356 swift 1.8 event=ac_adapter.*
357 neysx 1.12 action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
358 swift 1.8 </pre>
359    
360     <pre caption="/etc/acpi/events/pmg_battery">
361 neysx 1.12 <comment># replace "battery" below with the event generated on your laptop</comment>
362 so 1.15 <comment># For example, battery.* will match battery BAT0 00000080 00000001</comment>
363 swift 1.8 event=battery.*
364 neysx 1.12 action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
365 swift 1.8 </pre>
366 swift 1.1
367 swift 1.8 <p>
368 so 1.15 Finally acpid has to be restarted to recognize the changes.
369 swift 1.8 </p>
370 swift 1.1
371 swift 1.8 <pre caption="Finishing runlevel switching with acpid">
372     <i># /etc/init.d/acpid restart</i>
373 swift 1.1 </pre>
374    
375     <p>
376     Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
377 swift 1.8 mode" or "Switching to battery mode" messages. See the Troubleshooting
378     section if the script is not able to detect the power source correctly.
379 swift 1.1 </p>
380    
381     <p>
382     Due to the nature of the event mechanism, your laptop will boot into runlevel
383 so 1.15 <e>default</e> regardless of the AC/battery state. This is fine when running
384     from AC, but we'd like to boot into the battery runlevel otherwise. One
385     solution would be to add another entry to the boot loader with the parameter
386     <c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
387     is faking an ACPI event in the end of the boot process and letting
388     <path>pmg_switch_runlevel.sh</path> script decide whether a
389 swift 1.1 runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your
390     favourite editor and add these lines:
391     </p>
392    
393 so 1.15 <pre caption="Runlevel adjustment at boot time by editing local.start">
394 swift 1.1 <comment># Fake acpi event to switch runlevel if running on batteries</comment>
395 neysx 1.12 /etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
396 swift 1.1 </pre>
397    
398     <p>
399     Prepared like this you can activate Power Management policies for individual
400     devices.
401     </p>
402    
403     </body>
404     </section>
405     </chapter>
406    
407     <chapter>
408     <title>CPU Power Management</title>
409     <section>
410 nightmorph 1.17 <body>
411    
412     <p>
413     Mobile processors can operate at different frequencies. Some allow changing
414     voltage as well. Most of the time your CPU doesn't need to run at full speed
415     and scaling it down will save much energy - often without any performance
416     decrease.
417     </p>
418    
419     </body>
420     </section>
421    
422     <section>
423 swift 1.8 <title>Some technical terms</title>
424     <body>
425    
426     <p>
427     CPU frequency scaling brings up some technical terms that might be unknown to
428     you. Here's a quick introduction.
429     </p>
430    
431     <p>
432 so 1.15 First of all, the kernel has to be able to change the processor's frequency.
433     The <e>CPUfreq processor driver</e> knows the commands to do it on your CPU.
434     Thus it's important to choose the right one in your kernel. You should
435     already have done it above. Once the kernel knows how to change frequencies,
436     it has to know which frequency it should set. This is done according to the
437     <e>policy</e> which consists of a <e>CPUfreq policy</e> and a
438     <e>governor</e>. A CPUfreq policy are just two numbers which define a range
439     the frequency has to stay between - minimal and maximal frequency. The
440     governor now decides which of the available frequencies in between minimal
441     and maximal frequency to choose. For example, the <e>powersave governor</e>
442     always chooses the lowest frequency available, the <e>performance
443     governor</e> the highest one. The <e>userspace governor</e> makes no decision
444     but chooses whatever the user (or a program in userspace) wants - which means
445     it reads the frequency from
446 swift 1.8 <path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
447     </p>
448    
449     <p>
450     This doesn't sound like dynamic frequency changes yet and in fact it isn't.
451     Dynamics however can be accomplished with various approaches. For example,
452     the <e>ondemand governor</e> makes its decisions depending on the current CPU
453     load. The same is done by various userland tools like <c>cpudyn</c>,
454 neysx 1.12 <c>cpufreqd</c>, <c>powernowd</c> and many more. ACPI events can be used to
455 swift 1.8 enable or disable dynamic frequency changes depending on power source.
456     </p>
457    
458     </body>
459     </section>
460     <section>
461 swift 1.1 <title>Setting the frequency manually</title>
462     <body>
463    
464     <p>
465     Decreasing CPU speed and voltage has two advantages: On the one hand less
466     energy is consumed, on the other hand there is thermal improvement as your
467     system doesn't get as hot as running on full speed. The main disadvantage is
468     obviously the loss of performance. Decreasing processor speed is a trade off
469     between performance loss and energy saving.
470     </p>
471    
472     <note>
473     Not every laptop supports frequency scaling. If unsure, have a look at the list
474     of supported processors in the <e>Troubleshooting</e> section to verify your's
475     is supported.
476     </note>
477    
478     <p>
479 neysx 1.12 It's time to test whether CPU frequency changing works. Let's install another
480     tool which is very handy for debugging purposes: <c>sys-power/cpufrequtils</c>
481 swift 1.1 </p>
482    
483 neysx 1.12 <pre caption="Checking CPU frequency">
484     # <i>emerge cpufrequtils</i>
485     # <i>cpufreq-info</i>
486 swift 1.1 </pre>
487    
488     <p>
489 neysx 1.12 Here is an example output:
490 swift 1.1 </p>
491    
492 neysx 1.12 <pre caption="Sample output from cpufreq-info">
493 so 1.15 cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
494 neysx 1.12 Report errors and bugs to linux@brodo.de, please.
495     analyzing CPU 0:
496     driver: centrino
497     CPUs which need to switch frequency at the same time: 0
498     hardware limits: 600 MHz - 1.40 GHz
499     available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
500 so 1.15 available cpufreq governors: conservative, ondemand, powersave, userspace, performance
501 neysx 1.12 current policy: frequency should be within 924 MHz and 1.40 GHz.
502     The governor "performance" may decide which speed to use
503     within this range.
504 so 1.15 current CPU frequency is 1.40 GHz.
505 neysx 1.12 </pre>
506    
507 swift 1.1 <p>
508 neysx 1.12 Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
509     Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
510     governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
511     expected, you might find help in the Troubleshooting section in the end of this
512     guide.
513 swift 1.1 </p>
514    
515     </body>
516     </section>
517     <section>
518     <title>Automated frequency adaption</title>
519     <body>
520    
521     <p>
522     The above is quite nice, but not doable in daily life. Better let your system
523 so 1.15 set the appropriate frequency automatically. There are many different
524     approaches to do this. The following table gives a quick overview to help you
525     decide on one of them. It's roughly seperated in three categories
526     <e>kernel</e> for approaches that only need kernel support, <e>daemon</e> for
527     programs that run in the background and <e>graphical</e> for programs that
528     provide a GUI for easy configuration and changes.
529 swift 1.1 </p>
530    
531     <table>
532     <tr>
533     <th>Name</th>
534 swift 1.8 <th>Category</th>
535     <th>Switch decision</th>
536     <th>Kernel governors</th>
537     <th>Further governors</th>
538     <th>Comments</th>
539     </tr>
540     <tr>
541     <ti>'ondemand' governor</ti>
542     <ti>Kernel</ti>
543     <ti>CPU load</ti>
544     <ti>N.A.</ti>
545     <ti>N.A.</ti>
546     <ti>
547 so 1.15 Chooses maximal frequency on CPU load and slowly steps down when the CPU is
548     idle. Further tuning through files in
549 swift 1.8 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
550     userland tools (programs, scripts) if governor switching or similar is
551     desired.
552     </ti>
553 swift 1.1 </tr>
554     <tr>
555 so 1.15 <ti>'conservative' governor</ti>
556     <ti>Kernel</ti>
557     <ti>CPU load</ti>
558     <ti>N.A.</ti>
559     <ti>N.A.</ti>
560     <ti>
561 neysx 1.16 Unlike the ondemand governor, conversative doesn't jump to maximum
562     frequency when CPU load is high, but increases the frequency step by step.
563     Further tuning through files in
564     <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
565     userland tools (programs, scripts) if governor switching or similar is
566     desired.
567 so 1.15 </ti>
568     </tr>
569     <tr>
570 swift 1.1 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
571 swift 1.8 <ti>Daemon</ti>
572     <ti>CPU load</ti>
573 neysx 1.12 <ti>Performance, powersave</ti>
574 swift 1.8 <ti>Dynamic</ti>
575     <ti>
576     Also supports disk standby - notice however that <e>laptop mode</e> in most
577     cases will do a better job.
578     </ti>
579 swift 1.1 </tr>
580     <tr>
581 swift 1.8 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
582     <ti>Daemon</ti>
583 nightmorph 1.17 <ti>Battery state, CPU load, temperature, running programs and more</ti>
584 swift 1.8 <ti>All available</ti>
585     <ti>None</ti>
586     <ti>
587 nightmorph 1.17 Sophisticated (but somewhat complicated) setup. Extendible through plugins
588     like sensor monitoring (lm_sensors) or coordinating some NVidia based
589     graphics card memory and core. Cpufreqd is SMP aware and can optionally be
590     controlled manually at runtime.
591 swift 1.8 </ti>
592     </tr>
593     <tr>
594     <ti>
595     <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
596     </ti>
597     <ti>Daemon</ti>
598     <ti>CPU load</ti>
599     <ti>None</ti>
600     <ti>Passive, sine, aggressive</ti>
601     <ti>
602     Supports SMP.
603     </ti>
604 swift 1.1 </tr>
605     <tr>
606 so 1.15 <ti>
607     <uri link="http://fatcat.ftj.agh.edu.pl/~nelchael/index.php?cat=projs&amp;subcat=ncpufreqd&amp;language=en">ncpufreqd</uri>
608     </ti>
609     <ti>Daemon</ti>
610     <ti>Temperature</ti>
611     <ti>None</ti>
612     <ti>Powersave, performance</ti>
613     <ti>
614     Toggles the used governor between performance and powersave depending on
615     system temperature. Very useful on laptops with notorious heat problems.
616     </ti>
617     </tr>
618     <tr>
619 swift 1.1 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
620 swift 1.8 <ti>Daemon</ti>
621     <ti>CPU load</ti>
622     <ti>None</ti>
623     <ti>Dynamic, powersave, performance, fixed speed</ti>
624     <ti>
625 so 1.15 Easy to configure with a nice client/server interface. Requires a 2.6
626     kernel. Unmaintained, broken and thus removed from Portage. Please switch
627     to cpufreqd if you're still using it.
628 swift 1.8 </ti>
629     </tr>
630     <tr>
631     <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
632     <ti>Graphical</ti>
633     <ti>None</ti>
634     <ti>None</ti>
635     <ti>None</ti>
636 swift 1.1 <ti>
637 swift 1.8 Gnome application, a graphical tool to set CPU frequency manually. It does
638 neysx 1.12 not offer any automation.
639 swift 1.1 </ti>
640     </tr>
641     <tr>
642 swift 1.8 <ti>klaptopdaemon</ti>
643     <ti>Graphical</ti>
644     <ti>Battery state</ti>
645     <ti>All available</ti>
646     <ti>None</ti>
647     <ti>
648     KDE only, 'ondemand' governor required for dynamic frequency scaling.
649     </ti>
650 swift 1.1 </tr>
651     </table>
652    
653     <p>
654 so 1.15 While adjusting the frequency to the current load looks simple at a first
655     glance, it's not such a trivial task. A bad algorithm can cause switching
656     between two frequencies all the time or wasting energy when setting frequency
657     to an unnecessary high level.
658 swift 1.1 </p>
659    
660     <p>
661 neysx 1.12 Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
662 swift 1.1 </p>
663    
664     <pre caption="Installing cpufreqd">
665     # <i>emerge cpufreqd</i>
666     </pre>
667    
668     <p>
669 neysx 1.12 <c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
670     The default one that ships with cpufreqd may look a bit confusing. I recommend
671     replacing it with the one from Gentoo developer Henrik Brix Andersen (see
672 nightmorph 1.17 below). Please notice that you need cpufreqd-2.0.0 or later. Earlier versions
673     have a different syntax for the config file.
674 swift 1.1 </p>
675    
676 nightmorph 1.17 <pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)">
677 swift 1.1 [General]
678     pidfile=/var/run/cpufreqd.pid
679 nightmorph 1.17 poll_interval=3
680     enable_plugins=acpi_ac, acpi_battery
681 nightmorph 1.18 enable_remote=1
682     remote_group=wheel
683 neysx 1.12 verbosity=5
684 nightmorph 1.17 [/General]
685 swift 1.1
686     [Profile]
687 neysx 1.12 name=ondemand
688     minfreq=0%
689     maxfreq=100%
690     policy=ondemand
691 nightmorph 1.17 [/Profile]
692 swift 1.1
693     [Profile]
694 so 1.15 name=conservative
695     minfreq=0%
696     maxfreq=100%
697     policy=conservative
698 nightmorph 1.17 [/Profile]
699 so 1.15
700     [Profile]
701 neysx 1.12 name=powersave
702     minfreq=0%
703     maxfreq=100%
704 swift 1.1 policy=powersave
705 nightmorph 1.17 [/Profile]
706 swift 1.1
707     [Profile]
708 neysx 1.12 name=performance
709     minfreq=0%
710     maxfreq=100%
711     policy=performance
712 nightmorph 1.17 [/Profile]
713 swift 1.1
714     [Rule]
715 neysx 1.12 name=battery
716     ac=off
717 so 1.15 profile=conservative
718 nightmorph 1.17 [/Rule]
719 swift 1.1
720     [Rule]
721 neysx 1.12 name=battery_low
722 swift 1.1 ac=off
723 neysx 1.12 battery_interval=0-10
724     profile=powersave
725 nightmorph 1.17 [/Rule]
726 swift 1.1
727     [Rule]
728 neysx 1.12 name=ac
729     ac=on
730 so 1.15 profile=ondemand
731 nightmorph 1.17 [/Rule]
732 neysx 1.12 </pre>
733    
734     <p>
735 so 1.15 Now you can start the cpufreqd daemon. Add it to the <e>default</e> and
736     <e>battery</e> runlevel as well.
737 swift 1.1 </p>
738    
739 neysx 1.12 <pre caption="Starting cpufreqd">
740     # <i>rc-update add cpufreqd default battery</i>
741     # <i>rc</i>
742     </pre>
743    
744 nightmorph 1.17 <p>
745     Sometimes it can be desirable to select another policy than the daemon chooses,
746     for example when battery power is low, but you know that AC will be available
747     soon. In that case you can turn on cpufreqd's manual mode with
748     <c>cpufreqd-set manual</c> and select one of your configured policies (as
749     listed by <c>cpufreqd-get</c>). You can leave manual mode by executing
750     <c>cpufreqd-set dynamic</c>.
751     </p>
752    
753 neysx 1.12 <warn>
754     Do not run more than one of the above programs at the same time. It may cause
755     confusion like switching between two frequencies all the time.
756     </warn>
757    
758 swift 1.8 </body>
759     </section>
760    
761     <section>
762     <title>Verifying the result</title>
763    
764     <body>
765    
766 swift 1.1 <p>
767     The last thing to check is that your new policies do a good job. An easy way to
768 swift 1.8 do so is monitoring CPU speed while working with your laptop:
769 swift 1.1 </p>
770    
771     <pre caption="Monitoring CPU speed">
772 yoswink 1.13 # <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
773 swift 1.1 </pre>
774    
775     <p>
776 neysx 1.12 If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting),
777     monitor the CPU frequency with:
778 swift 1.1 </p>
779    
780     <pre caption="Alternative CPU speed monitoring">
781 neysx 1.12 # <i>watch x86info -mhz</i>
782 swift 1.1 </pre>
783    
784     <p>
785     Depending on your setup, CPU speed should increase on heavy load, decrease on
786 neysx 1.12 no activity or just stay at the same level. When using cpufreqd and verbosity
787     set to 5 or higher in <path>cpufreqd.conf</path> you'll get additional
788     information about what's happening reported to syslog.
789 swift 1.1 </p>
790    
791     </body>
792     </section>
793     </chapter>
794    
795     <chapter>
796     <title>LCD Power Management</title>
797     <section>
798     <body>
799    
800     <p>
801 swift 1.3 As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display
802 swift 1.1 consumes the biggest part of energy (might not be the case for non-mobile
803     CPU's). Thus it's quite important not only to shut the display off when not
804     needed, but also to reduce it's backlight if possible. Most laptops offer the
805     possibility to control the backlight dimming.
806     </p>
807    
808 nightmorph 1.17 </body>
809     </section>
810     <section>
811     <title>Standby settings</title>
812     <body>
813    
814 swift 1.1 <p>
815 nightmorph 1.17 The first thing to check is the standby/suspend/off timings of the display. As
816     this depends heavily on your windowmanager, I'll let you figure it out
817     yourself. Just two common places: Blanking the terminal can be done with
818     <c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
819     and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
820     <path>/etc/X11/xorg.conf</path> similar to this:
821 swift 1.1 </p>
822    
823 so 1.15 <pre caption="LCD suspend settings in X.org and XFree86">
824 swift 1.1 Section "ServerLayout"
825     Identifier [...]
826     [...]
827     Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
828     Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
829     Option "SuspendTime" "20" <comment># Full suspend after 20 minutes</comment>
830     Option "OffTime" "30" <comment># Turn off after half an hour</comment>
831     [...]
832     EndSection
833    
834     [...]
835    
836     Section "Monitor"
837     Identifier [...]
838     Option "DPMS" "true"
839     [...]
840     EndSection
841     </pre>
842    
843     <p>
844     This is the same for XFree86 and <path>/etc/X11/XF86Config</path>.
845     </p>
846    
847 nightmorph 1.17 </body>
848     </section>
849     <section>
850     <title>Backlight dimming</title>
851     <body>
852    
853 swift 1.1 <p>
854     Probably more important is the backlight dimming. If you have access to the
855     dimming settings via a tool, write a small script that dims the backlight in
856 neysx 1.12 battery mode and place it in your <e>battery</e> runlevel. The following script
857 nightmorph 1.17 should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
858     appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops, install
859     <c>app-laptop/acpitool</c> and skip configuration of ibm_acpi as described below.
860 neysx 1.12 </p>
861    
862     <warn>
863     Support for setting brightness is marked experimental in ibm-acpi. It accesses
864     hardware directly and may cause severe harm to your system. Please read the
865     <uri link="http://ibm-acpi.sourceforge.net/">ibm-acpi website</uri>
866     </warn>
867    
868     <p>
869     To be able to set the brightness level, the ibm_acpi module has to be loaded
870     with the experimental parameter.
871     </p>
872    
873     <pre caption="automatically loading the ibm_acpi module">
874     <comment>(Please read the warnings above before doing this!)</comment>
875     <i># echo "options ibm_acpi experimental=1" >> /etc/modules.d/ibm_acpi</i>
876     <i># /sbin/modules-update</i>
877     <i># echo ibm_acpi >> /etc/modules.autoload.d/kernel-2.6</i>
878     <i># modprobe ibm_acpi</i>
879     </pre>
880    
881     <p>
882     This should work without error messages and a file
883     <path>/proc/acpi/ibm/brightness</path> should be created after loading the
884     module. An init script will take care of choosing the brightness according
885     to the power source.
886     </p>
887    
888     <pre caption="/etc/conf.d/lcd-brightness">
889     <comment># See /proc/acpi/ibm/brightness for available values</comment>
890 nightmorph 1.17 <comment># Please read /usr/src/linux/Documentation/ibm-acpi.txt</comment>
891 neysx 1.12
892     <comment># brigthness level in ac mode. Default is 7.</comment>
893     BRIGHTNESS_AC=7
894    
895     <comment># brightness level in battery mode. Default is 4.</comment>
896     BRIGHTNESS_BATTERY=4
897     </pre>
898    
899     <pre caption="/etc/init.d/lcd-brightness">
900     #!/sbin/runscript
901    
902     set_brightness() {
903     if on_ac_power
904     then
905     LEVEL=${BRIGHTNESS_AC:-7}
906     else
907     LEVEL=${BRIGHTNESS_BATTERY:-4}
908     fi
909    
910     if [ -f /proc/acpi/ibm/brightness ]
911     then
912     ebegin "Setting LCD brightness"
913     echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
914     eend $?
915 nightmorph 1.17 elif [[ -e /usr/bin/acpitool &amp;&amp; -n $(acpitool -T | grep "LCD brightness") ]]
916     then
917     ebegin "Setting LCD brightness"
918     acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
919     eend $?
920 neysx 1.12 else
921     ewarn "Setting LCD brightness is not supported."
922 nightmorph 1.17 ewarn "For IBM Thinkpads, check that ibm_acpi is loaded into the kernel"
923     ewarn "For Toshiba laptops, you've got to install app-laptop/acpitool"
924 neysx 1.12 fi
925     }
926    
927     start() {
928     set_brightness
929     }
930    
931     stop () {
932     set_brightness
933     }
934     </pre>
935    
936     <p>
937     When done, make sure brightness is adjusted automatically by adding it to the
938     battery runlevel.
939 swift 1.1 </p>
940    
941 neysx 1.12 <pre caption="Enabling automatic brightness adjustment">
942     <i># chmod +x /etc/init.d/lcd-brightness</i>
943     <i># rc-update add lcd-brightness battery</i>
944     <i># rc</i>
945     </pre>
946    
947 swift 1.1 </body>
948     </section>
949     </chapter>
950    
951     <chapter>
952     <title>Disk Power Management</title>
953     <section>
954 nightmorph 1.17 <body>
955     <p>
956     Hard disks consume less energy in sleep mode. Therefore it makes sense to
957     activate power saving features whenever the hard disk is not used for a certain
958     amount of time. I'll show you two alternative possibilities to do it. First,
959     laptop-mode will save most energy due to several measures which prevent or at
960     least delay write accesses. The drawback is that due to the delayed write
961     accesses a power outage or kernel crash will be more dangerous for data loss.
962     If you don't like this, you have to make sure that there are no processes which
963     write to your hard disk frequently. Afterwards you can enable power saving
964     features of your hard disk with hdparm as the second alternative.
965     </p>
966    
967     </body>
968     </section>
969    
970     <section>
971     <title>Increasing idle time - laptop-mode</title>
972 swift 1.1 <body>
973    
974     <p>
975 nightmorph 1.17 Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches)
976     include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
977     written to disk on read calls or after 10 minutes (instead of 30 seconds). This
978     minimizes the time the hard disk needs to be spun up.
979 swift 1.1 </p>
980    
981 nightmorph 1.17 <pre caption="Automated start of laptop-mode">
982     # <i>emerge laptop-mode-tools</i>
983     </pre>
984 swift 1.1
985 nightmorph 1.17 <p>
986     <c>laptop-mode-tools</c> has its configuration file in
987     <path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
988     it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
989     automatically.
990     </p>
991    
992     <p>
993     Recent versions (1.11 and later) of laptop-mode-tools include a new tool
994     <c>lm-profiler</c>. It will monitor your system's disk usage and running
995     network services and suggests to disable unneeded ones. You can either disable
996     them through laptop-mode-tools builtin runlevel support (which will be reverted
997     by Gentoo's <c>/sbin/rc</c>) or use your <e>default</e>/<e>battery</e>
998     runlevels (recommended).
999     </p>
1000    
1001     <pre caption="Sample output from running lm-profiler">
1002     # lm-profiler
1003     Profiling session started.
1004     Time remaining: 600 seconds
1005     [4296896.602000] amarokapp
1006     Time remaining: 599 seconds
1007     [4296897.714000] sort
1008     [4296897.970000] mv
1009     Time remaining: 598 seconds
1010     Time remaining: 597 seconds
1011     [4296900.482000] reiserfs/0
1012     </pre>
1013    
1014     <p>
1015     After profiling your system for ten minutes, lm-profiler will present a list of
1016     services which might have caused disk accesses during that time.
1017     </p>
1018    
1019     <pre caption="lm-profiler suggests to disable some services">
1020     Program: "atd"
1021     Reason: standard recommendation (program may not be running)
1022     Init script: /etc/init.d/atd (GUESSED)
1023    
1024     Do you want to disable this service in battery mode? [y/N]: n
1025 swift 1.1 </pre>
1026    
1027     <p>
1028 nightmorph 1.17 To disable atd as suggested in the example above, you would run <c>rc-update
1029     del atd battery</c>. Be careful not to disable services that are needed for
1030     your system to run properly - lm-profiler is likely to generate some false
1031     positives. Do not disable a service if you are unsure whether it's needed.
1032     </p>
1033    
1034     </body>
1035     </section>
1036    
1037     <section>
1038     <title>Limiting write accesses</title>
1039     <body>
1040    
1041     <p>
1042     If you don't want to use laptop-mode, you must take special care to disable
1043     services that write to your disk frequently - <c>syslogd</c> is a good
1044     candidate, for example. You probably don't want to shut it down completely, but
1045     it's possible to modify the config file so that "unnecessary" things don't get
1046     logged and thus don't create disk traffic. Cups writes to disk periodically, so
1047     consider shutting it down and only enable it manually when needed.
1048     </p>
1049    
1050     <pre caption="Disabling cups in battery mode">
1051     # <i>rc-update del cupsd battery</i>
1052     </pre>
1053    
1054     <p>
1055     You can also use <c>lm-profiler</c> from laptop-mode-tools (see above) to find
1056     services to disable. Once you eliminated all of them, go on with configuring
1057     hdparm.
1058     </p>
1059    
1060     </body>
1061     </section>
1062    
1063     <section>
1064     <title>hdparm</title>
1065     <body>
1066    
1067     <p>
1068     The second possibility is using a small script and hdparm. Skip this if you
1069     are using laptop-mode. Otherwise, create <path>/etc/init.d/pmg_hda</path>:
1070 swift 1.1 </p>
1071    
1072     <pre caption="Using hdparm for disk standby">
1073     #!/sbin/runscript
1074 neysx 1.12
1075     depend() {
1076 nightmorph 1.17 after hdparm
1077 neysx 1.12 }
1078    
1079 swift 1.1 start() {
1080 nightmorph 1.17 ebegin "Activating Power Management for Hard Drives"
1081     hdparm -q -S12 /dev/hda
1082     eend $?
1083 swift 1.1 }
1084    
1085     stop () {
1086 nightmorph 1.17 ebegin "Deactivating Power Management for Hard Drives"
1087     hdparm -q -S253 /dev/hda
1088     eend $?
1089 swift 1.1 }
1090     </pre>
1091    
1092     <p>
1093     See <c>man hdparm</c> for the options. If your script is ready, add it to the
1094     battery runlevel.
1095     </p>
1096    
1097     <pre caption="Automate disk standby settings">
1098 nightmorph 1.17 # <i>chmod +x /etc/init.d/pmg_hda</i>
1099 swift 1.1 # <i>/sbin/depscan.sh</i>
1100 nightmorph 1.17 # <i>rc-update add pmg_hda battery</i>
1101 swift 1.1 </pre>
1102    
1103     <impo>
1104     Be careful with sleep/spin down settings of your hard drive. Setting it to
1105     small values might wear out your drive and lose warranty.
1106     </impo>
1107    
1108     </body>
1109     </section>
1110    
1111     <section>
1112     <title>Other tricks</title>
1113     <body>
1114    
1115     <p>
1116     Another possibility is to deactivate swap in battery mode. Before writing a
1117     swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
1118     heavily, otherwise you'll be in big problems.
1119     </p>
1120    
1121     <p>
1122     If you don't want to use laptop-mode, it's still possible to minimize disk
1123     access by mounting certain directories as <e>tmpfs</e> - write accesses are not
1124     stored on a disk, but in main memory and get lost with unmounting. Often it's
1125     useful to mount <path>/tmp</path> like this - you don't have to pay special
1126     attention as it gets cleared on every reboot regardless whether it was mounted
1127     on disk or in RAM. Just make sure you have enough RAM and no program (like a
1128     download client or compress utility) needs extraordinary much space in
1129     <path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
1130     add a line to <path>/etc/fstab</path> like this:
1131     </p>
1132    
1133     <pre caption="Editing /etc/fstab to make /tmp even more volatile">
1134     none /tmp tmpfs size=32m 0 0
1135     </pre>
1136    
1137     <warn>
1138     Pay attention to the size parameter and modify it for your system. If you're
1139     unsure, don't try this at all, it can become a perfomance bottleneck easily. In
1140     case you want to mount <path>/var/log</path> like this, make sure to merge the
1141     log files to disk before unmounting. They are essential. Don't attempt to mount
1142     /var/tmp like this. Portage uses it for compiling...
1143     </warn>
1144    
1145     </body>
1146     </section>
1147     </chapter>
1148    
1149     <chapter>
1150     <title>Power Management for other devices</title>
1151     <section>
1152 so 1.15 <title>Graphics cards</title>
1153     <body>
1154    
1155     <p>
1156     In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1157     scaling for the the graphics processing unit GPU), you can activate this
1158     feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable)
1159     the <c>DynamicClocks</c> option in the Device section. Please notice that
1160     this feature will lead to crashes on some systems.
1161     </p>
1162    
1163     <pre caption="Enabling ATI PowerPlay support in X.org">
1164     Section "Device"
1165     [...]
1166     Option "DynamicClocks" "on"
1167     EndSection
1168     </pre>
1169    
1170     </body>
1171     </section>
1172     <section>
1173 swift 1.1 <title>Wireless Power Management</title>
1174     <body>
1175    
1176     <p>
1177 nightmorph 1.17 Wireless LAN cards consume quite a bit of energy. Put them in Power Management
1178     mode in analogy to the pmg_hda script.
1179 swift 1.1 </p>
1180    
1181 nightmorph 1.17 <note>
1182     This script assumes your wireless interface is called <c>wlan0</c>; replace
1183     this with the actual name of your interface.
1184     </note>
1185    
1186 swift 1.1 <pre caption="WLAN Power Management automated">
1187     #!/sbin/runscript
1188     start() {
1189     ebegin "Activating Power Management for Wireless LAN"
1190 nightmorph 1.17 iwconfig wlan0 power on
1191 swift 1.1 eend $?
1192     }
1193    
1194     stop () {
1195     ebegin "Deactivating Power Management for Wireless LAN"
1196     iwconfig wlan0 power off
1197     eend $?
1198     }
1199     </pre>
1200    
1201     <p>
1202 nightmorph 1.17 Starting this script will activate power saving features for wlan0. Save it as
1203     <path>/etc/init.d/pmg_wlan0</path> and add it to the battery runlevel like the
1204     disk script above. See <c>man iwconfig</c> for details and more options like
1205     the period between wakeups or timeout settings. If your driver and access point
1206     support changing the beacon time, this is a good starting point to save even
1207     more energy.
1208 swift 1.1 </p>
1209    
1210 swift 1.8 <pre caption="Power Management for WLAN">
1211 nightmorph 1.17 # <i>chmod +x /etc/init.d/pmg_wlan0</i>
1212 swift 1.8 # <i>/sbin/depscan.sh</i>
1213 nightmorph 1.17 # <i>rc-update add pmg_wlan0 battery</i>
1214 swift 1.8 </pre>
1215    
1216 swift 1.1 </body>
1217     </section>
1218     <section>
1219     <title>USB Power Management</title>
1220     <body>
1221    
1222     <p>
1223     There are two problems with USB devices regarding energy consumption: First,
1224     devices like USB mice, digital cameras or USB sticks consume energy while
1225     plugged in. You cannot avoid this (nevertheless remove them in case they're not
1226     needed). Second, when there are USB devices plugged in, the USB host controller
1227     periodically accesses the bus which in turn prevents the CPU from going into
1228 so 1.15 sleep mode. The kernel offers an experimental option to enable suspension of
1229     USB devices through driver calls or one of the <path>power/state</path> files
1230     in <path>/sys</path>.
1231 swift 1.1 </p>
1232    
1233 so 1.15 <pre caption="Enabling USB suspend support in the kernel">
1234     Device Drivers
1235     USB support
1236     [*] Support for Host-side USB
1237     [*] USB suspend/resume (EXPERIMENTAL)
1238     </pre>
1239    
1240 swift 1.1 </body>
1241     </section>
1242     </chapter>
1243    
1244     <chapter>
1245     <title>Sleep states: sleep, standby, suspend to disk</title>
1246     <section>
1247     <body>
1248    
1249     <p>
1250     ACPI defines different sleep states. The more important ones are
1251     </p>
1252    
1253     <ul>
1254     <li>S1 aka Standby</li>
1255     <li>S3 aka Suspend to RAM aka Sleep</li>
1256     <li>S4 aka Suspend to Disk aka Hibernate</li>
1257     </ul>
1258    
1259     <p>
1260     They can be called whenever the system is not in use, but a shutdown is not
1261     wanted due to the long boot time.
1262     </p>
1263    
1264     </body>
1265     </section>
1266     <section>
1267 so 1.15 <title>Sleep (S3)</title>
1268 swift 1.1 <body>
1269    
1270     <p>
1271 so 1.15 The ACPI support for these sleep states is marked experimental for good reason.
1272     APM sleep states seem to be more stable, however you can't use APM and ACPI
1273     together.
1274     </p>
1275    
1276     <pre caption="Kernel configuration for the various suspend types">
1277     Power Management Options ---&gt;
1278     [*] Power Management support
1279     ACPI (Advanced Configuration and Power Interface) Support ---&gt;
1280     [*] ACPI Support
1281     [*] Sleep States
1282     </pre>
1283    
1284     <p>
1285 nightmorph 1.17 Once your kernel is properly configured, you can use the
1286 so 1.15 <c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1287     first.
1288     </p>
1289    
1290     <pre caption="Installing the hibernate-script">
1291     <i># emerge hibernate-script</i>
1292     </pre>
1293    
1294     <p>
1295     Some configuration has to be done in <path>/etc/hibernate</path> The default
1296     package introduces two configuration files <path>hibernate.conf</path> and
1297     <path>ram.conf</path>.
1298     </p>
1299    
1300     <p>
1301     To configure sleep, edit <path>ram.conf</path> in <path>/etc/hibernate</path>.
1302     <c>UseSysfsPowerState mem</c> is already setup correctly, but you have to go
1303     through the rest of the configuration file and set it up for your system. The
1304     comments and option names will guide you. If you use nfs or samba shares over
1305     the network, make sure to shutdown the appropriate init scripts to avoid
1306     timeouts.
1307     </p>
1308    
1309     <p>
1310     Ready? Now is the last chance to backup any data you want to keep after
1311     executing the next command. Notice that you probably have to hit a special key
1312     like <e>Fn</e> to resume from sleep.
1313     </p>
1314    
1315     <pre caption="Calling sleep">
1316     <i># hibernate-ram</i>
1317     </pre>
1318    
1319     <p>
1320     If you're still reading, it seems to work. You can also setup standby (S1) in
1321     a similar way by copying <path>ram.conf</path> to <path>standby.conf</path>
1322     and creating a symlink <path>/usr/sbin/hibernate-standby</path> pointing to
1323     <path>/usr/sbin/hibernate</path>. S3 and S4 are the more interesting sleep
1324     states due to greater energy savings however.
1325     </p>
1326    
1327     </body>
1328     </section>
1329     <section>
1330     <title>Hibernate (S4)</title>
1331     <body>
1332    
1333     <p>
1334     This section introduces hibernation, where a snapshot of the running system is
1335     written to disk before powering off. On resume, the snapshot is loaded and you
1336     can go on working at exactly the point you called hibernate before.
1337 swift 1.1 </p>
1338    
1339     <warn>
1340 so 1.15 Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
1341     a snapshot with a different kernel image than the one it was created with.
1342     Shutdown any NFS or samba server/client before hibernating.
1343 swift 1.1 </warn>
1344    
1345     <p>
1346 so 1.15 There are two different implementations for S4. The original one is swsusp,
1347     then there is the newer suspend2 with a nicer interface (including
1348     fbsplash support). A <uri link="http://suspend2.net/features.html#compare">
1349     feature comparison</uri> is available at the <uri link="http://suspend2.net">
1350     suspend2 Homepage</uri>. There used to be Suspend-to-Disk (pmdisk), a fork of
1351     swsusp, but it has been merged back.
1352 swift 1.1 </p>
1353    
1354     <p>
1355 so 1.15 Suspend2 is not included in the mainline kernel yet, therefore you either have
1356     to patch your kernel sources with the patches provided by
1357     <uri link="http://suspend2.net">suspend2.net</uri> or use
1358     <c>sys-kernel/suspend2-sources</c>.
1359 swift 1.1 </p>
1360    
1361     <p>
1362 so 1.15 The kernel part for both swusp and suspend2 is as follows:
1363 swift 1.1 </p>
1364    
1365     <pre caption="Kernel configuration for the various suspend types">
1366     Power Management Options ---&gt;
1367     <comment>(hibernate with swsusp)</comment>
1368 so 1.15 [*] Software Suspend
1369     <comment>(replace /dev/SWAP with your swap partition)</comment>
1370     (/dev/SWAP) Default resume partition
1371 swift 1.1
1372 so 1.15 <comment>(hibernate with suspend2)</comment>
1373 swift 1.1 Software Suspend 2
1374     --- Image Storage (you need at least one writer)
1375 so 1.15 [*] File Writer
1376 swift 1.1 [*] Swap Writer
1377 so 1.15 --- General Options
1378 swift 1.1 [*] LZF image compression
1379 so 1.15 <comment>(replace /dev/SWAP with your swap partition)</comment>
1380     (swap:/dev/SWAP) Default resume device name
1381     [ ] Allow Keep Image Mode
1382 swift 1.1 </pre>
1383    
1384     <p>
1385 so 1.15 The configuration for swsusp is rather easy. If you didn't store the location
1386     of your swap partition in the kernel config, you can also pass it as a
1387     parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1388     possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1389     <c>hibernate-cleanup</c> init script invalidates swsusp images during the
1390     boot process.
1391 swift 1.1 </p>
1392    
1393 so 1.15 <pre caption="Invalidating swsusp images during the boot process">
1394     <i># rc-update add hibernate-cleanup boot</i>
1395     </pre>
1396    
1397 swift 1.1 <p>
1398 so 1.15 To activate hibernate with swsusp, use the hibernate script and set
1399     <c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/hibernate.conf</path>.
1400 swift 1.1 </p>
1401    
1402     <warn>
1403     Backup your data before doing this. Run <c>sync</c> before executing one of the
1404     commands to have cached data written to disk. First try it outside of X, then
1405     with X running, but not logged in.
1406     </warn>
1407    
1408     <p>
1409     If you experience kernel panics due to uhci or similar, try to compile USB
1410     support as module and unload the modules before sending your laptop to sleep
1411 so 1.15 mode. There are configuration options for this in <path>hibernate.conf</path>
1412 swift 1.1 </p>
1413    
1414 so 1.15 <pre caption="Hibernating with swsusp">
1415     <i># nano -w /etc/hibernate.conf</i>
1416     <comment>(Make sure you have a backup of your data)</comment>
1417     <i># hibernate</i>
1418     </pre>
1419    
1420 swift 1.1 <p>
1421 so 1.15 The following section discusses the setup of suspend2 including fbsplash
1422     support for a nice graphical progress bar during suspend and resume.
1423     </p>
1424    
1425     <p>
1426     The first part of the configuration is similar to the configuration of
1427     swsusp. In case you didn't store the location of your swap partition in the
1428     kernel config, you have to pass it as a kernel parameter with the
1429     <c>resume2=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1430     broken image, append the <c>noresume2</c> parameter. Additionally, the
1431     <c>hibernate-cleanup</c> init script invalidates suspend2 images during the
1432     boot process.
1433     </p>
1434    
1435     <pre caption="Invalidating suspend2 images during the boot process">
1436     <i># rc-update add hibernate-cleanup boot</i>
1437     </pre>
1438    
1439     <p>Now edit <path>/etc/hibernate/hibernate.conf</path>, enable the
1440     <e>suspend2</e> section and comment everything in the <e>sysfs_power_state</e>
1441     and <e>acpi_sleep</e> sections. Do not enable the fbsplash part in global
1442     options yet.
1443 swift 1.1 </p>
1444    
1445 so 1.15 <pre caption="Hibernating with suspend2">
1446     <i># nano -w /etc/hibernate.conf</i>
1447     <comment>(Make sure you have a backup of your data)</comment>
1448 swift 1.8 <i># hibernate</i>
1449     </pre>
1450    
1451 so 1.15 <p>
1452     Please configure fbsplash now if you didn't do already. To enable fbsplash
1453     support during hibernation, the <c>sys-apps/suspend2-userui</c> package is
1454     needed. Additionally, you've got to enable the <e>fbsplash</e> USE flag.
1455     </p>
1456    
1457     <pre caption="Installing suspend2-userui">
1458     <i># mkdir -p /etc/portage</i>
1459     <i># echo sys-apps/suspend2-userui fbsplash >> /etc/portage/package.use</i>
1460     <i># emerge suspend2-userui</i>
1461     </pre>
1462    
1463     <p>
1464     The ebuild tells you to make a symlink to the theme you want to use. For
1465     example, to use the <c>livecd-2005.1</c> theme, run the following command:
1466     </p>
1467    
1468     <pre caption="Using the livecd-2005.1 theme during hibernation">
1469     <i># ln -sfn /etc/splash/livecd-2005.1 /etc/splash/suspend2</i>
1470     </pre>
1471    
1472     <p>
1473     If you don't want a black screen in the first part of the resume process, you
1474     have to add the <c>suspend2ui_fbsplash</c> tool to your initrd image. Assuming
1475     you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1476     <path>/boot/fbsplash-emergence-1024x768</path>, here's how to do
1477     that.
1478     </p>
1479    
1480     <pre caption="Adding suspend2ui_fbsplash to an initrd image">
1481     <i># mount /boot</i>
1482     <i># mkdir ~/initrd.d</i>
1483     <i># cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1484     <i># cd ~/initrd.d</i>
1485     <i># gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1486     <i># rm fbsplash-emergence-1024x768</i>
1487     <i># cp /usr/sbin/suspend2ui_fbsplash sbin/</i>
1488     <i># find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-suspend2-emergence-1024x768</i>
1489     </pre>
1490    
1491     <p>
1492     Afterwards adjust <path>grub.conf</path> respectively <path>lilo.conf</path>
1493     so that your suspend2 kernel uses
1494     <path>/boot/fbsplash-suspend2-emergence-1024x768</path> as initrd image. You
1495     can now test a dry run to see if everything is setup correctly.
1496     </p>
1497    
1498     <pre caption="Test run for fbsplash hibernation">
1499     <i># suspend2ui_fbsplash -t</i>
1500     </pre>
1501    
1502     <p>
1503     Afterwards open <path>/etc/hibernate/hibernate.conf</path> again and activate
1504     the fbsplash options. Execute <c>hibernate</c> and enjoy.
1505     </p>
1506    
1507 swift 1.1 </body>
1508     </section>
1509     </chapter>
1510    
1511     <chapter>
1512     <title>Troubleshooting</title>
1513     <section>
1514     <body>
1515    
1516     <p>
1517     <e>Q:</e> I'm trying to change the CPU frequency, but
1518     <path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
1519     exist.
1520     </p>
1521    
1522     <p>
1523     <e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1524     the right CPUFreq driver for your processor. Here is a list of processors that
1525     are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100,
1526     ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD
1527     mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm,
1528     Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4,
1529     Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX,
1530     Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several
1531     "PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible
1532     systems (only if "ACPI Processor Performance States" are available to the
1533     ACPI/BIOS interface).
1534     </p>
1535    
1536     <p>
1537     <e>Q:</e> My laptop supports frequency scaling, but
1538     <path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1539     </p>
1540    
1541     <p>
1542     <e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
1543     Try to update the BIOS, especially if a broken DSDT is reported. You can also
1544     try to fix it yourself (which is beyond the scope of this guide).
1545     </p>
1546    
1547     <p>
1548     <e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo
1549     the speed never changes.
1550     </p>
1551    
1552     <p>
1553 swift 1.8 <e>A:</e> Probably you have activated symmetric multiprocessing support
1554     (CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1555     kernels had a bug causing this. In that case, run <c>emerge x86info</c>,
1556     update your kernel as asked and check the current frequency with
1557     <c>x86info -mhz</c>.
1558 swift 1.1 </p>
1559    
1560     <p>
1561     <e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1562     another OS.
1563     </p>
1564    
1565     <p>
1566     <e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1567     minimum frequency. Notice that throttling doesn't save much energy and is
1568     mainly used for thermal management (keeping your laptop cool and quiet). You
1569     can read the current throttling state with <c>cat
1570     /proc/acpi/processor/CPU/throttling</c> and change it with <c>echo -n "0:x" >
1571     /proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in
1572     <path>/proc/acpi/processor/CPU/throttling</path>.
1573     </p>
1574    
1575     <p>
1576 swift 1.8 <e>Q:</e> When configuring the kernel, powersave, performance and userspace
1577     governors show up, but that ondemand thing is missing. Where do I get it?
1578     </p>
1579    
1580     <p>
1581     <e>A:</e> The ondemand governor is only included in recent kernel sources. Try
1582     updating them.
1583     </p>
1584    
1585     <p>
1586 swift 1.1 <e>Q:</e> Battery life time seems to be worse than before.
1587     </p>
1588    
1589     <p>
1590     <e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
1591     settings.
1592     </p>
1593    
1594     <p>
1595     <e>Q:</e> My battery is charged, but KDE reports there would be 0% left and
1596     immediately shuts down.
1597     </p>
1598    
1599     <p>
1600     <e>A:</e> Check that battery support is compiled into your kernel. If you use
1601     it as a module, make sure the module is loaded.
1602     </p>
1603    
1604     <p>
1605 nightmorph 1.17 <e>Q:</e> My system logger reports things like "logger: ACPI group battery / action
1606     battery is not defined".
1607     </p>
1608    
1609     <p>
1610     <e>A:</e> This message is generated by the /etc/acpi/default.sh script that is
1611     shipped with acpid. You can safely ignore it. If you like to get rid of it, you
1612     can comment the appropriate line in /etc/acpi/default.sh as shown below:
1613     </p>
1614    
1615     <pre caption="Disabling warnings about unknown acpi events">
1616     *) # logger "ACPI action $action is not defined"
1617     </pre>
1618    
1619     <p>
1620 swift 1.1 <e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1621     </p>
1622    
1623     <p>
1624     <e>A:</e> This seems to be a kernel bug. Read on <uri
1625     link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1626     </p>
1627    
1628     <p>
1629 so 1.15 <e>Q:</e> I activated the DynamicClocks option in <path>xorg.conf</path> and
1630     now X.org crashes / the screen stays black / my laptop doesn't shutdown
1631     properly.
1632     </p>
1633    
1634     <p>
1635     <e>A:</e> This happens on some systems. You have to disable DynamicClocks.
1636     </p>
1637    
1638     <p>
1639     <e>Q:</e> I want to use suspend2, but it tells me my swap partition is too
1640     small. Resizing is not an option.
1641     </p>
1642    
1643     <p>
1644     <e>A:</e> If there is enough free space on your system, you can use the
1645     filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it
1646     as well. More information can be found in
1647     <path>/usr/src/linux/Documentation/power/suspend2.txt</path>.
1648     </p>
1649    
1650     <p>
1651 swift 1.1 <e>Q:</e> I just bought a brand new battery, but it only lasts for some
1652     minutes! What am I doing wrong?
1653     </p>
1654    
1655     <p>
1656     <e>A:</e> First follow your manufacturer's advice on how to charge the battery
1657     correctly.
1658     </p>
1659    
1660     <p>
1661     <e>Q:</e> The above didn't help. What should I do then?
1662     </p>
1663    
1664     <p>
1665     <e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
1666     </p>
1667    
1668     <pre caption="Querying battery state">
1669     $ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
1670     design capacity: 47520 mWh
1671     last full capacity: 41830 mWh
1672     </pre>
1673    
1674     <p>
1675     If the "last full capacity" differs significantly from the design capacity,
1676     your battery is probably broken. Try to claim your warranty.
1677     </p>
1678    
1679 swift 1.8 <p>
1680     <e>Q:</e> My problem is not listed above. Where should I go next?
1681     </p>
1682    
1683     <p>
1684 nightmorph 1.17 <e>A:</e> Don't fear to contact me, <mail link="earthwings@gentoo.org">Dennis
1685     Nienhüser</mail>, directly. The
1686     <uri link="http://forums.gentoo.org">Gentoo Forums</uri> are a good place to
1687     get help as well. If you prefer IRC, try the <e>#gentoo-laptop</e> channel at
1688     <e>irc.freenode.net</e>.
1689 swift 1.8 </p>
1690    
1691 swift 1.1 </body>
1692     </section>
1693     </chapter>
1694     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20