/[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.54 - (show annotations) (download) (as text)
Mon Dec 9 20:07:13 2013 UTC (11 months, 1 week ago) by swift
Branch: MAIN
CVS Tags: HEAD
Changes since 1.53: +2 -2 lines
File MIME type: application/xml
Moved to https://wiki.gentoo.org/wiki/Power_management/HOWTO

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.53 2013/04/07 13:25:29 swift Exp $ -->
4
5 <guide disclaimer="obsolete" redirect="https://wiki.gentoo.org/wiki/Power_management/HOWTO">
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>8</version>
25 <date>2013-04-07</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>, which is active when the system is running on battery power;
325 the configuration files use the <c>BATT_</c> prefix for settings related to
326 this state
327 </li>
328 <li>
329 <e>AC</e>, which is active when the system is running on AC power;
330 the configuration files use the <c>AC_</c> prefix for settings related to
331 this state
332 </li>
333 <li>
334 <e>Laptop Mode</e>, which is active when <e>laptop mode</e> is enabled;
335 the configuration files use the <c>LM_</c> prefix for settings related to
336 this state
337 </li>
338 <li>
339 <e>No Laptop Mode</e>, which is active when <e>laptop mode</e> is disabled;
340 the configuration files use the <c>NOLM_</c> prefix for settings related to
341 this state
342 </li>
343 </ul>
344
345 <p>
346 The <c>AC/BATT_</c> and <c>LM/NOLM_</c> prefixes can be combined (so you can
347 have a <c>AC_LM_</c> prefix).
348 </p>
349
350 <p>
351 When the <c>laptop_mode</c> service is started, it will switch modes based on
352 events that occur (and of course based on the configuration settings). For
353 instance, the setting <c>ENABLE_LAPTOP_MODE_ON_BATTERY=1</c> will make sure that
354 the laptop mode tools switch to <e>laptop mode</e> when battery power is used.
355 If that is the case, then the settings starting with <c>LM_</c>,
356 <c>LM_BATT_</c>, <c>BATT_LM_</c> and <c>BATT_</c> will be used.
357 </p>
358
359 <p>
360 To make sure settings to not collide, it is not allowed to have overlapping
361 settigns. In the next example, the first set (for <c>CPU_MAXFREQ</c>) is valid,
362 but the second one (for <c>CPU_GOVERNOR</c>) isn't.
363 </p>
364
365 <pre caption="Colliding settings">
366 <comment>## Valid set</comment>
367 BATT_CPU_MAXFREQ=fastest
368 LM_AC_CPU_MAXFREQ=fastest
369 NOLM_AC_CPU_MAXFREQ=fastest
370
371 <comment>## Invalid set</comment>
372 BATT_CPU_MINFREQ=fastest
373 LM_AC_CPU_MINFREQ=fastest
374 <comment># The following includes AC and BATT, but BATT is already defined</comment>
375 NOLM_CPU_MINFREQ=fastest
376 </pre>
377
378 </body>
379 </section>
380 <section>
381 <title>Configuring CPU frequency management</title>
382 <body>
383
384 <p>
385 The support for CPU frequency management in the laptop mode tools allows
386 switching frequencies. It supports setting the CPU frequency governor, minimum
387 frequency and maximum frequency. The configuration file used here is
388 <path>/etc/laptop-mode/conf.d/cpufreq.conf</path>.
389 </p>
390
391 <p>
392 The <e>CPU frequency governor</e> is a kernel-level policy that defines how the
393 kernel will select the CPU frequency. We already selected the governors we want
394 to use in the kernel configuration earlier. Let's recap:
395 </p>
396
397 <ul>
398 <li>
399 <c>performance</c> always picks the highest frequency
400 </li>
401 <li>
402 <c>powersave</c> always picks the lowest frequency
403 </li>
404 <li>
405 <c>userspace</c> does not pick anything, but let the user decide (or any
406 process that the user is running that will decide for the user)
407 </li>
408 <li>
409 <c>ondemand</c> will scale the CPU frequency up to the highest frequency
410 when load is available
411 </li>
412 <li>
413 <c>conservative</c> will scale the CPU frequency up gradually when load is
414 available
415 </li>
416 </ul>
417
418 <p>
419 When switching between AC or battery, or (no) laptop mode, the appropriate
420 governor (as well as its minimum and maximum frequency) is selected.
421 </p>
422
423 </body>
424 </section>
425 <section>
426 <title>Configuring display brightness</title>
427 <body>
428
429 <p>
430 With <path>/etc/laptop-mode/conf.d/lcd-brightness.conf</path>, you can have the
431 laptop mode tools govern the brightness of your LCD screen.
432 </p>
433
434 <p>
435 The file currently uses the <path>/proc/acpi/video/VID/LCD/brightness</path>
436 file to set brightness values. Recent kernels do not provide this anymore -
437 you will need to adjust this to <path>/sys/class/backlight/acpi_video0/brightness</path>
438 instead.
439 </p>
440
441 <p>
442 The values you can use are between 0 and 15, with 0 being the lowest brightness
443 value.
444 </p>
445
446 </body>
447 </section>
448 <section>
449 <title>Configuring other services</title>
450 <body>
451
452 <p>
453 An interesting feature of <c>laptop-mode-tools</c> is to support reloading
454 particular services (like the system logger) after switching its configuration
455 file. This is handled through
456 <path>/etc/laptop-mode/conf.d/configuration-file-control.conf</path>.
457 </p>
458
459 <p>
460 If enabled, the <c>laptop_mode</c> application will switch the configuration
461 file(s) of the mentioned services with the same file, but suffixed with
462 <path>-nolm-ac</path>, <path>-lm-ac</path> or <path>-batt</path>. It willl then
463 signal or reload the appropriate services so they can use the new configuration
464 file.
465 </p>
466
467 </body>
468 </section>
469 </chapter>
470
471 <chapter>
472 <title>Using cpufreqd</title>
473 <section>
474 <title>Installation</title>
475 <body>
476
477 <p>
478 The <c>cpufreqd</c> application allows you to manage CPU frequencies in a more
479 granular approach then what <c>laptop-mode-tools</c> supports. But before we
480 dive into the installation of <c>cpufreqd</c>, let's first look at the USE flags
481 it supports.
482 </p>
483
484 <table>
485 <tr>
486 <th>USE flag</th>
487 <th>Description</th>
488 <th>Suggested when...</th>
489 </tr>
490 <tr>
491 <ti>acpi</ti>
492 <ti>
493 Enable support for ACPI, allowing <c>cpufreqd</c> to be notified about
494 specific events as well as govern power through the ACPI interface
495 </ti>
496 <ti>your laptop is not too old (~ year 2003 and later)</ti>
497 </tr>
498 <tr>
499 <ti>apm</ti>
500 <ti>
501 Enable support for APM, allowing <c>cpufreqd</c> to be notified about
502 specific events as well as govern power through the APM interface
503 </ti>
504 <ti>your laptop is very old</ti>
505 </tr>
506 <tr>
507 <ti>lm_sensors</ti>
508 <ti>
509 Enable support for the Linux hardware sensors (through
510 <c>sys-apps/lm_sensors</c>), allowing to switch profiles based on hardware
511 sensor results
512 </ti>
513 <ti>
514 you want to use advanced events through lm_sensors
515 </ti>
516 </tr>
517 <tr>
518 <ti>nforce2</ti>
519 <ti>
520 Enable support for NForce, allowing <c>cpufreqd</c> to change the NForce FSB
521 clock and video card frequency
522 </ti>
523 <ti>
524 you have an NVidia graphical card based on the NForce chipset
525 </ti>
526 </tr>
527 <tr>
528 <ti>nvidia</ti>
529 <ti>
530 Enable support for NVidia graphical card configuration (through the NVidia
531 <e>nvclock</e> interface), allowing <c>cpufreqd</c> to change the video card
532 frequency of NVidia graphical cards
533 </ti>
534 <ti>
535 you have an NVidia graphical card
536 </ti>
537 </tr>
538 <tr>
539 <ti>pmu</ti>
540 <ti>
541 Enable the Power Management Unit plug-in of <c>cpufreqd</c>. This allows the
542 software to poll the Linux kernel Power Supply interface, getting more
543 detailed information on battery charge.
544 </ti>
545 <ti>
546 your laptop does not support ACPI or APM
547 </ti>
548 </tr>
549 </table>
550
551 <p>
552 The USE flags <c>acpi</c>, <c>apm</c> and <c>pmu</c> overlap, so you should only
553 have one active. If your laptop is sufficiently recent, <c>acpi</c> is your best
554 bet. If not, <c>apm</c> offers all that is needed. When even APM isn't
555 supported, you can try <c>pmu</c>.
556 </p>
557
558 <p>
559 With the USE flags configured, it is time to install <c>cpufreqd</c>.
560 </p>
561
562 <pre caption="Installing cpufreqd">
563 # <i>emerge cpufreqd</i>
564 </pre>
565
566 </body>
567 </section>
568 <section>
569 <title>Configuration</title>
570 <body>
571
572 <p>
573 The <c>cpufreqd</c> application monitors the status of the system through
574 several plugins. Based on the feedback it receives from those plugins, it will
575 adjust the policy used to govern the CPU frequency.
576 </p>
577
578 <p>
579 <c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. It
580 contains three different sections:
581 </p>
582
583 <ol>
584 <li>
585 The <c>[General]...[/General]</c> section contains general configuration
586 information
587 </li>
588 <li>
589 The <c>[Profile]...[/Profile]</c> section defines the policies that the
590 <c>cpufreqd</c> daemon can switch to. The section is very similar to the
591 information you use when manually setting the CPU frequency policy using
592 <c>cpufreq-set</c>.
593 </li>
594 <li>
595 The <c>[Rule]...[/Rule]</c> section is the work-horse of the <c>cpufreqd</c>
596 daemon, defining when the daemon decides to switch to a different profile.
597 </li>
598 </ol>
599
600 <p>
601 Let's take a quick look at an example rule.
602 </p>
603
604 <pre caption="Sample cpufreqd rule">
605 [Profile]
606 name=On Demand High
607 minfreq=40%
608 maxfreq=100%
609 policy=ondemand
610 [/Profile]
611
612 [Rule]
613 name=AC Off - High Power
614 ac=off
615 battery_interval=70-100
616 profile=On Demand High
617 [/Rule]
618 </pre>
619
620 <p>
621 In the above example, <c>cpufreqd</c> will switch the system to the <e>On Demand
622 High</e> profile (also shown in the above excerpt). This profile by itself uses
623 the <c>ondemand</c> governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
624 will have by this policy a minimum frequency of 800Mhz).
625 </p>
626
627 <p>
628 As you can see, the <c>cpufreqd</c> application can offer a more granular
629 approach on CPU frequency scaling. But not only that, you can tweak the CPU
630 frequency scaling based on various other metrics available. The default
631 configuration offers a sample rule for when you watch a movie, where you want
632 maximum performance, unless the CPU temperature is getting too high.
633 </p>
634
635 <p>
636 When you have configured <c>cpufreqd</c>, it is time to start it (and make sure
637 the service is loaded automatically). Make sure that CPU frequency handling by
638 other tools (like <c>laptop-mode-tools</c>) is disabled!
639 </p>
640
641 <pre caption="Starting cpufreqd">
642 # <i>rc-update add cpufreqd default</i>
643 # <i>/etc/init.d/cpufreqd start</i>
644 </pre>
645
646 </body>
647 </section>
648 </chapter>
649
650 <chapter>
651 <title>Resources</title>
652 <section>
653 <title>Tools</title>
654 <body>
655
656 <ul>
657 <li>
658 <uri link="http://samwel.tk/laptop_mode/">Laptop Mode Tools Homepage</uri>,
659 includes <uri link="http://samwel.tk/laptop_mode/laptop_mode">About laptop
660 mode</uri>.
661 </li>
662 <li>
663 <uri link="http://www.lesswatts.org/projects/powertop/">PowerTOP</uri>, an
664 interactive application helping users to find out which processes are
665 forcing wakeups on the CPU most often.
666 </li>
667 </ul>
668
669 </body>
670 </section>
671 <section>
672 <title>Articles and Guides</title>
673 <body>
674
675 <ul>
676 <li>
677 A ThinkWiki article on <uri
678 link="http://www.thinkwiki.org/wiki/How_to_reduce_power_consumption">How to
679 reduce power consumption</uri> (on Linux). This article offers an exhaustive
680 list of measures one can take. However, it should be noted that the laptop
681 mode tools implements the majority of these (if properly configured).
682 </li>
683 </ul>
684
685 </body>
686 </section>
687 </chapter>
688 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20