/[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.25 - (hide annotations) (download) (as text)
Thu Mar 15 19:24:34 2007 UTC (7 years, 9 months ago) by nightmorph
Branch: MAIN
Changes since 1.24: +5 -5 lines
File MIME type: application/xml
typo fixes, no content change, bug 171068. thanks to kucrut for reporting and rane for ... rane for... rane for something. he was there at the time. :)

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

  ViewVC Help
Powered by ViewVC 1.1.20