Gentoo Archives: gentoo-doc-cvs

From: "Sven Vermeulen (swift)" <swift@g.o>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] gentoo commit in xml/htdocs/doc/en: power-management-guide.xml
Date: Fri, 23 Sep 2011 18:42:05
Message-Id: 20110923184152.D6AC120035@flycatcher.gentoo.org
1 swift 11/09/23 18:41:52
2
3 Modified: power-management-guide.xml
4 Log:
5 Fix bugs #379523 and #381059, rewrite power management guide reflecting recent developments in userspace support
6
7 Revision Changes Path
8 1.49 xml/htdocs/doc/en/power-management-guide.xml
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?rev=1.49&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?rev=1.49&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/power-management-guide.xml?r1=1.48&r2=1.49
13
14 Index: power-management-guide.xml
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v
17 retrieving revision 1.48
18 retrieving revision 1.49
19 diff -u -r1.48 -r1.49
20 --- power-management-guide.xml 17 Aug 2011 07:19:29 -0000 1.48
21 +++ power-management-guide.xml 23 Sep 2011 18:41:52 -0000 1.49
22 @@ -1,109 +1,74 @@
23 <?xml version='1.0' encoding="UTF-8"?>
24 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
25 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.48 2011/08/17 07:19:29 swift Exp $ -->
26 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.49 2011/09/23 18:41:52 swift Exp $ -->
27
28 <guide>
29 <title>Power Management Guide</title>
30
31 <author title="Author">
32 - <mail link="earthwings@g.o">Dennis Nienhüser</mail>
33 -</author>
34 -<author title="Editor">
35 - <mail link="chriswhite@g.o">Chris White</mail>
36 -</author>
37 -<author title="Editor">
38 - <mail link="nightmorph"/>
39 + <mail link="swift"/>
40 </author>
41
42 <abstract>
43 -Power Management is the key to extend battery run time on mobile systems like
44 -laptops. This guide assists you setting it up on your laptop.
45 +In recent years, power management has become one of the differentiating
46 +features in the quest for finding the perfect laptop. Yet, the operating system
47 +must support the various power saving functionalities too. In this guide, we
48 +cover how to setup your Gentoo installation so it manages power-hungry resources
49 +in a flexible yet automated manner.
50 </abstract>
51
52 <!-- The content of this document is licensed under the CC-BY-SA license -->
53 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
54 <license/>
55
56 -<version>4</version>
57 -<date>2011-08-17</date>
58 +<version>5</version>
59 +<date>2011-09-22</date>
60
61 <chapter>
62 <title>Introduction</title>
63 <section>
64 +<title>About this document...</title>
65 <body>
66
67 -<!--
68 - Remove this note after 6 months - ETA 01/02/2012
69 - By then, we can assume that OpenRC migrations are not that frequent
70 - anymore and this note can be dropped.
71 - ~ Sven Vermeulen
72 --->
73 -<impo>
74 -Since the introduction of OpenRC, the <c>pmg_switch_runlevel.sh</c> script
75 -needs to be updated. If you have issues after the OpenRC upgrade, please update
76 -this script according to this guide.
77 -</impo>
78 +<p>
79 +This document describes the setup of power management features on your laptop.
80 +Although some of the information in this guide can be applied to power
81 +management for servers, it is not the intention of this document to go that
82 +route. Please be careful when applying this on a non-laptop system.
83 +</p>
84
85 <p>
86 -Capacity and lifetime of laptop batteries have improved much in the last years.
87 -Nevertheless modern processors consume much more energy than older ones and
88 -each laptop generation introduces more devices hungry for energy. That's why
89 -Power Management is more important than ever. Increasing battery run time
90 -doesn't necessarily mean buying another battery. Much can be achieved applying
91 -intelligent Power Management policies.
92 +Within this document, we will focus primarily on the laptop mode tools since it
93 +offers a complete set of functionalities. However, we will also refer to other
94 +tools that might offer a more detailed approach on individual settings. In such
95 +cases, you will need to disable the feature from the laptop mode tools so that
96 +both tools do not fight over the same resource control.
97 </p>
98
99 </body>
100 </section>
101 <section>
102 -<title>A Quick Overview</title>
103 +<title>About laptop_mode</title>
104 <body>
105
106 <p>
107 -Please notice that this guide describes Power Management for <e>laptops</e>.
108 -While some sections might also suite for <e>servers</e>, others do not and may
109 -even cause harm. Please do not apply anything from this guide to a server
110 -unless you really know what you are doing.
111 -</p>
112 -
113 -<p>
114 -As this guide has become rather long, here's a short overview helping you to
115 -find your way through it.
116 -</p>
117 -
118 -<p>
119 -The <uri link="#doc_chap2">Prerequisites</uri> chapter talks about some
120 -requirements that should be met before any of the following device individual
121 -sections will work. This includes BIOS settings, kernel configuration and some
122 -simplifications in user land. The following three chapters focus on devices
123 -that typically consume most energy - processor, display and hard drive. Each
124 -can be configured separately. <uri link="#doc_chap3">CPU Power Management</uri>
125 -shows how to adjust the processor's frequency to save a maximum of energy
126 -without losing too much performance. A few different tricks prevent your hard
127 -drive from working unnecessarily often in <uri link="#doc_chap5">Disk Power
128 -Management</uri> (decreasing noise level as a nice side effect). Some notes on
129 -graphics cards, Wireless LAN and USB finish the device section in <uri
130 -link="#doc_chap6">Power Management For Other Devices</uri> while another
131 -chapter is dedicated to the (rather experimental) <uri link="#doc_chap7">sleep
132 -states</uri>. Last not least <uri link="#doc_chap8">Troubleshooting</uri> lists
133 -common pitfalls.
134 +The <c>laptop_mode</c> setting is an in-kernel configuration setting that
135 +optimizes I/O, allowing disks to spin down properly (and not be woken up
136 +immediately afterwards for queued operations).
137 </p>
138
139 </body>
140 </section>
141 <section>
142 -<title>Power Budget For Each Component</title>
143 +<title>About laptop-mode-tools</title>
144 <body>
145
146 -<figure link="/images/energy-budget.png" short="Which component consumes how
147 -much energy?" caption="Power budget for each component"/>
148 -
149 <p>
150 -Nearly every component can operate in different states - off, sleep, idle,
151 -active to name a few - consuming a different amount of energy. Major parts are
152 -consumed by the LCD display, CPU, chipset and hard drives. Often one is able to
153 -activate OS-independent Power Management in the BIOS, but an intelligent setup
154 -in the operating system adapting to different situations can achieve much more.
155 +The <e>Laptop Mode Tools</e> is a software package
156 +(<c>app-laptop/laptop-mode-tools</c>) which allows the user to optimize power
157 +saving functions. It allows managing the <c>laptop_mode</c> setting in the Linux
158 +kernel, but has additional features allowing you to tweak other power-related
159 +settings on the system.
160 </p>
161
162 </body>
163 @@ -111,881 +76,566 @@
164 </chapter>
165
166 <chapter>
167 -<title>Prerequisites</title>
168 +<title>Linux Kernel Configuration</title>
169 <section>
170 +<title>Minimum kernel setup</title>
171 <body>
172
173 <p>
174 -Before discussing the details of making individual devices Power Management
175 -aware, make sure certain requirements are met. After controlling BIOS settings,
176 -some kernel options want to be enabled - these are in short ACPI, sleep states
177 -and CPU frequency scaling. As power saving most of the time comes along with
178 -performance loss or increased latency, it should only be enabled when running
179 -on batteries. That's where a new runlevel <e>battery</e> comes in handy.
180 +There are different kernel sources in Portage. We recommend using
181 +<c>gentoo-sources</c>, but if you want advanced hibernation support you might
182 +need <c>tuxonice-sources</c>. To enable proper power management features in the
183 +Linux kernel, enable at least the following settings:
184 </p>
185
186 -</body>
187 -</section>
188 -<section>
189 -<title>The BIOS Part</title>
190 -<body>
191 +<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
192 +<![CDATA[
193 +General setup --->
194 + [*] Configure standard kernel features (expert users) --->
195 +
196 +Power management and ACPI options --->
197 + [*] ACPI (Advanced Configuration and Power Interface) Support --->
198 + <*> AC Adapter
199 + <*> Battery
200 + -*- Button
201 + -*- Video
202 + <*> Fan
203 + <*> Processor
204 + <*> Thermal Zone
205 + [*] Power Management Timer Support
206 +
207 + [*] CPU Frequency scaling --->
208 + [*] CPU Frequency scaling
209 + <*> 'performance' governor
210 + <*> 'powersave' governor
211 + <*> 'userspace' governor
212 + <*> 'ondemand' governor
213 + <*> 'conservative' governor
214 + <*> ACPI Processor P-States driver
215 +]]>
216 +</pre>
217
218 <p>
219 -First have a look into your BIOS Power Management settings. The best way is to
220 -combine BIOS and operating system policies, but for the moment it's better to
221 -disable most of the BIOS part. This makes sure it doesn't interfere with your
222 -policies. Don't forget to re-check BIOS settings after you configured
223 -everything else.
224 +Don't forget to enable the CPU frequency scaling driver for your CPU, located
225 +right after the <e>ACPI Processor P-States driver</e> mentioned above.
226 </p>
227
228 -</body>
229 -</section>
230 -<section>
231 -<title>Setting USE Flags</title>
232 -<body>
233 -
234 <p>
235 -Please check that the <c>acpi</c> USE flag is set in
236 -<path>/etc/make.conf</path>. Other USE flags that might be interesting for your
237 -system are <c>apm</c>, <c>lm_sensors</c>, <c>nforce2</c>, <c>nvidia</c>,
238 -<c>pmu</c>. See <path>/usr/portage/profiles/use*.desc</path> for details. If
239 -you forgot to set one of these flags, you can recompile affected packages using
240 -the <c>--newuse</c> flag in <c>emerge</c>, see <c>man emerge</c>.
241 +Build and install the new kernel (if necessary) and reboot.
242 </p>
243
244 </body>
245 </section>
246 -<section>
247 -<title>Configuring The Kernel</title>
248 +<!--
249 +<section id="kernelconfig">
250 +<title>Additional kernel configuration entries</title>
251 <body>
252
253 <p>
254 -ACPI (Advanced Configuration and Power Interface) support in the kernel is
255 -still work in progress. Using a recent kernel will make sure you'll get the
256 -most out of it.
257 +Further down this guide, additional kernel settings might be suggested. To
258 +lessen the effort to maintain the guide, and to make sure settings are correctly
259 +identified, we will use the kernel configuration short-hand notations. These
260 +notations are simple strings, like <c>CONFIG_USB_SUSPEND</c>. But how to read
261 +this?
262 </p>
263
264 <p>
265 -There are different kernel sources in Portage. I'd recommend using
266 -<c>gentoo-sources</c> or <c>tuxonice-sources</c>. The latter contains patches
267 -for TuxOnIce, see the chapter about <uri link="#doc_chap7">sleep states</uri>
268 -for more details. When configuring the kernel, activate at least these options:
269 +Well, then you configure your kernel (through <c>make menuconfig</c>), you can
270 +search through the configuration settings for a particular entry. Press <c>/</c>
271 +while configuring the Linux kernel and type the setting
272 +(<c>CONFIG_USB_SUSPEND</c>). The software will tell you what the setting is,
273 +what it is for, when you can select it (i.e. on which settings it depends before
274 +you can see it) but most importantly, where you can find it.
275 </p>
276
277 -<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
278 -Power management and ACPI options ---&gt;
279 -[*] Power Management support
280 - [ ] Software Suspend
281 -
282 - ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
283 - [ ] Deprecated /proc/acpi/ files
284 - [*] AC Adapter
285 - [*] Battery
286 - &lt;M&gt; Button
287 - &lt;M&gt; Video
288 - [ ] Generic Hotkey
289 - &lt;M&gt; Fan
290 - &lt;M&gt; Processor
291 - &lt;M&gt; Thermal Zone
292 - &lt; &gt; ASUS/Medion Laptop Extras
293 - &lt; &gt; IBM ThinkPad Laptop Extras
294 - &lt; &gt; Toshiba Laptop Extras
295 - (0) Disable ACPI for systems before Jan 1st this year
296 - [ ] Debug Statements
297 - [*] Power Management Timer Support
298 - &lt; &gt; ACPI0004,PNP0A05 and PNP0A06 Container Driver (EXPERIMENTAL)
299 -
300 - CPU Frequency Scaling ---&gt;
301 - [*] CPU Frequency scaling
302 - [ ] Enable CPUfreq debugging
303 - &lt; &gt; CPU frequency translation statistics
304 - [ ] CPU frequency translation statistics details
305 - Default CPUFreq governor (userspace)
306 - &lt;*&gt; 'performance' governor
307 - &lt;*&gt; 'powersave' governor
308 - &lt;*&gt; 'ondemand' cpufreq policy governor
309 - &lt;*&gt; 'conservative' cpufreq governor
310 - &lt;*&gt; CPU frequency table helpers
311 - &lt;M&gt; ACPI Processor P-States driver
312 - &lt;*&gt; <i>CPUFreq driver for your processor</i>
313 +<pre caption="Result of a search operation during menuconfig">
314 +<![CDATA[Symbol: USB_SUSPEND [=n]
315 +Type : boolean
316 +Prompt: USB runtime power management (autosuspend) and wakeup
317 + Defined at drivers/usb/core/Kconfig:93
318 + Depends on: USB_SUPPORT [=y] && USB [=y] && PM_RUNTIME [=n]
319 + Location:
320 + -> Device Drivers
321 + -> USB support (USB_SUPPORT [=y])
322 + -> Support for Host-side USB (USB [=y]) ]]>
323 </pre>
324
325 -<p>
326 -Decide yourself whether you want to enable Software Suspend, and Sleep States
327 -(see below). If you own an ASUS, Medion, IBM Thinkpad or Toshiba laptop, enable
328 -the appropriate section.
329 -</p>
330 +</body>
331 +</section>
332 +-->
333 +</chapter>
334 +
335 +<chapter>
336 +<title>Using Laptop Mode Tools</title>
337 +<section>
338 +<title>Installation</title>
339 +<body>
340
341 <p>
342 -The kernel has to know how to enable CPU frequency scaling on your processor.
343 -As each type of CPU has a different interface, you've got to choose the right
344 -driver for your processor. Be careful here - enabling <c>Intel Pentium 4 clock
345 -modulation</c> on a Pentium M system will lead to strange results for example.
346 -Consult the kernel documentation if you're unsure which one to take.
347 +It comes to no surprise that installation of the <e>Laptop Mode Tools</e>
348 +software is easily done through <c>emerge laptop-mode-tools</c>. However, this
349 +package takes on additional, optional settings through USE flag configuration.
350 +So let's first take a look at the supported USE flags and what they mean to the
351 +package.
352 </p>
353
354 +<table>
355 +<tr>
356 + <th>USE flag</th>
357 + <th>Description</th>
358 + <th>Suggested when...</th>
359 +</tr>
360 +<tr>
361 + <ti>acpi</ti>
362 + <ti>
363 + Depend on <c>sys-power/acpid</c> so that changes in the system are
364 + captured and power saving features are automatically enabled/disabled.
365 + </ti>
366 + <ti>your laptop is not too old (~ year 2003 and later)</ti>
367 +</tr>
368 +<tr>
369 + <ti>apm</ti>
370 + <ti>
371 + Depend on <c>sys-apps/apmd</c> so that changes in the system are captured
372 + and power saving features are automatically enabled/disabled.
373 + </ti>
374 + <ti>your laptop is very old</ti>
375 +</tr>
376 +<tr>
377 + <ti>bluetooth</ti>
378 + <ti>
379 + Depend on <c>net-wireless/bluez</c>, enabling the <c>laptop-mode-tools</c>
380 + to manage bluetooth settings (enabling/disabling the service based on
381 + battery availability)
382 + </ti>
383 + <ti>your laptop (and kernel) supports bluetooth</ti>
384 +</tr>
385 +<tr>
386 + <ti>scsi</ti>
387 + <ti>
388 + Depend on <c>sys-apps/sdparm</c>, enabling the <c>laptop-mode-tools</c> to
389 + manage SCSI (<e>and not</e> SATA) disk parameters.
390 + </ti>
391 + <ti>your laptop uses SCSI disks</ti>
392 +</tr>
393 +</table>
394 +
395 <p>
396 -Compile your kernel, make sure the right modules get loaded at startup and boot
397 -into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to
398 -get the acpi daemon. This one informs you about events like switching from AC
399 -to battery or closing the lid. Make sure the modules are loaded if you didn't
400 -compile them into the kernel and start acpid by executing <c>/etc/init.d/acpid
401 -start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
402 -soon see how to use it.
403 +As you can see, there are two USE flags that seem to collide: <c>acpi</c> and
404 +<c>apm</c>. So what's the deal there?
405 </p>
406
407 -<pre caption="Installing acpid">
408 -# <i>emerge sys-power/acpid</i>
409 -# <i>/etc/init.d/acpid start</i>
410 -# <i>rc-update add acpid default</i>
411 -</pre>
412 +<ul>
413 + <li>
414 + The <c>apm</c> USE flag enables support for <e>Advanced Power
415 + Management</e>, an older (before year 2000) standard for power management
416 + features within a system.
417 + </li>
418 + <li>
419 + The <c>acpi</c> USE flag enables support for <e>Advanced Configuration and
420 + Power Interface</e>, the successor of APM. All modern laptops support ACPI.
421 + </li>
422 +</ul>
423
424 -</body>
425 -</section>
426 -<section>
427 -<title>Creating A "battery" Runlevel</title>
428 -<body>
429 +<p>
430 +Depending on your system, you will either need <c>acpi</c> or <c>apm</c> set. In
431 +the remainder of this guide, we assume that your laptop is recent enough to use
432 +ACPI.
433 +</p>
434
435 <p>
436 -The default policy will be to enable Power Management only when needed -
437 -running on batteries. To make the switch between AC and battery convenient,
438 -create a runlevel <c>battery</c> that holds all the scripts starting and
439 -stopping Power Management.
440 +So, with the USE flags set, let's install <c>laptop-mode-tools</c>.
441 </p>
442
443 <note>
444 -You can safely skip this section if you don't like the idea of having another
445 -runlevel. However, skipping this step will make the rest a bit trickier to set
446 -up. The next sections assume a runlevel <c>battery</c> exists.
447 +If you have USE="acpi" set, the installation will pull in <c>acpid</c>. However,
448 +the current stable ACPI daemon (2.0.9) does not support the new ACPI interfaces
449 +within the Linux kernel (using the netlink interface). As such, we recommend
450 +unmasking <c>sys-power/acpid-2.0.12</c> (or higher). For more information about
451 +unmasking packages, please read
452 +<uri link="/doc/en/handbook/handbook-amd64.xml?part=3&amp;chap=3">Mixing Software
453 +Branches</uri> in the Gentoo Handbook.
454 </note>
455
456 -<pre caption="Creating a battery runlevel">
457 -# <i>cd /etc/runlevels</i>
458 -# <i>cp -a default battery</i>
459 +<pre caption="Installing laptop-mode-tools">
460 +# <i>emerge laptop-mode-tools</i>
461 </pre>
462
463 -<p>
464 -Finished. Your new runlevel <c>battery</c> contains everything like
465 -<c>default</c>, but there is no automatic switch between both yet. Time to
466 -change it.
467 -</p>
468 -
469 </body>
470 </section>
471 <section>
472 -<title>Reacting On ACPI Events</title>
473 +<title>Configuration</title>
474 <body>
475
476 <p>
477 -Typical ACPI events are closing the lid, changing the power source or pressing
478 -the sleep button. An important event is changing the power source, which should
479 -cause a runlevel switch. A small script will take care of it.
480 -</p>
481 -
482 -<p>
483 -First you need a script which changes the runlevel to <c>default</c>
484 -respectively <c>battery</c> depending on the power source. The script uses the
485 -<c>on_ac_power</c> command from <c>sys-power/pm-utils</c> - make sure the
486 -package is installed on your system.
487 +Having <c>laptop-mode-tools</c> installed on your system does not automatically
488 +enable the power management features that you might need. To configure the
489 +package, first take a look at <path>/etc/laptop-mode/laptop-mode.conf</path>.
490 +This is the main configuration file for the package and is pretty well described
491 +(through comments).
492 </p>
493
494 -<pre caption="Installing pm-utils">
495 -# <i>emerge pm-utils</i>
496 -</pre>
497 -
498 -<p>
499 -You are now able to determine the power source by executing <c>on_ac_power
500 -&amp;&amp; echo AC available || echo Running on batteries</c> in a shell. The
501 -script below is responsible for changing runlevels. Save it as
502 -<path>/etc/acpi/actions/pmg_switch_runlevel.sh</path>.
503 -</p>
504 -
505 -<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
506 -#!/bin/bash
507 -
508 -# BEGIN configuration
509 -RUNLEVEL_AC="default"
510 -RUNLEVEL_BATTERY="battery"
511 -
512 -if [ -x /usr/bin/logger ]; then
513 - LOGGER="/usr/bin/logger -s -p daemon.info -t /etc/acpi/actions/pmg_switch_runlevel.sh"
514 -else
515 - LOGGER="/bin/echo"
516 -fi
517 -
518 -ON_AC_POWER=/usr/bin/on_ac_power
519 -# END configuration
520 -
521 -
522 -if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
523 -then
524 - ${LOGGER} "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
525 - exit 1
526 -fi
527 -
528 -if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
529 -then
530 - ${LOGGER} "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
531 - exit 1
532 -fi
533 -
534 -if ${on_ac_power}
535 -then
536 - if [[ "$(rc-status --runlevel)" != "${RUNLEVEL_AC}" ]]
537 - then
538 - ${LOGGER} "Switching to ${RUNLEVEL_AC} runlevel"
539 - /sbin/rc ${RUNLEVEL_AC}
540 - fi
541 -elif [[ "$(rc-status --runlevel)" != "${RUNLEVEL_BATTERY}" ]]
542 -then
543 - ${LOGGER} "Switching to ${RUNLEVEL_BATTERY} runlevel"
544 - /sbin/rc ${RUNLEVEL_BATTERY}
545 -fi
546 -</pre>
547 -
548 <p>
549 -Dont forget to run <c>chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</c> to
550 -make the script executable. The last thing that needs to be done is calling the
551 -script whenever the power source changes. That's done by catching ACPI events
552 -with the help of <c>acpid</c>. First you need to know which events are
553 -generated when the power source changes. The events are called
554 -<c>ac_adapter</c> and <c>battery</c> on most laptops, but it might be different
555 -on yours.
556 +But it is not the only configuration file to work with. The Laptop Mode Tools
557 +package supports plugins (or modules) which have their own configuration
558 +file(s). These files are located in <path>/etc/laptop-mode/conf.d</path> and are
559 +named after the module they represent (such as
560 +<path>intel-sata-powermgmt.conf</path>).
561 </p>
562
563 -<pre caption="Determining ACPI events for changing the power source">
564 -# <i>tail -f /var/log/messages | grep "ACPI event"</i>
565 -</pre>
566 -
567 <p>
568 -Run the command above and pull the power cable. You should see something like
569 -this:
570 +Now, one of the important settings in each configuration file is if the Laptop
571 +Mode Tools package should govern a particular setting or not. This is important
572 +when you want to combine <c>laptop-mode-tools</c> with other services like
573 +<c>cpufreqd</c>. In this example case, you will need to set
574 +<c>CONTROL_CPU_FREQUENCY=0</c>:
575 </p>
576
577 -<pre caption="Sample output for power source changes">
578 -[Tue Sep 20 17:39:06 2005] ACPI event "ac_adapter AC 00000080 00000000"
579 -[Tue Sep 20 17:39:06 2005] ACPI event "battery BAT0 00000080 00000001"
580 +<pre caption="Editing /etc/laptop-mode/conf.d/cpufreq.conf">
581 +# <i>nano -w /etc/laptop-mode/conf.d/cpufreq.conf</i>
582 +CONTROL_CPU_FREQUENCY=<i>0</i>
583 </pre>
584
585 <p>
586 -The interesting part is the quoted string after <c>ACPI event</c>. It will
587 -be matched by the event line in the files you are going to create below. Don't
588 -worry if your system generates multiple events or always the same. As long as
589 -any event is generated, runlevel changing will work.
590 +The next few sections will help you configure <c>laptop-mode-tools</c> to suit
591 +your needs. When you are finished, start the <c>laptop_mode</c> service and make
592 +sure it is started when you boot up your system.
593 </p>
594
595 -<pre caption="/etc/acpi/events/pmg_ac_adapter">
596 -<comment># replace "ac_adapter" below with the event generated on your laptop</comment>
597 -<comment># For example, ac_adapter.* will match ac_adapter AC 00000080 00000000</comment>
598 -event=ac_adapter.*
599 -action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
600 +<pre caption="Starting the laptop_mode service">
601 +# <i>/etc/init.d/laptop_mode start</i>
602 +# <i>rc-update add laptop_mode default</i>
603 </pre>
604
605 -<pre caption="/etc/acpi/events/pmg_battery">
606 -<comment># replace "battery" below with the event generated on your laptop</comment>
607 -<comment># For example, battery.* will match battery BAT0 00000080 00000001</comment>
608 -event=battery.*
609 -action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
610 -</pre>
611 +</body>
612 +</section>
613 +<section>
614 +<title>How does laptop-mode-tools work</title>
615 +<body>
616
617 <p>
618 -Finally acpid has to be restarted to recognize the changes.
619 +When running the <c>laptop_mode</c> service, the software will check in which
620 +state your system is in. The states are defined as:
621 </p>
622
623 -<pre caption="Finishing runlevel switching with acpid">
624 -# <i>/etc/init.d/acpid restart</i>
625 -</pre>
626 +<ul>
627 + <li>
628 + <e>Battery</e>, in the configuration files using the <c>BATT_</c> prefix, is
629 + active when the system is running on battery power
630 + </li>
631 + <li>
632 + <e>AC</e>, in the configuration files using the <c>AC_</c> prefix, is active
633 + when the system is running on AC power
634 + </li>
635 + <li>
636 + <e>Laptop Mode</e>, in the configuration files using the <c>LM_</c> prefix,
637 + is active when <e>laptop mode</e> is enabled
638 + </li>
639 + <li>
640 + <e>No Laptop Mode</e>, in the configuration files using the <c>NOLM_</c>
641 + prefix, is active when <e>laptop mode</e> is disabled
642 + </li>
643 +</ul>
644
645 <p>
646 -Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
647 -mode" or "Switching to battery mode" messages. See the <uri
648 -link="#doc_chap8">Troubleshooting section</uri> if the script is not able to
649 -detect the power source correctly.
650 +The <c>AC/BATT_</c> and <c>LM/NOLM_</c> prefixes can be combined (so you can
651 +have a <c>AC_LM_</c> prefix).
652 </p>
653
654 <p>
655 -Due to the nature of the event mechanism, your laptop will boot into runlevel
656 -<c>default</c> regardless of the AC/battery state. This is fine when running
657 -from AC, but we'd like to boot into the battery runlevel otherwise. One
658 -solution would be to add another entry to the boot loader with the parameter
659 -<c>softlevel=battery</c>, but it's likely to forget choosing it. A better way
660 -is faking an ACPI event in the end of the boot process and letting
661 -<path>pmg_switch_runlevel.sh</path> script decide whether a runlevel change is
662 -necessary. Create a <path>/etc/local.d/battery.start</path> file with the
663 -following contents:
664 -</p>
665 -
666 -<pre caption="Runlevel adjustment at boot time through local.d/battery.start">
667 -#!/bin/sh
668 -<comment># Fake acpi event to switch runlevel if running on batteries</comment>
669 -/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
670 -</pre>
671 +When the <c>laptop_mode</c> service is started, it will switch modes based on
672 +events that occur (and of course based on the configuration settings). For
673 +instance, the setting <c>ENABLE_LAPTOP_MODE_ON_BATTERY=1</c> will make sure that
674 +the laptop mode tools switch to <e>laptop mode</e> when battery power is used.
675 +If that is the case, then the settings starting with <c>LM_</c>,
676 +<c>LM_BATT_</c>, <c>BATT_LM_</c> and <c>BATT_</c> will be used.
677 +</p>
678
679 <p>
680 -Don't forget to mark the file as executable (<c>chmod +x
681 -/etc/local.d/battery.start</c>). Prepared like this you can activate Power
682 -Management policies for individual devices.
683 +To make sure settings to not collide, it is not allowed to have overlapping
684 +settigns. In the next example, the first set (for <c>CPU_MAXFREQ</c>) is valid,
685 +but the second one (for <c>CPU_GOVERNOR</c>) isn't.
686 </p>
687
688 -</body>
689 -</section>
690 -</chapter>
691 -
692 -<chapter>
693 -<title>CPU Power Management</title>
694 -<section>
695 -<body>
696 +<pre caption="Colliding settings">
697 +<comment>## Valid set</comment>
698 +BATT_CPU_MAXFREQ=fastest
699 +LM_AC_CPU_MAXFREQ=fastest
700 +NOLM_AC_CPU_MAXFREQ=fastest
701
702 -<p>
703 -Mobile processors can operate at different frequencies. Some allow changing
704 -voltage as well. Most of the time your CPU doesn't need to run at full speed
705 -and scaling it down will save much energy - often without any performance
706 -decrease.
707 -</p>
708 +<comment>## Invalid set</comment>
709 +BATT_CPU_MINFREQ=fastest
710 +LM_AC_CPU_MINFREQ=fastest
711 +<comment># The following includes AC and BATT, but BATT is already defined</comment>
712 +NOLM_CPU_MINFREQ=fastest
713 +</pre>
714
715 </body>
716 </section>
717 <section>
718 -<title>Some Technical Terms</title>
719 +<title>Configuring CPU frequency management</title>
720 <body>
721
722 <p>
723 -CPU frequency scaling brings up some technical terms that might be unknown to
724 -you. Here's a quick introduction.
725 +The support for CPU frequency management in the laptop mode tools allows
726 +switching frequencies. It supports setting the CPU frequency governor, minimum
727 +frequency and maximum frequency. The configuration file used here is
728 +<path>/etc/laptop-mode/conf.d/cpufreq.conf</path>.
729 </p>
730
731 <p>
732 -First of all, the kernel has to be able to change the processor's frequency.
733 -The <b>CPUfreq processor driver</b> knows the commands to do it on your CPU.
734 -Thus it's important to choose the right one in your kernel. You should already
735 -have done it above. Once the kernel knows how to change frequencies, it has to
736 -know which frequency it should set. This is done according to the <b>policy</b>
737 -which consists of a <b>CPUfreq policy</b> and a <b>governor</b>. A CPUfreq
738 -policy are just two numbers which define a range the frequency has to stay
739 -between - minimal and maximal frequency. The governor now decides which of the
740 -available frequencies in between minimal and maximal frequency to choose. For
741 -example, the <b>powersave governor</b> always chooses the lowest frequency
742 -available, the <b>performance governor</b> the highest one. The <b>userspace
743 -governor</b> makes no decision but chooses whatever the user (or a program in
744 -userspace) wants - which means it reads the frequency from
745 -<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
746 +The <e>CPU frequency governor</e> is a kernel-level policy that defines how the
747 +kernel will select the CPU frequency. We already selected the governors we want
748 +to use in the kernel configuration earlier. Let's recap:
749 </p>
750
751 +<ul>
752 + <li>
753 + <c>performance</c> always picks the highest frequency
754 + </li>
755 + <li>
756 + <c>powersave</c> always picks the lowest frequency
757 + </li>
758 + <li>
759 + <c>userspace</c> does not pick anything, but let the user decide (or any
760 + process that the user is running that will decide for the user)
761 + </li>
762 + <li>
763 + <c>ondemand</c> will scale the CPU frequency up to the highest frequency
764 + when load is available
765 + </li>
766 + <li>
767 + <c>conservative</c> will scale the CPU frequency up gradually when load is
768 + available
769 + </li>
770 +</ul>
771 +
772 <p>
773 -This doesn't sound like dynamic frequency changes yet and in fact it isn't.
774 -Dynamics however can be accomplished with various approaches. For example, the
775 -<b>ondemand governor</b> makes its decisions depending on the current CPU load.
776 -The same is done by various userland tools like <c>cpudyn</c>, <c>cpufreqd</c>,
777 -<c>powernowd</c> and many more. ACPI events can be used to enable or disable
778 -dynamic frequency changes depending on power source.
779 +When switching between AC or battery, or (no) laptop mode, the appropriate
780 +governor (as well as its minimum and maximum frequency) is selected.
781 </p>
782
783 </body>
784 </section>
785 <section>
786 -<title>Setting The Frequency</title>
787 +<title>Configuring display brightness</title>
788 <body>
789
790 <p>
791 -Decreasing CPU speed and voltage has two advantages: On the one hand less
792 -energy is consumed, on the other hand there is thermal improvement as your
793 -system doesn't get as hot as running on full speed. The main disadvantage is
794 -obviously the loss of performance. Decreasing processor speed is a trade off
795 -between performance loss and energy saving.
796 +With <path>/etc/laptop-mode/conf.d/lcd-brightness.conf</path>, you can have the
797 +laptop mode tools govern the brightness of your LCD screen.
798 </p>
799
800 -<note>
801 -Not every laptop supports frequency scaling. If unsure, have a look at the list
802 -of supported processors in the <uri link="#doc_chap8">Troubleshooting</uri>
803 -section to verify yours is supported.
804 -</note>
805 -
806 <p>
807 -It's time to test whether CPU frequency changing works. Let's install another
808 -tool: <c>sys-power/cpufrequtils</c>.
809 +The file currently uses the <path>/proc/acpi/video/VID/LCD/brightness</path>
810 +file to set brightness values. Recent kernels do not provide this anymore -
811 +you will need to adjust this to <path>/sys/class/backlight/acpi_video0/brightness</path>
812 +instead.
813 </p>
814
815 -<pre caption="Checking CPU frequency">
816 -# <i>emerge cpufrequtils</i>
817 -# <i>cpufreq-info</i>
818 -</pre>
819 -
820 <p>
821 -Here is an example output:
822 +The values you can use are between 0 and 15, with 0 being the lowest brightness
823 +value.
824 </p>
825
826 -<pre caption="Sample output from cpufreq-info">
827 -cpufrequtils 0.3: cpufreq-info (C) Dominik Brodowski 2004
828 -Report errors and bugs to linux@×××××.de, please.
829 -analyzing CPU 0:
830 - driver: centrino
831 - CPUs which need to switch frequency at the same time: 0
832 - hardware limits: 600 MHz - 1.40 GHz
833 - available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
834 - available cpufreq governors: conservative, ondemand, powersave, userspace, performance
835 - current policy: frequency should be within 924 MHz and 1.40 GHz.
836 - The governor "performance" may decide which speed to use
837 - within this range.
838 - current CPU frequency is 1.40 GHz.
839 -</pre>
840 +</body>
841 +</section>
842 +<section>
843 +<title>Configuring other services</title>
844 +<body>
845
846 <p>
847 -Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
848 -Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
849 -governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
850 -expected, you might find help in the <uri link="#doc_chap8">Troubleshooting
851 -section</uri> in the end of this guide.
852 +An interesting feature of <c>laptop-mode-tools</c> is to support reloading
853 +particular services (like the system logger) after switching its configuration
854 +file. This is handled through
855 +<path>/etc/laptop-mode/conf.d/configuration-file-control.conf</path>.
856 </p>
857
858 <p>
859 -<c>cpufrequtils</c> can operate in an automatic mode (when you use the
860 -<b>ondemand</b> governor), you can also switch to the <b>userspace</b> governor
861 -if you want to manually set a specific speed. You can also statically set your
862 -CPU to its highest or lowest frequency by using the <b>performance</b>
863 -and <b>powersave</b> governors, respectively.
864 -</p>
865 -
866 -<pre caption="Changing CPU speeds">
867 -<comment>(Set the highest available frequency)</comment>
868 -# <i>cpufreq-set -g performance</i>
869 -<comment>(Set the lowest available frequency)</comment>
870 -# <i>cpufreq-set -g powersave</i>
871 -<comment>(Set a specific frequency)</comment>
872 -# <i>cpufreq-set -g userspace</i>
873 -# <i>cpufreq-set -f 2.00ghz</i>
874 -</pre>
875 +If enabled, the <c>laptop_mode</c> application will switch the configuration
876 +file(s) of the mentioned services with the same file, but suffixed with
877 +<path>-nolm-ac</path>, <path>-lm-ac</path> or <path>-batt</path>. It willl then
878 +signal or reload the appropriate services so they can use the new configuration
879 +file.
880 +</p>
881
882 </body>
883 </section>
884 +</chapter>
885 +
886 +<chapter>
887 +<title>Using cpufreqd</title>
888 <section>
889 -<title>Other CPU Speed Utilities</title>
890 +<title>Installation</title>
891 <body>
892
893 <p>
894 -While <c>cpufrequtils</c> may be the best all-around program, there are some
895 -other choices available in Portage. The following table gives a quick overview
896 -of available CPU speed utilities. It's roughly separated in three categories
897 -<b>kernel</b> for approaches that only need kernel support, <b>daemon</b> for
898 -programs that run in the background and <b>graphical</b> for programs that
899 -provide a GUI for easy configuration and changes.
900 +The <c>cpufreqd</c> application allows you to manage CPU frequencies in a more
901 +granular approach then what <c>laptop-mode-tools</c> supports. But before we
902 +dive into the installation of <c>cpufreqd</c>, let's first look at the USE flags
903 +it supports.
904 </p>
905
906 <table>
907 <tr>
908 - <th>Name</th>
909 - <th>Category</th>
910 - <th>Switch decision</th>
911 - <th>Kernel governors</th>
912 - <th>Further governors</th>
913 - <th>Comments</th>
914 + <th>USE flag</th>
915 + <th>Description</th>
916 + <th>Suggested when...</th>
917 </tr>
918 <tr>
919 - <ti>'ondemand' governor</ti>
920 - <ti>Kernel</ti>
921 - <ti>CPU load</ti>
922 - <ti>N.A.</ti>
923 - <ti>N.A.</ti>
924 + <ti>acpi</ti>
925 <ti>
926 - Chooses maximal frequency on CPU load and slowly steps down when the CPU is
927 - idle. Further tuning through files in
928 - <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
929 - userland tools (programs, scripts) if governor switching or similar is
930 - desired.
931 + Enable support for ACPI, allowing <c>cpufreqd</c> to be notified about
932 + specific events as well as govern power through the ACPI interface
933 </ti>
934 + <ti>your laptop is not too old (~ year 2003 and later)</ti>
935 </tr>
936 <tr>
937 - <ti>'conservative' governor</ti>
938 - <ti>Kernel</ti>
939 - <ti>CPU load</ti>
940 - <ti>N.A.</ti>
941 - <ti>N.A.</ti>
942 + <ti>apm</ti>
943 <ti>
944 - Unlike the ondemand governor, conversative doesn't jump to maximum
945 - frequency when CPU load is high, but increases the frequency step by step.
946 - Further tuning through files in
947 - <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
948 - userland tools (programs, scripts) if governor switching or similar is
949 - desired.
950 + Enable support for APM, allowing <c>cpufreqd</c> to be notified about
951 + specific events as wel as govern power through the APM interface
952 </ti>
953 + <ti>your laptop is very old</ti>
954 </tr>
955 <tr>
956 - <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
957 - <ti>Daemon</ti>
958 - <ti>CPU load</ti>
959 - <ti>Performance, powersave</ti>
960 - <ti>Dynamic</ti>
961 + <ti>lm_sensors</ti>
962 <ti>
963 - Also supports disk standby - notice however that <e>laptop mode</e> in most
964 - cases will do a better job.
965 + Enable support for the Linux hardware sensors (through
966 + <c>sys-apps/lm_sensors</c>), allowing to switch profiles based on hardware
967 + sensor results
968 </ti>
969 -</tr>
970 -<tr>
971 - <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
972 - <ti>Daemon</ti>
973 - <ti>Battery state, CPU load, temperature, running programs and more</ti>
974 - <ti>All available</ti>
975 - <ti>None</ti>
976 <ti>
977 - Sophisticated (but somewhat complicated) setup. Extendible through plugins
978 - like sensor monitoring (lm_sensors) or coordinating some NVidia based
979 - graphics card memory and core. Cpufreqd is SMP aware and can optionally be
980 - controlled manually at runtime.
981 + you want to use advanced events through lm_sensors
982 </ti>
983 </tr>
984 <tr>
985 + <ti>nforce2</ti>
986 <ti>
987 - <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
988 + Enable support for NForce, allowing <c>cpufreqd</c> to change the NForce FSB
989 + clock and video card frequency
990 </ti>
991 - <ti>Daemon</ti>
992 - <ti>CPU load</ti>
993 - <ti>None</ti>
994 - <ti>Passive, sine, aggressive</ti>
995 <ti>
996 - Supports SMP.
997 + you have an NVidia graphical card based on the NForce chipset
998 </ti>
999 </tr>
1000 <tr>
1001 + <ti>nvidia</ti>
1002 <ti>
1003 - <uri
1004 - link="http://projects.simpledesigns.com.pl/project/ncpufreqd/">ncpufreqd</uri>
1005 - </ti>
1006 - <ti>Daemon</ti>
1007 - <ti>Temperature</ti>
1008 - <ti>None</ti>
1009 - <ti>Powersave, performance</ti>
1010 - <ti>
1011 - Toggles the used governor between performance and powersave depending on
1012 - system temperature. Very useful on laptops with notorious heat problems.
1013 + Enable support for NVidia graphical card configuration (through the NVidia
1014 + <e>nvclock</e> interface), allowing <c>cpufreqd</c> to change the video card
1015 + frequency of NVidia graphical cards
1016 </ti>
1017 -</tr>
1018 -<tr>
1019 - <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
1020 - <ti>Daemon</ti>
1021 - <ti>CPU load</ti>
1022 - <ti>None</ti>
1023 - <ti>Dynamic, powersave, performance, fixed speed</ti>
1024 <ti>
1025 - Easy to configure with a nice client/server interface. Requires a 2.6
1026 - kernel. Unmaintained, broken and thus removed from Portage. Please switch
1027 - to cpufreqd if you're still using it.
1028 + you have an NVidia graphical card
1029 </ti>
1030 </tr>
1031 <tr>
1032 - <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
1033 - <ti>Graphical</ti>
1034 - <ti>None</ti>
1035 - <ti>None</ti>
1036 - <ti>None</ti>
1037 + <ti>pmu</ti>
1038 <ti>
1039 - Gnome application, a graphical tool to set CPU frequency manually. It does
1040 - not offer any automation.
1041 + Enable the Power Management Unit plug-in of <c>cpufreqd</c>. This allows the
1042 + software to poll the Linux kernel Power Supply interface, getting more
1043 + detailed information on battery charge.
1044 </ti>
1045 -</tr>
1046 -<tr>
1047 - <ti>klaptopdaemon</ti>
1048 - <ti>Graphical</ti>
1049 - <ti>Battery state</ti>
1050 - <ti>All available</ti>
1051 - <ti>None</ti>
1052 <ti>
1053 - KDE only, 'ondemand' governor required for dynamic frequency scaling.
1054 + your laptop does not support ACPI or APM
1055 </ti>
1056 </tr>
1057 </table>
1058
1059 <p>
1060 -While adjusting the frequency to the current load looks simple at a first
1061 -glance, it's not such a trivial task. A bad algorithm can cause switching
1062 -between two frequencies all the time or wasting energy when setting frequency
1063 -to an unnecessary high level.
1064 +The USE flags <c>acpi</c>, <c>apm</c> and <c>pmu</c> overlap, so you should only
1065 +have one active. If your laptop is sufficiently recent, <c>acpi</c> is your best
1066 +bet. If not, <c>apm</c> offers all that is needed. When even APM isn't
1067 +supported, you can try <c>pmu</c>.
1068 </p>
1069
1070 <p>
1071 -Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
1072 +With the USE flags configured, it is time to install <c>cpufreqd</c>.
1073 </p>
1074
1075 <pre caption="Installing cpufreqd">
1076 # <i>emerge cpufreqd</i>
1077 </pre>
1078
1079 -<p>
1080 -<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
1081 -The default one that ships with cpufreqd may look a bit confusing. I recommend
1082 -replacing it with the one from former Gentoo developer Henrik Brix Andersen
1083 -(see below). Please notice that you need cpufreqd-2.0.0 or later. Earlier
1084 -versions have a different syntax for the config file.
1085 -</p>
1086 -
1087 -<pre caption="/etc/cpufreqd.conf (cpufreqd-2.0.0 and later)">
1088 -[General]
1089 -pidfile=/var/run/cpufreqd.pid
1090 -poll_interval=3
1091 -enable_plugins=acpi_ac, acpi_battery
1092 -enable_remote=1
1093 -remote_group=wheel
1094 -verbosity=5
1095 -[/General]
1096 -
1097 -[Profile]
1098 -name=ondemand
1099 -minfreq=0%
1100 -maxfreq=100%
1101 -policy=ondemand
1102 -[/Profile]
1103 -
1104 -[Profile]
1105 -name=conservative
1106 -minfreq=0%
1107 -maxfreq=100%
1108 -policy=conservative
1109 -[/Profile]
1110 -
1111 -[Profile]
1112 -name=powersave
1113 -minfreq=0%
1114 -maxfreq=100%
1115 -policy=powersave
1116 -[/Profile]
1117 -
1118 -[Profile]
1119 -name=performance
1120 -minfreq=0%
1121 -maxfreq=100%
1122 -policy=performance
1123 -[/Profile]
1124 -
1125 -[Rule]
1126 -name=battery
1127 -ac=off
1128 -profile=conservative
1129 -[/Rule]
1130 -
1131 -[Rule]
1132 -name=battery_low
1133 -ac=off
1134 -battery_interval=0-10
1135 -profile=powersave
1136 -[/Rule]
1137 -
1138 -[Rule]
1139 -name=ac
1140 -ac=on
1141 -profile=ondemand
1142 -[/Rule]
1143 -</pre>
1144 -
1145 -<p>
1146 -Now you can start the cpufreqd daemon. Add it to the <c>default</c> and
1147 -<c>battery</c> runlevel as well.
1148 -</p>
1149 -
1150 -<pre caption="Starting cpufreqd">
1151 -# <i>rc-update add cpufreqd default battery</i>
1152 -# <i>/etc/init.d/cpufreqd start</i>
1153 -</pre>
1154 -
1155 -<p>
1156 -Sometimes it can be desirable to select another policy than the daemon chooses,
1157 -for example when battery power is low, but you know that AC will be available
1158 -soon. In that case you can turn on cpufreqd's manual mode with <c>cpufreqd-set
1159 -manual</c> and select one of your configured policies (as listed by
1160 -<c>cpufreqd-get</c>). You can leave manual mode by executing <c>cpufreqd-set
1161 -dynamic</c>.
1162 -</p>
1163 -
1164 -<warn>
1165 -Do not run more than one of the above programs at the same time. It may cause
1166 -confusion like switching between two frequencies all the time.
1167 -</warn>
1168 -
1169 </body>
1170 </section>
1171 <section>
1172 -<title>Verifying the result</title>
1173 +<title>Configuration</title>
1174 <body>
1175
1176 <p>
1177 -The last thing to check is that your new policies do a good job. An easy way to
1178 -do so is monitoring CPU speed while working with your laptop:
1179 -</p>
1180 -
1181 -<pre caption="Monitoring CPU speed">
1182 -# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
1183 -</pre>
1184 -
1185 -<p>
1186 -If <path>/proc/cpuinfo</path> doesn't get updated (see <uri
1187 -link="#doc_chap8">Troubleshooting</uri>), monitor the CPU frequency with
1188 -<c>sys-apps/x86info</c>:
1189 +The <c>cpufreqd</c> application monitors the status of the system through
1190 +several plugins. Based on the feedback it receives from those plugins, it will
1191 +adjust the policy used to govern the CPU frequency.
1192 </p>
1193
1194 -<pre caption="Alternative CPU speed monitoring">
1195 -# <i>watch x86info -mhz</i>
1196 -</pre>
1197 -
1198 <p>
1199 -Depending on your setup, CPU speed should increase on heavy load, decrease on
1200 -no activity or just stay at the same level. When using <c>cpufreqd</c> and
1201 -verbosity set to 5 or higher in <path>cpufreqd.conf</path> you'll get
1202 -additional information about what's happening reported to <c>syslog</c>.
1203 +<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. It
1204 +contains three different sections:
1205 </p>
1206
1207 -</body>
1208 -</section>
1209 -</chapter>
1210 -
1211 -<chapter>
1212 -<title>LCD Power Management</title>
1213 -<section>
1214 -<body>
1215 +<ol>
1216 + <li>
1217 + The <c>[General]...[/General]</c> section contains general configuration
1218 + information
1219 + </li>
1220 + <li>
1221 + The <c>[Profile]...[/Profile]</c> section defines the policies that the
1222 + <c>cpufreqd</c> daemon can switch to. The section is very similar to the
1223 + information you use when manually setting the CPU frequency policy using
1224 + <c>cpufreq-set</c>.
1225 + </li>
1226 + <li>
1227 + The <c>[Rule]...[/Rule]</c> section is the work-horse of the <c>cpufreqd</c>
1228 + daemon, defining when the daemon decides to switch to a different profile.
1229 + </li>
1230 +</ol>
1231
1232 <p>
1233 -As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD
1234 -display consumes the biggest part of energy (might not be the case for
1235 -non-mobile CPU's). Thus it's quite important not only to shut the display off
1236 -when not needed, but also to reduce it's backlight if possible. Most laptops
1237 -offer the possibility to control the backlight dimming.
1238 +Let's take a quick look at an example rule.
1239 </p>
1240
1241 -</body>
1242 -</section>
1243 -<section>
1244 -<title>Standby settings</title>
1245 -<body>
1246 +<pre caption="Sample cpufreqd rule">
1247 +[Profile]
1248 +name=On Demand High
1249 +minfreq=40%
1250 +maxfreq=100%
1251 +policy=ondemand
1252 +[/Profile]
1253
1254 -<p>
1255 -The first thing to check is the standby/suspend/off timings of the display. As
1256 -this depends heavily on your windowmanager, I'll let you figure it out
1257 -yourself. Just two common places: Blanking the terminal can be done with
1258 -<c>setterm -blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c>
1259 -and <c>setterm -powerdown &lt;number-of-minutesM&gt;</c>. For X.org, modify
1260 -<path>/etc/X11/xorg.conf</path> similar to this:
1261 -</p>
1262 -
1263 -<pre caption="LCD suspend settings in X.org">
1264 -Section "ServerFlags"
1265 - Option "blank time" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
1266 - Option "standby time" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
1267 - Option "suspend time" "20" <comment># Full suspend after 20 minutes</comment>
1268 - Option "off time" "30" <comment># Turn off after half an hour</comment>
1269 - [...]
1270 -EndSection
1271 -
1272 -[...]
1273 -
1274 -Section "Monitor"
1275 - Identifier [...]
1276 - Option "DPMS"
1277 - [...]
1278 -EndSection
1279 +[Rule]
1280 +name=AC Off - High Power
1281 +ac=off
1282 +battery_interval=70-100
1283 +profile=On Demand High
1284 +[/Rule]
1285 </pre>
1286
1287 -</body>
1288 -</section>
1289 -<section>
1290 -<title>Backlight dimming</title>
1291 -<body>
1292 -
1293 <p>
1294 -Probably more important is the backlight dimming. If you have access to the
1295 -dimming settings via a tool, write a small script that dims the backlight in
1296 -battery mode and place it in your <c>battery</c> runlevel. The following script
1297 -should work on most IBM Thinkpads and Toshiba laptops. You've got to enable the
1298 -appropriate option in your kernel (IBM Thinkpads only). For Toshiba laptops,
1299 -install <c>sys-power/acpitool</c> and skip configuration of <c>thinkpad_acpi</c>
1300 -(formerly called <c>ibm_acpi</c>) as described below.
1301 -</p>
1302 -
1303 -<warn>
1304 -Support for setting brightness is marked experimental in thinkpad_acpi. It
1305 -accesses hardware directly and may cause severe harm to your system. Please
1306 -read the <uri link="http://ibm-acpi.sourceforge.net/">thinkpad_acpi
1307 -website</uri>
1308 -</warn>
1309 -
1310 -<p>
1311 -To be able to set the brightness level, the thinkpad_acpi module has to be
1312 -loaded with the experimental parameter.
1313 -</p>
1314 -
1315 -<pre caption="Automatically loading the thinkpad_acpi module">
1316 -<comment>(Please read the warnings above before doing this!)</comment>
1317 -
1318 -# <i>echo "options thinkpad_acpi experimental=1" >> /etc/modprobe.d/thinkpad_acpi</i>
1319 -# <i>update-modules</i>
1320 -# <i>nano /etc/conf.d/modules</i>
1321 -<comment># Autoload the thinkpad_acpi module</comment>
1322 -modules_2_6="thinkpad_acpi"
1323 -<comment># Parameters for the thinkpad_acpi module</comment>
1324 -modules_thinkpad_acpi_args_2_6="experimental=1"
1325 -
1326 -# <i>modprobe thinkpad_acpi</i>
1327 -</pre>
1328 +In the above example, <c>cpufreqd</c> will switch the system to the <e>On Demand
1329 +High</e> profile (also shown in the above excerpt). This profile by itself uses
1330 +the <c>ondemand</c> governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
1331 +will have by this policy a minimum frequency of 800Mhz).
1332 +</p>
1333
1334 <p>
1335 -This should work without error messages and a file
1336 -<path>/proc/acpi/ibm/brightness</path> should be created after loading the
1337 -module. An init script will take care of choosing the brightness according to
1338 -the power source.
1339 +As you can see, the <c>cpufreqd</c> application can offer a more granular
1340 +approach on CPU frequency scaling. But not only that, you can tweak the CPU
1341 +frequency scaling based on various other metrics available. The default
1342 +configuration offers a sample rule for when you watch a movie, where you want
1343 +maximum performance, unless the CPU temperature is getting too high.
1344 </p>
1345
1346 -<pre caption="/etc/conf.d/lcd-brightness">
1347 -<comment># See /proc/acpi/ibm/brightness for available values</comment>
1348 -<comment># Please read /usr/src/linux/Documentation/thinkpad-acpi.txt</comment>
1349 -
1350 -<comment># brightness level in ac mode. Default is 7.</comment>
1351 -BRIGHTNESS_AC=7
1352 -
1353 -<comment># brightness level in battery mode. Default is 4.</comment>
1354 -BRIGHTNESS_BATTERY=4
1355 -</pre>
1356 -
1357 -<pre caption="/etc/init.d/lcd-brightness">
1358 -#!/sbin/runscript
1359 -
1360 -set_brightness() {
1361 - if on_ac_power
1362 - then
1363 - LEVEL=${BRIGHTNESS_AC:-7}
1364 - else
1365 - LEVEL=${BRIGHTNESS_BATTERY:-4}
1366 - fi
1367 -
1368 - if [ -f /proc/acpi/ibm/brightness ]
1369 - then
1370 - ebegin "Setting LCD brightness"
1371 - echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
1372 - eend $?
1373 - elif [[ -e /usr/bin/acpitool &amp;&amp; -n $(acpitool -T | grep "LCD brightness") ]]
1374 - then
1375 - ebegin "Setting LCD brightness"
1376 - acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
1377 - eend $?
1378 - else
1379 - ewarn "Setting LCD brightness is not supported."
1380 - ewarn "For IBM Thinkpads, check that thinkpad_acpi is loaded into the kernel"
1381 - ewarn "For Toshiba laptops, you've got to install sys-power/acpitool"
1382 - fi
1383 -}
1384 -
1385 -start() {
1386 - set_brightness
1387 -}
1388 -
1389 -stop () {
1390 - set_brightness
1391 -}
1392 -</pre>
1393 -
1394 <p>
1395 -When done, make sure brightness is adjusted automatically by adding it to the
1396 -battery runlevel.
1397 +When you have configured <c>cpufreqd</c>, it is time to start it (and make sure
1398 +the service is loaded automatically). Make sure that CPU frequency handling by
1399 +other tools (like <c>laptop-mode-tools</c>) is disabled!
1400 </p>
1401
1402 -<pre caption="Enabling automatic brightness adjustment">
1403 -# <i>chmod +x /etc/init.d/lcd-brightness</i>
1404 -# <i>rc-update add lcd-brightness battery</i>
1405 -# <i>rc</i>
1406 +<pre caption="Starting cpufreqd">
1407 +# <i>rc-service add cpufreqd default</i>
1408 +# <i>/etc/init.d/cpufreqd start</i>
1409 </pre>
1410
1411 </body>
1412 @@ -993,722 +643,40 @@
1413 </chapter>
1414
1415 <chapter>
1416 -<title>Disk Power Management</title>
1417 -<section>
1418 -<body>
1419 -
1420 -<p>
1421 -Hard disks consume less energy in sleep mode. Therefore it makes sense to
1422 -activate power saving features whenever the hard disk is not used for a certain
1423 -amount of time. I'll show you two alternative possibilities to do it. First,
1424 -laptop-mode will save most energy due to several measures which prevent or at
1425 -least delay write accesses. The drawback is that due to the delayed write
1426 -accesses a power outage or kernel crash will be more dangerous for data loss.
1427 -If you don't like this, you have to make sure that there are no processes which
1428 -write to your hard disk frequently. Afterwards you can enable power saving
1429 -features of your hard disk with <c>hdparm</c> as the second alternative.
1430 -</p>
1431 -
1432 -</body>
1433 -</section>
1434 +<title>Resources</title>
1435 <section>
1436 -<title>Increasing idle time - laptop-mode</title>
1437 +<title>Tools</title>
1438 <body>
1439
1440 -<p>
1441 -Recent 2.6 kernels include the so-called <c>laptop-mode</c>. When activated,
1442 -dirty buffers are written to disk on read calls or after 10 minutes (instead of
1443 -30 seconds). This minimizes the time the hard disk needs to be spun up.
1444 -</p>
1445 -
1446 -<pre caption="Automated start of laptop-mode">
1447 -# <i>emerge laptop-mode-tools</i>
1448 -</pre>
1449 -
1450 -<p>
1451 -<c>laptop-mode-tools</c> has its configuration file in
1452 -<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
1453 -it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
1454 -automatically.
1455 -</p>
1456 -
1457 -<p>
1458 -Recent versions (1.11 and later) of laptop-mode-tools include a new tool
1459 -<c>lm-profiler</c>. It will monitor your system's disk usage and running
1460 -network services and suggests to disable unneeded ones. You can either disable
1461 -them through laptop-mode-tools builtin runlevel support (which will be reverted
1462 -by Gentoo's <c>/sbin/rc</c>) or use your <c>default</c>/<c>battery</c>
1463 -runlevels (recommended).
1464 -</p>
1465 -
1466 -<pre caption="Sample output from running lm-profiler">
1467 -# <i>lm-profiler</i>
1468 -Profiling session started.
1469 -Time remaining: 600 seconds
1470 -[4296896.602000] amarokapp
1471 -Time remaining: 599 seconds
1472 -[4296897.714000] sort
1473 -[4296897.970000] mv
1474 -Time remaining: 598 seconds
1475 -Time remaining: 597 seconds
1476 -[4296900.482000] reiserfs/0
1477 -</pre>
1478 -
1479 -<p>
1480 -After profiling your system for ten minutes, lm-profiler will present a list of
1481 -services which might have caused disk accesses during that time.
1482 -</p>
1483 -
1484 -<pre caption="lm-profiler suggests to disable some services">
1485 -Program: "atd"
1486 -Reason: standard recommendation (program may not be running)
1487 -Init script: /etc/init.d/atd (GUESSED)
1488 -
1489 -Do you want to disable this service in battery mode? [y/N]: <i>n</i>
1490 -</pre>
1491 -
1492 -<p>
1493 -To disable atd as suggested in the example above, you would run <c>rc-update
1494 -del atd battery</c>. Be careful not to disable services that are needed for
1495 -your system to run properly - <c>lm-profiler</c> is likely to generate some
1496 -false positives. Do not disable a service if you are unsure whether it's
1497 -needed.
1498 -</p>
1499 +<ul>
1500 + <li>
1501 + <uri link="http://samwel.tk/laptop_mode/">Laptop Mode Tools Homepage</uri>,
1502 + includes <uri link="http://samwel.tk/laptop_mode/laptop_mode">About laptop
1503 + mode</uri>.
1504 + </li>
1505 + <li>
1506 + <uri link="http://www.lesswatts.org/projects/powertop/">PowerTOP</uri>, an
1507 + interactive application helping users to find out which processes are
1508 + forcing wakeups on the CPU most often.
1509 + </li>
1510 +</ul>
1511
1512 </body>
1513 </section>
1514 <section>
1515 -<title>Limiting Write Accesses</title>
1516 +<title>Articles and Guides</title>
1517 <body>
1518
1519 -<p>
1520 -If you don't want to use laptop-mode, you must take special care to disable
1521 -services that write to your disk frequently - <c>syslogd</c> is a good
1522 -candidate, for example. You probably don't want to shut it down completely, but
1523 -it's possible to modify the config file so that "unnecessary" things don't get
1524 -logged and thus don't create disk traffic. <c>Cups</c> writes to disk
1525 -periodically, so consider shutting it down and only enable it manually when
1526 -needed.
1527 -</p>
1528 -
1529 -<pre caption="Disabling cups in battery mode">
1530 -# <i>rc-update del cupsd battery</i>
1531 -</pre>
1532 -
1533 -<p>
1534 -You can also use <c>lm-profiler</c> from laptop-mode-tools (see above) to find
1535 -services to disable. Once you eliminated all of them, go on with configuring
1536 -hdparm.
1537 -</p>
1538 -
1539 -</body>
1540 -</section>
1541 -<section>
1542 -<title>hdparm</title>
1543 -<body>
1544 -
1545 -<p>
1546 -The second possibility is using <c>hdparm</c>. Skip this if
1547 -you are using laptop-mode. Otherwise, edit <path>/etc/conf.d/hdparm</path> and
1548 -add the following values to your drive entries. This example assumes your hard
1549 -drive is called <b>hda</b>:
1550 -</p>
1551 -
1552 -<pre caption="Using /etc/conf.d/hdparm for disk standby">
1553 -hda_args="-q -S12"
1554 -</pre>
1555 -
1556 -<p>
1557 -This will activate power management for your hard drive. If you ever want to
1558 -deactivate power management, you can edit <path>/etc/conf.d/hdparm</path> and
1559 -change the values to <c>-q -S0</c>, or just run <c>hdparm -q -S0 /dev/hda</c>.
1560 -</p>
1561 -
1562 -<p>
1563 -See <c>man hdparm</c> for the options. Though you can always start <c>hdparm</c>
1564 -manually when you are on battery power by running <c>/etc/init.d/hdparm
1565 -start</c>, it's much easier to automate its startup and shutdown. To do so, add
1566 -<c>hdparm</c> to the battery runlevel so that it will automatically enable power
1567 -management.
1568 -</p>
1569 -
1570 -<pre caption="Automate disk standby settings">
1571 -# <i>rc-update add hdparm battery</i>
1572 -</pre>
1573 -
1574 -<impo>
1575 -Be careful with sleep/spin down settings of your hard drive. Setting it to
1576 -small values might wear out your drive and lose warranty.
1577 -</impo>
1578 -
1579 -</body>
1580 -</section>
1581 -<section>
1582 -<title>Other tricks</title>
1583 -<body>
1584 -
1585 -<p>
1586 -Another possibility is to deactivate swap in battery mode. Before writing a
1587 -swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
1588 -heavily, otherwise you'll be in big problems.
1589 -</p>
1590 -
1591 -<p>
1592 -If you don't want to use laptop-mode, it's still possible to minimize disk
1593 -access by mounting certain directories as <c>tmpfs</c> - write accesses are not
1594 -stored on a disk, but in main memory and get lost with unmounting. Often it's
1595 -useful to mount <path>/tmp</path> like this - you don't have to pay special
1596 -attention as it gets cleared on every reboot regardless whether it was mounted
1597 -on disk or in RAM. Just make sure you have enough RAM and no program (like a
1598 -download client or compress utility) needs extraordinary much space in
1599 -<path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
1600 -add a line to <path>/etc/fstab</path> like this:
1601 -</p>
1602 -
1603 -<pre caption="Editing /etc/fstab to make /tmp even more volatile">
1604 -none /tmp tmpfs size=32m 0 0
1605 -</pre>
1606 -
1607 -<warn>
1608 -Pay attention to the size parameter and modify it for your system. If you're
1609 -unsure, don't try this at all, it can become a performance bottleneck easily. In
1610 -case you want to mount <path>/var/log</path> like this, make sure to merge the
1611 -log files to disk before unmounting. They are essential. Don't attempt to mount
1612 -<path>/var/tmp</path> like this. Portage uses it for compiling...
1613 -</warn>
1614 -
1615 -</body>
1616 -</section>
1617 -</chapter>
1618 -
1619 -<chapter>
1620 -<title>Power Management For Other Devices</title>
1621 -<section>
1622 -<title>Graphics Cards</title>
1623 -<body>
1624 -
1625 -<p>
1626 -In case you own an ATI graphics card supporting PowerPlay (dynamic clock
1627 -scaling for the graphics processing unit GPU), you can activate this
1628 -feature in X.org. Open <path>/etc/X11/xorg.conf</path> and add (or enable) the
1629 -<c>DynamicClocks</c> option in the Device section. Please notice that this
1630 -feature will lead to crashes on some systems.
1631 -</p>
1632 -
1633 -<pre caption="Enabling ATI PowerPlay support in X.org">
1634 -Section "Device"
1635 -[...]
1636 -Option "DynamicClocks" "on"
1637 -EndSection
1638 -</pre>
1639 -
1640 -</body>
1641 -</section>
1642 -<section>
1643 -<title>Wireless Power Management</title>
1644 -<body>
1645 -
1646 -<p>
1647 -Wireless LAN cards consume quite a bit of energy. Put them in Power Management
1648 -mode just like your hard drives.
1649 -</p>
1650 -
1651 -<note>
1652 -This script assumes your wireless interface is called <c>wlan0</c>; replace
1653 -this with the actual name of your interface.
1654 -</note>
1655 -
1656 -<p>
1657 -Add the following option to <path>/etc/conf.d/net</path> to automatically enable
1658 -power management for your wireless card:
1659 -</p>
1660 -
1661 -<pre caption="Automated WLAN Power Management">
1662 -iwconfig_wlan0="power on"
1663 -</pre>
1664 -
1665 -<p>
1666 -See <c>man iwconfig</c> for details and more options like the period between
1667 -wakeups or timeout settings. If your driver and access point support changing
1668 -the beacon time, this is a good starting point to save even more energy.
1669 -</p>
1670 -
1671 -</body>
1672 -</section>
1673 -<section>
1674 -<title>USB Power Management</title>
1675 -<body>
1676 -
1677 -<p>
1678 -There are two problems with USB devices regarding energy consumption: First,
1679 -devices like USB mice, digital cameras or USB sticks consume energy while
1680 -plugged in. You cannot avoid this (nevertheless remove them in case they're not
1681 -needed). Second, when there are USB devices plugged in, the USB host controller
1682 -periodically accesses the bus which in turn prevents the CPU from going into
1683 -sleep mode. The kernel offers an experimental option to enable suspension of
1684 -USB devices through driver calls or one of the <path>power/state</path> files
1685 -in <path>/sys</path>.
1686 -</p>
1687 -
1688 -<pre caption="Enabling USB suspend support in the kernel">
1689 -Device Drivers
1690 - USB support
1691 - [*] Support for Host-side USB
1692 - [*] USB suspend/resume (EXPERIMENTAL)
1693 -</pre>
1694 -
1695 -</body>
1696 -</section>
1697 -</chapter>
1698 -
1699 -<chapter>
1700 -<title>Sleep States: sleep, standby, and suspend to disk</title>
1701 -<section>
1702 -<body>
1703 -
1704 -<p>
1705 -ACPI defines different sleep states. The more important ones are
1706 -</p>
1707 -
1708 <ul>
1709 - <li>S1 aka Standby</li>
1710 - <li>S3 aka Suspend to RAM aka Sleep</li>
1711 - <li>S4 aka Suspend to Disk aka Hibernate</li>
1712 + <li>
1713 + A ThinkWiki article on <uri
1714 + link="http://www.thinkwiki.org/wiki/How_to_reduce_power_consumption">How to
1715 + reduce power consumption</uri> (on Linux). This article offers an exhaustive
1716 + list of measures one can take. However, it should be noted that the laptop
1717 + mode tools implements the majority of these (if properly configured).
1718 + </li>
1719 </ul>
1720
1721 -<p>
1722 -They can be called whenever the system is not in use, but a shutdown is not
1723 -wanted due to the long boot time.
1724 -</p>
1725 -
1726 -</body>
1727 -</section>
1728 -<section>
1729 -<title>Sleep (S3)</title>
1730 -<body>
1731 -
1732 -<p>
1733 -The ACPI support for these sleep states is marked experimental for good reason.
1734 -APM sleep states seem to be more stable, however you can't use APM and ACPI
1735 -together.
1736 -</p>
1737 -
1738 -<pre caption="Kernel configuration for the various suspend types">
1739 - Power Management Options ---&gt;
1740 - [*] Power Management support
1741 - [*] Suspend to RAM and standby
1742 -</pre>
1743 -
1744 -<p>
1745 -Once your kernel is properly configured, you can use the
1746 -<c>hibernate-script</c> to activate suspend or sleep mode. Let's install that
1747 -first.
1748 -</p>
1749 -
1750 -<pre caption="Installing the hibernate-script">
1751 -# <i>emerge hibernate-script</i>
1752 -</pre>
1753 -
1754 -<p>
1755 -Some configuration has to be done in <path>/etc/hibernate</path>. The default
1756 -package introduces a few configuration files for each sleep state. Options that
1757 -are common to all suspend methods are placed in <path>common.conf</path>; make
1758 -sure this file is properly set up for your system.
1759 -</p>
1760 -
1761 -<p>
1762 -To configure sleep, edit <path>sysfs-ram.conf</path> in
1763 -<path>/etc/hibernate</path>. <c>UseSysfsPowerState mem</c> is already setup
1764 -correctly, but if you need to make further changes to this particular sleep
1765 -state (or any other sleep state) you should add them to
1766 -<path>/etc/hibernate/hibernate.conf</path>. The comments and option names will
1767 -guide you. If you use nfs or samba shares over the network, make sure to
1768 -shutdown the appropriate init scripts to avoid timeouts.
1769 -</p>
1770 -
1771 -<note>
1772 -For more information on setting up sleep states, read <c>man
1773 -hibernate.conf</c>.
1774 -</note>
1775 -
1776 -<p>
1777 -Ready? Now is the last chance to backup any data you want to keep after
1778 -executing the next command. Notice that you probably have to hit a special key
1779 -like <c>Fn</c> to resume from sleep.
1780 -</p>
1781 -
1782 -<pre caption="Calling sleep">
1783 -# <i>hibernate-ram</i>
1784 -</pre>
1785 -
1786 -<p>
1787 -If you're still reading, it seems to work. You can also setup standby (S1) in a
1788 -similar way by editing <path>sysfs-ram.conf</path> and changing
1789 -"UseSysfsPowerState mem" to "UseSysfsPowerState standby". S3 and S4 are the more
1790 -interesting sleep states due to greater energy savings however.
1791 -</p>
1792 -
1793 -</body>
1794 -</section>
1795 -<section>
1796 -<title>Hibernate (S4)</title>
1797 -<body>
1798 -
1799 -<p>
1800 -This section introduces hibernation, where a snapshot of the running system is
1801 -written to disk before powering off. On resume, the snapshot is loaded and you
1802 -can go on working at exactly the point you called hibernate before.
1803 -</p>
1804 -
1805 -<warn>
1806 -Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load
1807 -a snapshot with a different kernel image than the one it was created with.
1808 -Shutdown any NFS or samba server/client before hibernating.
1809 -</warn>
1810 -
1811 -<p>
1812 -There are two different implementations for S4. The original one is swsusp,
1813 -then there is the newer tuxonice (formerly suspend2) with a nicer interface
1814 -(including fbsplash support). A <uri
1815 -link="http://tuxonice.net/features.html#compare">feature comparison</uri> is
1816 -available at the <uri link="http://www.tuxonice.net">tuxonice homepage</uri>.
1817 -There used to be Suspend-to-Disk (pmdisk), a fork of swsusp, but it has been
1818 -merged back.
1819 -</p>
1820 -
1821 -<p>
1822 -TuxOnIce is not included in the mainline kernel yet, therefore you either have
1823 -to patch your kernel sources with the patches provided by <uri
1824 -link="http://www.tuxonice.net">tuxonice.net</uri> or use
1825 -<c>sys-kernel/tuxonice-sources</c>.
1826 -</p>
1827 -
1828 -<p>
1829 -The kernel part for both swusp and TuxOnIce is as follows:
1830 -</p>
1831 -
1832 -<pre caption="Kernel configuration for the various suspend types">
1833 -Power Management support ---&gt;
1834 - <comment>(hibernate with swsusp)</comment>
1835 - [*] Hibernation (aka 'suspend to disk')
1836 - <comment>(replace /dev/SWAP with your swap partition)</comment>
1837 - (/dev/SWAP) Default resume partition
1838 -
1839 - <comment>(hibernate with TuxOnIce)</comment>
1840 - Enhanced Hibernation (TuxOnIce)
1841 - --- Image Storage (you need at least one allocator)
1842 - [*] File Allocator
1843 - [*] Swap Allocator
1844 - --- General Options
1845 - [*] Compression support
1846 - [ ] Allow Keep Image Mode
1847 - [*] Replace swsusp by default
1848 -</pre>
1849 -
1850 -<p>
1851 -The configuration for swsusp is rather easy. If you didn't store the location
1852 -of your swap partition in the kernel config, you can also pass it as a
1853 -parameter with the <c>resume=/dev/SWAP</c> directive. If booting is not
1854 -possible due to a broken image, use the <c>noresume</c> kernel parameter. The
1855 -<c>hibernate-cleanup</c> init script invalidates swsusp images during the boot
1856 -process.
1857 -</p>
1858 -
1859 -<pre caption="Invalidating swsusp images during the boot process">
1860 -# <i>rc-update add hibernate-cleanup boot</i>
1861 -</pre>
1862 -
1863 -<p>
1864 -To activate hibernate with swsusp, use the hibernate script and set
1865 -<c>UseSysfsPowerState disk</c> in <path>/etc/hibernate/sysfs-disk</path>.
1866 -</p>
1867 -
1868 -<warn>
1869 -Backup your data before doing this. Run <c>sync</c> before executing one of the
1870 -commands to have cached data written to disk. First try it outside of X, then
1871 -with X running, but not logged in.
1872 -</warn>
1873 -
1874 -<p>
1875 -If you experience kernel panics due to uhci or similar, try to compile USB
1876 -support as module and unload the modules before sending your laptop to sleep
1877 -mode. There are configuration options for this in <path>common.conf</path>
1878 -</p>
1879 -
1880 -<pre caption="Hibernating with swsusp">
1881 -# <i>nano -w /etc/hibernate/common.conf</i>
1882 -<comment>(Make sure you have a backup of your data)</comment>
1883 -# <i>hibernate</i>
1884 -</pre>
1885 -
1886 -<p>
1887 -The following section discusses the setup of TuxOnIce including fbsplash support
1888 -for a nice graphical progress bar during suspend and resume.
1889 -</p>
1890 -
1891 -<p>
1892 -The first part of the configuration is similar to the configuration of swsusp.
1893 -In case you didn't store the location of your swap partition in the kernel
1894 -config, you have to pass it as a kernel parameter with the
1895 -<c>resume=swap:/dev/SWAP</c> directive. If booting is not possible due to a
1896 -broken image, append the <c>noresume</c> parameter. Additionally, the
1897 -<c>hibernate-cleanup</c> init script invalidates TuxOnIce images during the boot
1898 -process.
1899 -</p>
1900 -
1901 -<pre caption="Invalidating TuxOnIce images during the boot process">
1902 -# <i>rc-update add hibernate-cleanup boot</i>
1903 -</pre>
1904 -
1905 -<p>
1906 -Now edit <path>/etc/hibernate/tuxonice.conf</path>, enable the <c>TuxOnIce</c>
1907 -options you need. Do not enable the <c>fbsplash</c> options in
1908 -<c>common.conf</c> just yet.
1909 -</p>
1910 -
1911 -<pre caption="Hibernating with TuxOnIce">
1912 -# <i>nano -w /etc/hibernate/tuxonice.conf</i>
1913 -<comment>(Make sure you have a backup of your data)</comment>
1914 -# <i>hibernate</i>
1915 -</pre>
1916 -
1917 -<p>
1918 -Please configure <c>fbsplash</c> now if you didn't do already. To enable
1919 -fbsplash support during hibernation, the <c>sys-apps/tuxonice-userui</c> package
1920 -is needed. Additionally, you've got to enable the <c>fbsplash</c> USE flag.
1921 -</p>
1922 -
1923 -<pre caption="Installing tuxonice-userui">
1924 -# <i>echo "sys-apps/tuxonice-userui fbsplash" >> /etc/portage/package.use</i>
1925 -# <i>emerge tuxonice-userui</i>
1926 -</pre>
1927 -
1928 -<p>
1929 -The ebuild tells you to make a symlink to the theme you want to use. For
1930 -example, to use the <c>livecd-2005.1</c> theme, run the following command:
1931 -</p>
1932 -
1933 -<pre caption="Using the livecd-2005.1 theme during hibernation">
1934 -# <i>ln -sfn /etc/splash/livecd-2005.1 /etc/splash/tuxonice</i>
1935 -</pre>
1936 -
1937 -<p>
1938 -If you don't want a black screen in the first part of the resume process, you
1939 -have to add the <c>tuxoniceui_fbsplash</c> tool to your initrd image. Assuming
1940 -you created the initrd image with <c>splash_geninitramfs</c> and saved it as
1941 -<path>/boot/fbsplash-emergence-1024x768</path>, here's how to do that.
1942 -</p>
1943 -
1944 -<pre caption="Adding tuxoniceui_fbsplash to an initrd image">
1945 -# <i>mount /boot</i>
1946 -# <i>mkdir ~/initrd.d</i>
1947 -# <i>cp /boot/fbsplash-emergence-1024x768 ~/initrd.d/</i>
1948 -# <i>cd ~/initrd.d</i>
1949 -# <i>gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc</i>
1950 -# <i>rm fbsplash-emergence-1024x768</i>
1951 -# <i>cp /usr/sbin/tuxoniceui_fbsplash sbin/</i>
1952 -# <i>find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-tuxonice-emergence-1024x768</i>
1953 -</pre>
1954 -
1955 -<p>
1956 -Afterwards adjust <path>grub.conf</path> (or <path>lilo.conf</path>) so that
1957 -your TuxOnIce kernel uses
1958 -<path>/boot/fbsplash-tuxonice-emergence-1024x768</path> as initrd image. You can
1959 -now test a dry run to see if everything is setup correctly.
1960 -</p>
1961 -
1962 -<pre caption="Test run for fbsplash hibernation">
1963 -# <i>tuxoniceui_fbsplash -t</i>
1964 -</pre>
1965 -
1966 -<p>
1967 -Afterwards open <path>/etc/hibernate/common.conf</path> and activate the
1968 -fbsplash options. Execute <c>hibernate</c> and enjoy.
1969 -</p>
1970 -
1971 -</body>
1972 -</section>
1973 -</chapter>
1974 -
1975 -<chapter>
1976 -<title>Troubleshooting</title>
1977 -<section>
1978 -<body>
1979 -
1980 -<p>
1981 -<e>Q:</e> I'm trying to change the CPU frequency, but
1982 -<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not
1983 -exist.
1984 -</p>
1985 -
1986 -<p>
1987 -<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose
1988 -the right CPUFreq driver for your processor. Here is a list of processors that
1989 -are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110,
1990 -AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron,
1991 -AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile
1992 -PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon,
1993 -Intel Pentium M (Centrino), National Semiconductors Geode GX, Transmeta Crusoe,
1994 -VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several "PowerBook" and
1995 -"iBook2" and various processors on some ACPI 2.0-compatible systems (only if
1996 -"ACPI Processor Performance States" are available to the ACPI/BIOS interface).
1997 -</p>
1998 -
1999 -<p>
2000 -<e>Q:</e> My laptop supports frequency scaling, but
2001 -<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
2002 -</p>
2003 -
2004 -<p>
2005 -<e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
2006 -Try to update the BIOS, especially if a broken DSDT is reported. You can also
2007 -try to fix it yourself (which is beyond the scope of this guide).
2008 -</p>
2009 -
2010 -<p>
2011 -<e>Q:</e> My laptop supports frequency scaling, but according to
2012 -<path>/proc/cpuinfo</path> the speed never changes.
2013 -</p>
2014 -
2015 -<p>
2016 -<e>A:</e> Probably you have activated symmetric multiprocessing support
2017 -(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
2018 -kernels had a bug causing this. In that case, run <c>emerge x86info</c>, update
2019 -your kernel as asked and check the current frequency with <c>x86info -mhz</c>.
2020 -</p>
2021 -
2022 -<p>
2023 -<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
2024 -another OS.
2025 -</p>
2026 -
2027 -<p>
2028 -<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
2029 -minimum frequency. Notice that throttling doesn't save much energy and is mainly
2030 -used for thermal management (keeping your laptop cool and quiet). You can read
2031 -the current throttling state with <c>cat /proc/acpi/processor/CPU/throttling</c>
2032 -and change it with <c>echo -n "0:x" > /proc/acpi/processor/CPU/limit</c>, where
2033 -x is one of the Tx states listed in
2034 -<path>/proc/acpi/processor/CPU/throttling</path>.
2035 -</p>
2036 -
2037 -<p>
2038 -<e>Q:</e> When configuring the kernel, powersave, performance and userspace
2039 -governors show up, but that ondemand thing is missing. Where do I get it?
2040 -</p>
2041 -
2042 -<p>
2043 -<e>A:</e> The ondemand governor is only included in recent kernel sources. Try
2044 -updating them.
2045 -</p>
2046 -
2047 -<p>
2048 -<e>Q:</e> Battery life time seems to be worse than before.
2049 -</p>
2050 -
2051 -<p>
2052 -<e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
2053 -settings.
2054 -</p>
2055 -
2056 -<p>
2057 -<e>Q:</e> My battery is charged, but KDE reports there would be 0% left and
2058 -immediately shuts down.
2059 -</p>
2060 -
2061 -<p>
2062 -<e>A:</e> Check that battery support is compiled into your kernel. If you use
2063 -it as a module, make sure the module is loaded.
2064 -</p>
2065 -
2066 -<p>
2067 -<e>Q:</e> My system logger reports things like "logger: ACPI group battery /
2068 -action battery is not defined".
2069 -</p>
2070 -
2071 -<p>
2072 -<e>A:</e> This message is generated by the <path>/etc/acpi/default.sh</path>
2073 -script that is shipped with acpid. You can safely ignore it. If you like to get
2074 -rid of it, you can comment the appropriate line in
2075 -<path>/etc/acpi/default.sh</path> as shown below:
2076 -</p>
2077 -
2078 -<pre caption="Disabling warnings about unknown acpi events">
2079 - *) # logger "ACPI action $action is not defined"
2080 -</pre>
2081 -
2082 -<p>
2083 -<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
2084 -</p>
2085 -
2086 -<p>
2087 -<e>A:</e> This seems to be a kernel bug. Read on <uri
2088 -link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
2089 -</p>
2090 -
2091 -<p>
2092 -<e>Q:</e> I activated the <c>DynamicClocks</c> option in <path>xorg.conf</path>
2093 -and now X.org crashes / the screen stays black / my laptop doesn't shutdown
2094 -properly.
2095 -</p>
2096 -
2097 -<p>
2098 -<e>A:</e> This happens on some systems. You have to disable
2099 -<c>DynamicClocks</c>.
2100 -</p>
2101 -
2102 -<p>
2103 -<e>Q:</e> I want to use TuxOnIce, but it tells me my swap partition is too
2104 -small. Resizing is not an option.
2105 -</p>
2106 -
2107 -<p>
2108 -<e>A:</e> If there is enough free space on your system, you can use the
2109 -filewriter instead of the swapwriter. The <c>hibernate-script</c> supports it as
2110 -well. More information can be found in
2111 -<path>/usr/src/linux/Documentation/power/tuxonice.txt</path>.
2112 -</p>
2113 -
2114 -<p>
2115 -<e>Q:</e> I just bought a brand new battery, but it only lasts for some
2116 -minutes! What am I doing wrong?
2117 -</p>
2118 -
2119 -<p>
2120 -<e>A:</e> First follow your manufacturer's advice on how to charge the battery
2121 -correctly.
2122 -</p>
2123 -
2124 -<p>
2125 -<e>Q:</e> The above didn't help. What should I do then?
2126 -</p>
2127 -
2128 -<p>
2129 -<e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
2130 -</p>
2131 -
2132 -<pre caption="Querying battery state">
2133 -$ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
2134 -design capacity: 47520 mWh
2135 -last full capacity: 41830 mWh
2136 -</pre>
2137 -
2138 -<p>
2139 -If the "last full capacity" differs significantly from the design capacity,
2140 -your battery is probably broken. Try to claim your warranty.
2141 -</p>
2142 -
2143 -<p>
2144 -<e>Q:</e> My problem is not listed above. Where should I go next?
2145 -</p>
2146 -
2147 -<p>
2148 -<e>A:</e> Don't fear to contact me, <mail link="earthwings@g.o">Dennis
2149 -Nienhüser</mail>, directly. The <uri link="http://forums.gentoo.org">Gentoo
2150 -Forums</uri> are a good place to get help as well. If you prefer IRC, try the
2151 -<c>#gentoo-laptop</c> <uri link="irc://irc.gentoo.org">channel</uri>.
2152 -</p>
2153 -
2154 </body>
2155 </section>
2156 </chapter>