/[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.52 - (show annotations) (download) (as text)
Mon Jan 14 06:19:27 2013 UTC (15 months ago) by nightmorph
Branch: MAIN
Changes since 1.51: +4 -4 lines
File MIME type: application/xml
fix rc command, via email to www@g.o address

1 <?xml version='1.0' encoding="UTF-8"?>
2 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.51 2012/03/28 23:20:12 nightmorph Exp $ -->
4
5 <guide>
6 <title>Power Management Guide</title>
7
8 <author title="Author">
9 <mail link="swift"/>
10 </author>
11
12 <abstract>
13 In recent years, power management has become one of the differentiating
14 features in the quest for finding the perfect laptop. Yet, the operating system
15 must support the various power saving functionalities too. In this guide, we
16 cover how to setup your Gentoo installation so it manages power-hungry resources
17 in a flexible yet automated manner.
18 </abstract>
19
20 <!-- The content of this document is licensed under the CC-BY-SA license -->
21 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
22 <license/>
23
24 <version>7</version>
25 <date>2013-01-13</date>
26
27 <chapter>
28 <title>Introduction</title>
29 <section>
30 <title>About this document...</title>
31 <body>
32
33 <p>
34 This document describes the setup of power management features on your laptop.
35 Although some of the information in this guide can be applied to power
36 management for servers, it is not the intention of this document to go that
37 route. Please be careful when applying this on a non-laptop system.
38 </p>
39
40 <p>
41 Within this document, we will focus primarily on the laptop mode tools since it
42 offers a complete set of functionalities. However, we will also refer to other
43 tools that might offer a more detailed approach on individual settings. In such
44 cases, you will need to disable the feature from the laptop mode tools so that
45 both tools do not fight over the same resource control.
46 </p>
47
48 </body>
49 </section>
50 <section>
51 <title>About laptop_mode</title>
52 <body>
53
54 <p>
55 The <c>laptop_mode</c> setting is an in-kernel configuration setting that
56 optimizes I/O, allowing disks to spin down properly (and not be woken up
57 immediately afterwards for queued operations).
58 </p>
59
60 </body>
61 </section>
62 <section>
63 <title>About laptop-mode-tools</title>
64 <body>
65
66 <p>
67 The <e>Laptop Mode Tools</e> is a software package
68 (<c>app-laptop/laptop-mode-tools</c>) which allows the user to optimize power
69 saving functions. It allows managing the <c>laptop_mode</c> setting in the Linux
70 kernel, but has additional features allowing you to tweak other power-related
71 settings on the system.
72 </p>
73
74 </body>
75 </section>
76 </chapter>
77
78 <chapter>
79 <title>Linux Kernel Configuration</title>
80 <section>
81 <title>Minimum kernel setup</title>
82 <body>
83
84 <p>
85 There are different kernel sources in Portage. We recommend using
86 <c>gentoo-sources</c>, but if you want advanced hibernation support you might
87 need <c>tuxonice-sources</c>. To enable proper power management features in the
88 Linux kernel, enable at least the following settings:
89 </p>
90
91 <pre caption="Minimum kernel setup for Power Management">
92 <![CDATA[
93 General setup --->
94 [*] Configure standard kernel features (expert users) --->
95
96 Power management and ACPI options --->
97 [*] Run-time PM core functionality
98 [*] ACPI (Advanced Configuration and Power Interface) Support --->
99 <*> AC Adapter
100 <*> Battery
101 -*- Button
102 -*- Video
103 <*> Fan
104 <*> Processor
105 <*> Thermal Zone
106 [*] Power Management Timer Support
107
108 [*] CPU Frequency scaling --->
109 [*] CPU Frequency scaling
110 <*> 'performance' governor
111 <*> 'powersave' governor
112 <*> 'userspace' governor
113 <*> 'ondemand' governor
114 <*> 'conservative' governor
115 <*> ACPI Processor P-States driver
116 ]]>
117 </pre>
118
119 <p>
120 Don't forget to enable the CPU frequency scaling driver for your CPU, located
121 right after the <e>ACPI Processor P-States driver</e> mentioned above.
122 </p>
123
124 <p>
125 Build and install the new kernel (if necessary) and reboot.
126 </p>
127
128 </body>
129 </section>
130 <!--
131 <section id="kernelconfig">
132 <title>Additional kernel configuration entries</title>
133 <body>
134
135 <p>
136 Further down this guide, additional kernel settings might be suggested. To
137 lessen the effort to maintain the guide, and to make sure settings are correctly
138 identified, we will use the kernel configuration short-hand notations. These
139 notations are simple strings, like <c>CONFIG_USB_SUSPEND</c>. But how to read
140 this?
141 </p>
142
143 <p>
144 Well, then you configure your kernel (through <c>make menuconfig</c>), you can
145 search through the configuration settings for a particular entry. Press <c>/</c>
146 while configuring the Linux kernel and type the setting
147 (<c>CONFIG_USB_SUSPEND</c>). The software will tell you what the setting is,
148 what it is for, when you can select it (i.e. on which settings it depends before
149 you can see it) but most importantly, where you can find it.
150 </p>
151
152 <pre caption="Result of a search operation during menuconfig">
153 <![CDATA[Symbol: USB_SUSPEND [=n]
154 Type : boolean
155 Prompt: USB runtime power management (autosuspend) and wakeup
156 Defined at drivers/usb/core/Kconfig:93
157 Depends on: USB_SUPPORT [=y] && USB [=y] && PM_RUNTIME [=n]
158 Location:
159 -> Device Drivers
160 -> USB support (USB_SUPPORT [=y])
161 -> Support for Host-side USB (USB [=y]) ]]>
162 </pre>
163
164 </body>
165 </section>
166 -->
167 </chapter>
168
169 <chapter>
170 <title>Using Laptop Mode Tools</title>
171 <section>
172 <title>Installation</title>
173 <body>
174
175 <p>
176 It comes to no surprise that installation of the <e>Laptop Mode Tools</e>
177 software is easily done through <c>emerge laptop-mode-tools</c>. However, this
178 package takes on additional, optional settings through USE flag configuration.
179 So let's first take a look at the supported USE flags and what they mean to the
180 package.
181 </p>
182
183 <table>
184 <tr>
185 <th>USE flag</th>
186 <th>Description</th>
187 <th>Suggested when...</th>
188 </tr>
189 <tr>
190 <ti>acpi</ti>
191 <ti>
192 Depend on <c>sys-power/acpid</c> so that changes in the system are
193 captured and power saving features are automatically enabled/disabled.
194 </ti>
195 <ti>your laptop is not too old (~ year 2003 and later)</ti>
196 </tr>
197 <tr>
198 <ti>apm</ti>
199 <ti>
200 Depend on <c>sys-apps/apmd</c> so that changes in the system are captured
201 and power saving features are automatically enabled/disabled.
202 </ti>
203 <ti>your laptop is very old</ti>
204 </tr>
205 <tr>
206 <ti>bluetooth</ti>
207 <ti>
208 Depend on <c>net-wireless/bluez</c>, enabling the <c>laptop-mode-tools</c>
209 to manage bluetooth settings (enabling/disabling the service based on
210 battery availability)
211 </ti>
212 <ti>your laptop (and kernel) supports bluetooth</ti>
213 </tr>
214 <tr>
215 <ti>scsi</ti>
216 <ti>
217 Depend on <c>sys-apps/sdparm</c>, enabling the <c>laptop-mode-tools</c> to
218 manage SCSI (<e>and not</e> SATA) disk parameters.
219 </ti>
220 <ti>your laptop uses SCSI disks</ti>
221 </tr>
222 </table>
223
224 <p>
225 As you can see, there are two USE flags that seem to collide: <c>acpi</c> and
226 <c>apm</c>. So what's the deal there?
227 </p>
228
229 <ul>
230 <li>
231 The <c>apm</c> USE flag enables support for <e>Advanced Power
232 Management</e>, an older (before year 2000) standard for power management
233 features within a system.
234 </li>
235 <li>
236 The <c>acpi</c> USE flag enables support for <e>Advanced Configuration and
237 Power Interface</e>, the successor of APM. All modern laptops support ACPI.
238 </li>
239 </ul>
240
241 <p>
242 Depending on your system, you will either need <c>acpi</c> or <c>apm</c> set. In
243 the remainder of this guide, we assume that your laptop is recent enough to use
244 ACPI.
245 </p>
246
247 <p>
248 So, with the USE flags set, let's install <c>laptop-mode-tools</c>.
249 </p>
250
251 <note>
252 If you have USE="acpi" set, the installation will pull in <c>acpid</c>. However,
253 the current stable ACPI daemon (2.0.9) does not support the new ACPI interfaces
254 within the Linux kernel (using the netlink interface). As such, we recommend
255 unmasking <c>sys-power/acpid-2.0.12</c> (or higher). For more information about
256 unmasking packages, please read
257 <uri link="/doc/en/handbook/handbook-amd64.xml?part=3&amp;chap=3">Mixing Software
258 Branches</uri> in the Gentoo Handbook.
259 </note>
260
261 <pre caption="Installing laptop-mode-tools">
262 # <i>emerge laptop-mode-tools</i>
263 </pre>
264
265 </body>
266 </section>
267 <section>
268 <title>Configuration</title>
269 <body>
270
271 <p>
272 Having <c>laptop-mode-tools</c> installed on your system does not automatically
273 enable the power management features that you might need. To configure the
274 package, first take a look at <path>/etc/laptop-mode/laptop-mode.conf</path>.
275 This is the main configuration file for the package and is pretty well described
276 (through comments).
277 </p>
278
279 <p>
280 But it is not the only configuration file to work with. The Laptop Mode Tools
281 package supports plugins (or modules) which have their own configuration
282 file(s). These files are located in <path>/etc/laptop-mode/conf.d</path> and are
283 named after the module they represent (such as
284 <path>intel-sata-powermgmt.conf</path>).
285 </p>
286
287 <p>
288 Now, one of the important settings in each configuration file is if the Laptop
289 Mode Tools package should govern a particular setting or not. This is important
290 when you want to combine <c>laptop-mode-tools</c> with other services like
291 <c>cpufreqd</c>. In this example case, you will need to set
292 <c>CONTROL_CPU_FREQUENCY=0</c>:
293 </p>
294
295 <pre caption="Editing /etc/laptop-mode/conf.d/cpufreq.conf">
296 # <i>nano -w /etc/laptop-mode/conf.d/cpufreq.conf</i>
297 CONTROL_CPU_FREQUENCY=<i>0</i>
298 </pre>
299
300 <p>
301 The next few sections will help you configure <c>laptop-mode-tools</c> to suit
302 your needs. When you are finished, start the <c>laptop_mode</c> service and make
303 sure it is started when you boot up your system.
304 </p>
305
306 <pre caption="Starting the laptop_mode service">
307 # <i>/etc/init.d/laptop_mode start</i>
308 # <i>rc-update add laptop_mode default</i>
309 </pre>
310
311 </body>
312 </section>
313 <section>
314 <title>How does laptop-mode-tools work</title>
315 <body>
316
317 <p>
318 When running the <c>laptop_mode</c> service, the software will check in which
319 state your system is in. The states are defined as:
320 </p>
321
322 <ul>
323 <li>
324 <e>Battery</e>, in the configuration files using the <c>BATT_</c> prefix, is
325 active when the system is running on battery power
326 </li>
327 <li>
328 <e>AC</e>, in the configuration files using the <c>AC_</c> prefix, is active
329 when the system is running on AC power
330 </li>
331 <li>
332 <e>Laptop Mode</e>, in the configuration files using the <c>LM_</c> prefix,
333 is active when <e>laptop mode</e> is enabled
334 </li>
335 <li>
336 <e>No Laptop Mode</e>, in the configuration files using the <c>NOLM_</c>
337 prefix, is active when <e>laptop mode</e> is disabled
338 </li>
339 </ul>
340
341 <p>
342 The <c>AC/BATT_</c> and <c>LM/NOLM_</c> prefixes can be combined (so you can
343 have a <c>AC_LM_</c> prefix).
344 </p>
345
346 <p>
347 When the <c>laptop_mode</c> service is started, it will switch modes based on
348 events that occur (and of course based on the configuration settings). For
349 instance, the setting <c>ENABLE_LAPTOP_MODE_ON_BATTERY=1</c> will make sure that
350 the laptop mode tools switch to <e>laptop mode</e> when battery power is used.
351 If that is the case, then the settings starting with <c>LM_</c>,
352 <c>LM_BATT_</c>, <c>BATT_LM_</c> and <c>BATT_</c> will be used.
353 </p>
354
355 <p>
356 To make sure settings to not collide, it is not allowed to have overlapping
357 settigns. In the next example, the first set (for <c>CPU_MAXFREQ</c>) is valid,
358 but the second one (for <c>CPU_GOVERNOR</c>) isn't.
359 </p>
360
361 <pre caption="Colliding settings">
362 <comment>## Valid set</comment>
363 BATT_CPU_MAXFREQ=fastest
364 LM_AC_CPU_MAXFREQ=fastest
365 NOLM_AC_CPU_MAXFREQ=fastest
366
367 <comment>## Invalid set</comment>
368 BATT_CPU_MINFREQ=fastest
369 LM_AC_CPU_MINFREQ=fastest
370 <comment># The following includes AC and BATT, but BATT is already defined</comment>
371 NOLM_CPU_MINFREQ=fastest
372 </pre>
373
374 </body>
375 </section>
376 <section>
377 <title>Configuring CPU frequency management</title>
378 <body>
379
380 <p>
381 The support for CPU frequency management in the laptop mode tools allows
382 switching frequencies. It supports setting the CPU frequency governor, minimum
383 frequency and maximum frequency. The configuration file used here is
384 <path>/etc/laptop-mode/conf.d/cpufreq.conf</path>.
385 </p>
386
387 <p>
388 The <e>CPU frequency governor</e> is a kernel-level policy that defines how the
389 kernel will select the CPU frequency. We already selected the governors we want
390 to use in the kernel configuration earlier. Let's recap:
391 </p>
392
393 <ul>
394 <li>
395 <c>performance</c> always picks the highest frequency
396 </li>
397 <li>
398 <c>powersave</c> always picks the lowest frequency
399 </li>
400 <li>
401 <c>userspace</c> does not pick anything, but let the user decide (or any
402 process that the user is running that will decide for the user)
403 </li>
404 <li>
405 <c>ondemand</c> will scale the CPU frequency up to the highest frequency
406 when load is available
407 </li>
408 <li>
409 <c>conservative</c> will scale the CPU frequency up gradually when load is
410 available
411 </li>
412 </ul>
413
414 <p>
415 When switching between AC or battery, or (no) laptop mode, the appropriate
416 governor (as well as its minimum and maximum frequency) is selected.
417 </p>
418
419 </body>
420 </section>
421 <section>
422 <title>Configuring display brightness</title>
423 <body>
424
425 <p>
426 With <path>/etc/laptop-mode/conf.d/lcd-brightness.conf</path>, you can have the
427 laptop mode tools govern the brightness of your LCD screen.
428 </p>
429
430 <p>
431 The file currently uses the <path>/proc/acpi/video/VID/LCD/brightness</path>
432 file to set brightness values. Recent kernels do not provide this anymore -
433 you will need to adjust this to <path>/sys/class/backlight/acpi_video0/brightness</path>
434 instead.
435 </p>
436
437 <p>
438 The values you can use are between 0 and 15, with 0 being the lowest brightness
439 value.
440 </p>
441
442 </body>
443 </section>
444 <section>
445 <title>Configuring other services</title>
446 <body>
447
448 <p>
449 An interesting feature of <c>laptop-mode-tools</c> is to support reloading
450 particular services (like the system logger) after switching its configuration
451 file. This is handled through
452 <path>/etc/laptop-mode/conf.d/configuration-file-control.conf</path>.
453 </p>
454
455 <p>
456 If enabled, the <c>laptop_mode</c> application will switch the configuration
457 file(s) of the mentioned services with the same file, but suffixed with
458 <path>-nolm-ac</path>, <path>-lm-ac</path> or <path>-batt</path>. It willl then
459 signal or reload the appropriate services so they can use the new configuration
460 file.
461 </p>
462
463 </body>
464 </section>
465 </chapter>
466
467 <chapter>
468 <title>Using cpufreqd</title>
469 <section>
470 <title>Installation</title>
471 <body>
472
473 <p>
474 The <c>cpufreqd</c> application allows you to manage CPU frequencies in a more
475 granular approach then what <c>laptop-mode-tools</c> supports. But before we
476 dive into the installation of <c>cpufreqd</c>, let's first look at the USE flags
477 it supports.
478 </p>
479
480 <table>
481 <tr>
482 <th>USE flag</th>
483 <th>Description</th>
484 <th>Suggested when...</th>
485 </tr>
486 <tr>
487 <ti>acpi</ti>
488 <ti>
489 Enable support for ACPI, allowing <c>cpufreqd</c> to be notified about
490 specific events as well as govern power through the ACPI interface
491 </ti>
492 <ti>your laptop is not too old (~ year 2003 and later)</ti>
493 </tr>
494 <tr>
495 <ti>apm</ti>
496 <ti>
497 Enable support for APM, allowing <c>cpufreqd</c> to be notified about
498 specific events as well as govern power through the APM interface
499 </ti>
500 <ti>your laptop is very old</ti>
501 </tr>
502 <tr>
503 <ti>lm_sensors</ti>
504 <ti>
505 Enable support for the Linux hardware sensors (through
506 <c>sys-apps/lm_sensors</c>), allowing to switch profiles based on hardware
507 sensor results
508 </ti>
509 <ti>
510 you want to use advanced events through lm_sensors
511 </ti>
512 </tr>
513 <tr>
514 <ti>nforce2</ti>
515 <ti>
516 Enable support for NForce, allowing <c>cpufreqd</c> to change the NForce FSB
517 clock and video card frequency
518 </ti>
519 <ti>
520 you have an NVidia graphical card based on the NForce chipset
521 </ti>
522 </tr>
523 <tr>
524 <ti>nvidia</ti>
525 <ti>
526 Enable support for NVidia graphical card configuration (through the NVidia
527 <e>nvclock</e> interface), allowing <c>cpufreqd</c> to change the video card
528 frequency of NVidia graphical cards
529 </ti>
530 <ti>
531 you have an NVidia graphical card
532 </ti>
533 </tr>
534 <tr>
535 <ti>pmu</ti>
536 <ti>
537 Enable the Power Management Unit plug-in of <c>cpufreqd</c>. This allows the
538 software to poll the Linux kernel Power Supply interface, getting more
539 detailed information on battery charge.
540 </ti>
541 <ti>
542 your laptop does not support ACPI or APM
543 </ti>
544 </tr>
545 </table>
546
547 <p>
548 The USE flags <c>acpi</c>, <c>apm</c> and <c>pmu</c> overlap, so you should only
549 have one active. If your laptop is sufficiently recent, <c>acpi</c> is your best
550 bet. If not, <c>apm</c> offers all that is needed. When even APM isn't
551 supported, you can try <c>pmu</c>.
552 </p>
553
554 <p>
555 With the USE flags configured, it is time to install <c>cpufreqd</c>.
556 </p>
557
558 <pre caption="Installing cpufreqd">
559 # <i>emerge cpufreqd</i>
560 </pre>
561
562 </body>
563 </section>
564 <section>
565 <title>Configuration</title>
566 <body>
567
568 <p>
569 The <c>cpufreqd</c> application monitors the status of the system through
570 several plugins. Based on the feedback it receives from those plugins, it will
571 adjust the policy used to govern the CPU frequency.
572 </p>
573
574 <p>
575 <c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. It
576 contains three different sections:
577 </p>
578
579 <ol>
580 <li>
581 The <c>[General]...[/General]</c> section contains general configuration
582 information
583 </li>
584 <li>
585 The <c>[Profile]...[/Profile]</c> section defines the policies that the
586 <c>cpufreqd</c> daemon can switch to. The section is very similar to the
587 information you use when manually setting the CPU frequency policy using
588 <c>cpufreq-set</c>.
589 </li>
590 <li>
591 The <c>[Rule]...[/Rule]</c> section is the work-horse of the <c>cpufreqd</c>
592 daemon, defining when the daemon decides to switch to a different profile.
593 </li>
594 </ol>
595
596 <p>
597 Let's take a quick look at an example rule.
598 </p>
599
600 <pre caption="Sample cpufreqd rule">
601 [Profile]
602 name=On Demand High
603 minfreq=40%
604 maxfreq=100%
605 policy=ondemand
606 [/Profile]
607
608 [Rule]
609 name=AC Off - High Power
610 ac=off
611 battery_interval=70-100
612 profile=On Demand High
613 [/Rule]
614 </pre>
615
616 <p>
617 In the above example, <c>cpufreqd</c> will switch the system to the <e>On Demand
618 High</e> profile (also shown in the above excerpt). This profile by itself uses
619 the <c>ondemand</c> governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
620 will have by this policy a minimum frequency of 800Mhz).
621 </p>
622
623 <p>
624 As you can see, the <c>cpufreqd</c> application can offer a more granular
625 approach on CPU frequency scaling. But not only that, you can tweak the CPU
626 frequency scaling based on various other metrics available. The default
627 configuration offers a sample rule for when you watch a movie, where you want
628 maximum performance, unless the CPU temperature is getting too high.
629 </p>
630
631 <p>
632 When you have configured <c>cpufreqd</c>, it is time to start it (and make sure
633 the service is loaded automatically). Make sure that CPU frequency handling by
634 other tools (like <c>laptop-mode-tools</c>) is disabled!
635 </p>
636
637 <pre caption="Starting cpufreqd">
638 # <i>rc-update add cpufreqd default</i>
639 # <i>/etc/init.d/cpufreqd start</i>
640 </pre>
641
642 </body>
643 </section>
644 </chapter>
645
646 <chapter>
647 <title>Resources</title>
648 <section>
649 <title>Tools</title>
650 <body>
651
652 <ul>
653 <li>
654 <uri link="http://samwel.tk/laptop_mode/">Laptop Mode Tools Homepage</uri>,
655 includes <uri link="http://samwel.tk/laptop_mode/laptop_mode">About laptop
656 mode</uri>.
657 </li>
658 <li>
659 <uri link="http://www.lesswatts.org/projects/powertop/">PowerTOP</uri>, an
660 interactive application helping users to find out which processes are
661 forcing wakeups on the CPU most often.
662 </li>
663 </ul>
664
665 </body>
666 </section>
667 <section>
668 <title>Articles and Guides</title>
669 <body>
670
671 <ul>
672 <li>
673 A ThinkWiki article on <uri
674 link="http://www.thinkwiki.org/wiki/How_to_reduce_power_consumption">How to
675 reduce power consumption</uri> (on Linux). This article offers an exhaustive
676 list of measures one can take. However, it should be noted that the laptop
677 mode tools implements the majority of these (if properly configured).
678 </li>
679 </ul>
680
681 </body>
682 </section>
683 </chapter>
684 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20