/[gentoo]/xml/htdocs/doc/en/power-management-guide.xml
Gentoo

Diff of /xml/htdocs/doc/en/power-management-guide.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.7 Revision 1.50
1<?xml version='1.0' encoding="UTF-8"?> 1<?xml version='1.0' encoding="UTF-8"?>
2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> 2<!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.7 2004/10/11 00:51:36 vapier Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.50 2011/09/30 15:07:46 cam Exp $ -->
4<guide link="power-management-guide.xml"> 4
5<guide>
5<title>Power Management Guide</title> 6<title>Power Management Guide</title>
6 7
7<author title="Author"> 8<author title="Author">
8 <mail link="fragfred@gmx.de">Dennis Nienh&#252;ser</mail> 9 <mail link="swift"/>
9</author> 10</author>
10 11
11<abstract> 12<abstract>
12Power Management is the key to extend battery run time on mobile systems like 13In recent years, power management has become one of the differentiating
13laptops. This guide assists you setting it up on your laptop. 14features in the quest for finding the perfect laptop. Yet, the operating system
15must support the various power saving functionalities too. In this guide, we
16cover how to setup your Gentoo installation so it manages power-hungry resources
17in a flexible yet automated manner.
14</abstract> 18</abstract>
15 19
16<!-- The content of this document is licensed under the CC-BY-SA license --> 20<!-- The content of this document is licensed under the CC-BY-SA license -->
17<!-- See http://creativecommons.org/licenses/by-sa/2.0 --> 21<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
18<license/> 22<license/>
19 23
20<version>1.17</version> 24<version>5</version>
21<date>October 10, 2004</date> 25<date>2011-09-22</date>
22 26
23<chapter> 27<chapter>
24<title>Introduction</title> 28<title>Introduction</title>
25
26<section>
27<title>Why Power Management?</title>
28
29<body>
30
31<p>
32Capacity and lifetime of laptop batteries has improved much in the last years.
33Nevertheless modern processors consume much more energy than older ones and
34each laptop generation introduces more devices hungry for energy. That's why
35Power Management is more important than ever. Increasing battery run time
36doesn't necessarily mean buying another battery. Much can be achieved applying
37intelligent Power Management policies.
38</p>
39
40</body>
41</section> 29<section>
30<title>About this document...</title>
31<body>
42 32
33<p>
34This document describes the setup of power management features on your laptop.
35Although some of the information in this guide can be applied to power
36management for servers, it is not the intention of this document to go that
37route. Please be careful when applying this on a non-laptop system.
38</p>
39
40<p>
41Within this document, we will focus primarily on the laptop mode tools since it
42offers a complete set of functionalities. However, we will also refer to other
43tools that might offer a more detailed approach on individual settings. In such
44cases, you will need to disable the feature from the laptop mode tools so that
45both tools do not fight over the same resource control.
46</p>
47
48</body>
43<section> 49</section>
44<title>A quick overview</title>
45<body>
46
47<p>
48Please notice that this guide describes Power Management for <e>laptops</e>.
49While some sections might also suite for <e>servers</e>, others do not and may
50even cause harm. Please do not apply anything from this guide to a server
51unless you really know what you are doing.
52</p>
53
54<p>
55As this guide has become rather long, here's a short overview helping you to
56find your way through it.
57</p>
58
59<p>
60The <e>Prerequisites</e> chapter talks about some requirements that should be
61met before any of the following device individual sections will work. This
62includes BIOS settings, kernel configuration and some simplifications in user
63land. The following three chapters focus on devices that typically consume most
64energy - processor, display and hard drive. Each can be configured seperately.
65<e>CPU Power Management</e> shows how to adjust the processor's frequency to
66save a maximum of energy whithout losing too much performance. A few different
67tricks prevent your hard drive from working unnecessarily often in <e>Disk Power
68Management</e> (decreasing noise level as a nice side effect). Some notes on
69Wireless LAN and USB finish the device section in <e>Power Management for other
70devices</e> while another chapter is dedicated to the (rather experimental)
71<e>sleep states</e>. Last not least <e>Troubleshooting</e> lists common
72pitfalls.
73</p>
74
75</body>
76</section> 50<section>
51<title>About laptop_mode</title>
52<body>
77 53
54<p>
55The <c>laptop_mode</c> setting is an in-kernel configuration setting that
56optimizes I/O, allowing disks to spin down properly (and not be woken up
57immediately afterwards for queued operations).
58</p>
59
60</body>
78<section> 61</section>
79<title>Power Budget for each component</title> 62<section>
63<title>About laptop-mode-tools</title>
80<body> 64<body>
81 65
82<figure link="/images/energy-budget.png" short="Which component consumes how
83much energy?" caption="Power budget for each component"/>
84
85<p> 66<p>
86Nearly every component can operate in different states - off, sleep, idle, 67The <e>Laptop Mode Tools</e> is a software package
87active to name a few - consuming a different amount of energy. Major parts are 68(<c>app-laptop/laptop-mode-tools</c>) which allows the user to optimize power
88consumed by the LCD display, CPU, chipset and hard drives. Often one is able to 69saving functions. It allows managing the <c>laptop_mode</c> setting in the Linux
89activate OS-independent Power Management in the BIOS, but an intelligent setup 70kernel, but has additional features allowing you to tweak other power-related
90in the operating system adapting to different situations can achieve much more. 71settings on the system.
91</p> 72</p>
92 73
93</body> 74</body>
94</section> 75</section>
95</chapter> 76</chapter>
96 77
97<chapter> 78<chapter>
98<title>Prerequisites</title> 79<title>Linux Kernel Configuration</title>
99<section>
100<title>What has to be done first</title>
101<body>
102
103<p>
104Before going into the details on making individual devices Power Management
105aware, make sure certain requirements are met. After controlling the BIOS
106settings, some kernel options want to be enabled - these are in short ACPI,
107sleep states and CPU frequency scaling. As power saving most of the time comes
108along with performance loss or increased latency, it should only be enabled
109when running on batteries. That's where a new runlevel <e>battery</e> comes in
110handy.
111</p>
112
113</body>
114</section> 80<section>
115<section> 81<title>Minimum kernel setup</title>
116<title>The BIOS part</title>
117<body>
118
119<p>
120First have a look into your BIOS Power Management settings. The best way is to
121combine BIOS and operating system policies, but for the moment it's better to
122disable most of the BIOS part. This makes sure it doesn't interfere with your
123policies. Don't forget to re-check BIOS settings after you configured
124everything else.
125</p>
126
127</body> 82<body>
128</section>
129<section>
130<title>Configuring the kernel</title>
131<body>
132 83
133<p>
134ACPI (Advanced Configuration and Power Interface) support in the kernel is
135still work in progress. Using a recent kernel will make sure you'll get the
136most out of it.
137</p> 84<p>
138 85There are different kernel sources in Portage. We recommend using
139<p> 86<c>gentoo-sources</c>, but if you want advanced hibernation support you might
140In kernel config, activate at least these options: 87need <c>tuxonice-sources</c>. To enable proper power management features in the
88Linux kernel, enable at least the following settings:
141</p> 89</p>
142 90
143<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)"> 91<pre caption="Minimum kernel setup for Power Management (Kernel 2.6)">
144Power Management Options ---&gt; 92<![CDATA[
145 [*] Power Management Support 93General setup --->
146 [ ] Software Suspend 94 [*] Configure standard kernel features (expert users) --->
147 [ ] Suspend-to-Disk Support
148 95
96Power management and ACPI options --->
149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 97 [*] ACPI (Advanced Configuration and Power Interface) Support --->
150 [*] ACPI Support 98 <*> AC Adapter
151 [ ] Sleep States 99 <*> Battery
152 &lt;M&gt; AC Adapter 100 -*- Button
153 &lt;M&gt; Battery 101 -*- Video
154 &lt;M&gt; Button 102 <*> Fan
155 &lt;M&gt; Fan 103 <*> Processor
156 &lt;M&gt; Processor 104 <*> Thermal Zone
157 &lt;M&gt; Thermal Zone 105 [*] Power Management Timer Support
158 &lt; &gt; ASUS/Medion Laptop Extras 106
159 &lt; &gt; Toshiba Laptop Extras
160 [ ] Debug Statements
161
162 CPU Frequency Scaling ---&gt; 107 [*] CPU Frequency scaling --->
163 [*] CPU Frequency scaling 108 [*] CPU Frequency scaling
164 Default CPUFreq governor (userspace)
165 &lt;*&gt; 'performance' governor 109 <*> 'performance' governor
166 &lt;*&gt; 'powersave' governor 110 <*> 'powersave' governor
167 &lt;*&gt; CPU frequency table helpers 111 <*> 'userspace' governor
112 <*> 'ondemand' governor
113 <*> 'conservative' governor
168 &lt;M&gt; ACPI Processor P-States driver 114 <*> ACPI Processor P-States driver
169 &lt;*&gt; <i>CPUFreq driver for your processor</i> 115]]>
170</pre> 116</pre>
171 117
172<p>
173Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk
174and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop,
175enable the appropriate section.
176</p> 118<p>
177 119Don't forget to enable the CPU frequency scaling driver for your CPU, located
120right after the <e>ACPI Processor P-States driver</e> mentioned above.
178<p> 121</p>
179Compile your kernel, make sure the right modules get loaded at startup and boot 122
180into your new ACPI-enabled kernel. Next run <c>emerge sys-apps/acpid</c> to get
181the acpi daemon. This one informs you about events like switching from AC to
182battery or closing the lid. Make sure the module <e>button</e> is loaded if you
183didn't compile it into the kernel and start acpid with <c>/etc/init.d/acpid
184start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll
185soon see how to use it.
186</p> 123<p>
187 124Build and install the new kernel (if necessary) and reboot.
188<pre caption="Installing acpid">
189# <i>emerge sys-apps/acpid</i>
190# <i>modprobe button</i>
191# <i>/etc/init.d/acpid start</i>
192# <i>rc-update add acpid default</i>
193</pre> 125</p>
194 126
195</body> 127</body>
196</section>
197<section> 128</section>
198<title>Creating a "battery" runlevel</title> 129<!--
130<section id="kernelconfig">
131<title>Additional kernel configuration entries</title>
132<body>
133
134<p>
135Further down this guide, additional kernel settings might be suggested. To
136lessen the effort to maintain the guide, and to make sure settings are correctly
137identified, we will use the kernel configuration short-hand notations. These
138notations are simple strings, like <c>CONFIG_USB_SUSPEND</c>. But how to read
139this?
140</p>
141
142<p>
143Well, then you configure your kernel (through <c>make menuconfig</c>), you can
144search through the configuration settings for a particular entry. Press <c>/</c>
145while configuring the Linux kernel and type the setting
146(<c>CONFIG_USB_SUSPEND</c>). The software will tell you what the setting is,
147what it is for, when you can select it (i.e. on which settings it depends before
148you can see it) but most importantly, where you can find it.
149</p>
150
151<pre caption="Result of a search operation during menuconfig">
152<![CDATA[Symbol: USB_SUSPEND [=n]
153Type : boolean
154Prompt: USB runtime power management (autosuspend) and wakeup
155 Defined at drivers/usb/core/Kconfig:93
156 Depends on: USB_SUPPORT [=y] && USB [=y] && PM_RUNTIME [=n]
157 Location:
158 -> Device Drivers
159 -> USB support (USB_SUPPORT [=y])
160 -> Support for Host-side USB (USB [=y]) ]]>
161</pre>
162
199<body> 163</body>
164</section>
165-->
166</chapter>
200 167
168<chapter>
169<title>Using Laptop Mode Tools</title>
170<section>
171<title>Installation</title>
172<body>
173
174<p>
175It comes to no surprise that installation of the <e>Laptop Mode Tools</e>
176software is easily done through <c>emerge laptop-mode-tools</c>. However, this
177package takes on additional, optional settings through USE flag configuration.
178So let's first take a look at the supported USE flags and what they mean to the
179package.
201<p> 180</p>
202The default policy will be to enable Power Management only when needed - 181
203running on batteries. To make the switch between AC and battery convenient, 182<table>
204create a runlevel <e>battery</e> that holds all the scripts starting and 183<tr>
205stopping Power Management. 184 <th>USE flag</th>
185 <th>Description</th>
186 <th>Suggested when...</th>
187</tr>
188<tr>
189 <ti>acpi</ti>
190 <ti>
191 Depend on <c>sys-power/acpid</c> so that changes in the system are
192 captured and power saving features are automatically enabled/disabled.
193 </ti>
194 <ti>your laptop is not too old (~ year 2003 and later)</ti>
195</tr>
196<tr>
197 <ti>apm</ti>
198 <ti>
199 Depend on <c>sys-apps/apmd</c> so that changes in the system are captured
200 and power saving features are automatically enabled/disabled.
201 </ti>
202 <ti>your laptop is very old</ti>
203</tr>
204<tr>
205 <ti>bluetooth</ti>
206 <ti>
207 Depend on <c>net-wireless/bluez</c>, enabling the <c>laptop-mode-tools</c>
208 to manage bluetooth settings (enabling/disabling the service based on
209 battery availability)
210 </ti>
211 <ti>your laptop (and kernel) supports bluetooth</ti>
212</tr>
213<tr>
214 <ti>scsi</ti>
215 <ti>
216 Depend on <c>sys-apps/sdparm</c>, enabling the <c>laptop-mode-tools</c> to
217 manage SCSI (<e>and not</e> SATA) disk parameters.
218 </ti>
219 <ti>your laptop uses SCSI disks</ti>
220</tr>
221</table>
222
223<p>
224As you can see, there are two USE flags that seem to collide: <c>acpi</c> and
225<c>apm</c>. So what's the deal there?
226</p>
227
228<ul>
229 <li>
230 The <c>apm</c> USE flag enables support for <e>Advanced Power
231 Management</e>, an older (before year 2000) standard for power management
232 features within a system.
233 </li>
234 <li>
235 The <c>acpi</c> USE flag enables support for <e>Advanced Configuration and
236 Power Interface</e>, the successor of APM. All modern laptops support ACPI.
237 </li>
238</ul>
239
240<p>
241Depending on your system, you will either need <c>acpi</c> or <c>apm</c> set. In
242the remainder of this guide, we assume that your laptop is recent enough to use
243ACPI.
244</p>
245
246<p>
247So, with the USE flags set, let's install <c>laptop-mode-tools</c>.
206</p> 248</p>
207 249
208<note> 250<note>
209You can safely skip this section if you don't like the idea of having another 251If you have USE="acpi" set, the installation will pull in <c>acpid</c>. However,
210runlevel. However, skipping this step will make the rest a bit trickier to set 252the current stable ACPI daemon (2.0.9) does not support the new ACPI interfaces
211up. The next sections assume a runlevel <e>battery</e> exists. 253within the Linux kernel (using the netlink interface). As such, we recommend
254unmasking <c>sys-power/acpid-2.0.12</c> (or higher). For more information about
255unmasking packages, please read
256<uri link="/doc/en/handbook/handbook-amd64.xml?part=3&amp;chap=3">Mixing Software
257Branches</uri> in the Gentoo Handbook.
212</note> 258</note>
213 259
214<pre caption="Creating a battery runlevel"> 260<pre caption="Installing laptop-mode-tools">
215# <i>cd /etc/runlevels</i> 261# <i>emerge laptop-mode-tools</i>
216# <i>cp -a default battery</i>
217</pre>
218
219<p>
220Finished. Your new runlevel <e>battery</e> contains everything like
221<e>default</e>, but there is no automatic switch between both yet. Time to
222change it.
223</p> 262</pre>
224 263
225</body> 264</body>
226</section>
227<section> 265</section>
228<title>Reacting on ACPI events</title> 266<section>
267<title>Configuration</title>
268<body>
269
270<p>
271Having <c>laptop-mode-tools</c> installed on your system does not automatically
272enable the power management features that you might need. To configure the
273package, first take a look at <path>/etc/laptop-mode/laptop-mode.conf</path>.
274This is the main configuration file for the package and is pretty well described
275(through comments).
276</p>
277
278<p>
279But it is not the only configuration file to work with. The Laptop Mode Tools
280package supports plugins (or modules) which have their own configuration
281file(s). These files are located in <path>/etc/laptop-mode/conf.d</path> and are
282named after the module they represent (such as
283<path>intel-sata-powermgmt.conf</path>).
284</p>
285
286<p>
287Now, one of the important settings in each configuration file is if the Laptop
288Mode Tools package should govern a particular setting or not. This is important
289when you want to combine <c>laptop-mode-tools</c> with other services like
290<c>cpufreqd</c>. In this example case, you will need to set
291<c>CONTROL_CPU_FREQUENCY=0</c>:
292</p>
293
294<pre caption="Editing /etc/laptop-mode/conf.d/cpufreq.conf">
295# <i>nano -w /etc/laptop-mode/conf.d/cpufreq.conf</i>
296CONTROL_CPU_FREQUENCY=<i>0</i>
297</pre>
298
299<p>
300The next few sections will help you configure <c>laptop-mode-tools</c> to suit
301your needs. When you are finished, start the <c>laptop_mode</c> service and make
302sure it is started when you boot up your system.
303</p>
304
305<pre caption="Starting the laptop_mode service">
306# <i>/etc/init.d/laptop_mode start</i>
307# <i>rc-update add laptop_mode default</i>
308</pre>
309
229<body> 310</body>
311</section>
312<section>
313<title>How does laptop-mode-tools work</title>
314<body>
230 315
231<p>
232Typical ACPI events are closing the lid, changing the power source or pressing
233the sleep button. Every acpi event recognized by the kernel is catched by acpid
234which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification
235supporting runlevel switching:
236</p> 316<p>
237 317When running the <c>laptop_mode</c> service, the software will check in which
238<pre caption="Event driven runlevel switching with acpid"> 318state your system is in. The states are defined as:
239#!/bin/sh
240
241set $*
242
243group=${1/\/*/}
244action=${1/*\//}
245
246<comment># runlevel to use in AC mode</comment>
247RLVL_AC="default"
248<comment># runlevel to use in battery mode</comment>
249RLVL_BATTERY="battery"
250
251<comment># file indicating the AC state. Verify the filename before using</comment>
252AC_STATE="/proc/acpi/ac_adapter/AC/state"
253<comment># this string means running on AC</comment>
254AC_ON="on-line"
255<comment># this string means running on batteries</comment>
256AC_OFF="off-line"
257
258function SwitchRunlevel() {
259 if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]]
260 then
261 logger "Switching to ${RLVL_BATTERY} runlevel"
262 /sbin/rc ${RLVL_BATTERY}
263 elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]]
264 then
265 logger "Switching to ${RLVL_AC} runlevel"
266 /sbin/rc ${RLVL_AC}
267 fi
268}
269
270
271case "$group" in
272 battery)
273 case "$action" in
274 battery)
275 SwitchRunlevel
276 ;;
277 *)
278 logger "ACPI group battery / action $action is not defined"
279 ;;
280 esac
281 ;;
282
283 ac_adapter)
284 case "$action" in
285 ac_adapter)
286 SwitchRunlevel
287 ;;
288 *)
289 logger "ACPI group ac_adapter / action $action is not defined"
290 ;;
291 esac
292 ;;
293 *)
294 logger "ACPI group $group / action $action is not defined"
295 ;;
296esac
297</pre>
298
299<p> 319</p>
300Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 320
301mode" or "Switching to battery mode" messages. 321<ul>
322 <li>
323 <e>Battery</e>, in the configuration files using the <c>BATT_</c> prefix, is
324 active when the system is running on battery power
325 </li>
326 <li>
327 <e>AC</e>, in the configuration files using the <c>AC_</c> prefix, is active
328 when the system is running on AC power
329 </li>
330 <li>
331 <e>Laptop Mode</e>, in the configuration files using the <c>LM_</c> prefix,
332 is active when <e>laptop mode</e> is enabled
333 </li>
334 <li>
335 <e>No Laptop Mode</e>, in the configuration files using the <c>NOLM_</c>
336 prefix, is active when <e>laptop mode</e> is disabled
337 </li>
338</ul>
339
302</p> 340<p>
303 341The <c>AC/BATT_</c> and <c>LM/NOLM_</c> prefixes can be combined (so you can
342have a <c>AC_LM_</c> prefix).
304<p> 343</p>
305Due to the nature of the event mechanism, your laptop will boot into runlevel 344
306<e>default</e> regardless of the AC/battery state. You can add another entry
307to the boot loader with <c>softlevel=boot</c>, but it's likely to forget
308choosing it. A better way is faking an ACPI event in the end of the boot
309process and let the <path>/etc/acpi/default.sh</path> script decide whether a
310runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your
311favourite editor and add these lines:
312</p> 345<p>
313 346When the <c>laptop_mode</c> service is started, it will switch modes based on
314<pre caption="Runlevel switch at boot time by editing local.start"> 347events that occur (and of course based on the configuration settings). For
315<comment># Fake acpi event to switch runlevel if running on batteries</comment> 348instance, the setting <c>ENABLE_LAPTOP_MODE_ON_BATTERY=1</c> will make sure that
316/etc/acpi/default.sh "battery/battery" 349the laptop mode tools switch to <e>laptop mode</e> when battery power is used.
317</pre> 350If that is the case, then the settings starting with <c>LM_</c>,
318 351<c>LM_BATT_</c>, <c>BATT_LM_</c> and <c>BATT_</c> will be used.
319<p> 352</p>
320Prepared like this you can activate Power Management policies for individual 353
321devices. 354<p>
355To make sure settings to not collide, it is not allowed to have overlapping
356settigns. In the next example, the first set (for <c>CPU_MAXFREQ</c>) is valid,
357but the second one (for <c>CPU_GOVERNOR</c>) isn't.
358</p>
359
360<pre caption="Colliding settings">
361<comment>## Valid set</comment>
362BATT_CPU_MAXFREQ=fastest
363LM_AC_CPU_MAXFREQ=fastest
364NOLM_AC_CPU_MAXFREQ=fastest
365
366<comment>## Invalid set</comment>
367BATT_CPU_MINFREQ=fastest
368LM_AC_CPU_MINFREQ=fastest
369<comment># The following includes AC and BATT, but BATT is already defined</comment>
370NOLM_CPU_MINFREQ=fastest
371</pre>
372
373</body>
374</section>
375<section>
376<title>Configuring CPU frequency management</title>
377<body>
378
379<p>
380The support for CPU frequency management in the laptop mode tools allows
381switching frequencies. It supports setting the CPU frequency governor, minimum
382frequency and maximum frequency. The configuration file used here is
383<path>/etc/laptop-mode/conf.d/cpufreq.conf</path>.
384</p>
385
386<p>
387The <e>CPU frequency governor</e> is a kernel-level policy that defines how the
388kernel will select the CPU frequency. We already selected the governors we want
389to use in the kernel configuration earlier. Let's recap:
390</p>
391
392<ul>
393 <li>
394 <c>performance</c> always picks the highest frequency
395 </li>
396 <li>
397 <c>powersave</c> always picks the lowest frequency
398 </li>
399 <li>
400 <c>userspace</c> does not pick anything, but let the user decide (or any
401 process that the user is running that will decide for the user)
402 </li>
403 <li>
404 <c>ondemand</c> will scale the CPU frequency up to the highest frequency
405 when load is available
406 </li>
407 <li>
408 <c>conservative</c> will scale the CPU frequency up gradually when load is
409 available
410 </li>
411</ul>
412
413<p>
414When switching between AC or battery, or (no) laptop mode, the appropriate
415governor (as well as its minimum and maximum frequency) is selected.
416</p>
417
418</body>
419</section>
420<section>
421<title>Configuring display brightness</title>
422<body>
423
424<p>
425With <path>/etc/laptop-mode/conf.d/lcd-brightness.conf</path>, you can have the
426laptop mode tools govern the brightness of your LCD screen.
427</p>
428
429<p>
430The file currently uses the <path>/proc/acpi/video/VID/LCD/brightness</path>
431file to set brightness values. Recent kernels do not provide this anymore -
432you will need to adjust this to <path>/sys/class/backlight/acpi_video0/brightness</path>
433instead.
434</p>
435
436<p>
437The values you can use are between 0 and 15, with 0 being the lowest brightness
438value.
439</p>
440
441</body>
442</section>
443<section>
444<title>Configuring other services</title>
445<body>
446
447<p>
448An interesting feature of <c>laptop-mode-tools</c> is to support reloading
449particular services (like the system logger) after switching its configuration
450file. This is handled through
451<path>/etc/laptop-mode/conf.d/configuration-file-control.conf</path>.
452</p>
453
454<p>
455If enabled, the <c>laptop_mode</c> application will switch the configuration
456file(s) of the mentioned services with the same file, but suffixed with
457<path>-nolm-ac</path>, <path>-lm-ac</path> or <path>-batt</path>. It willl then
458signal or reload the appropriate services so they can use the new configuration
459file.
322</p> 460</p>
323 461
324</body> 462</body>
325</section> 463</section>
326</chapter> 464</chapter>
327 465
328<chapter> 466<chapter>
329<title>CPU Power Management</title> 467<title>Using cpufreqd</title>
330<section>
331<title>Setting the frequency manually</title>
332<body>
333
334<p>
335Decreasing CPU speed and voltage has two advantages: On the one hand less
336energy is consumed, on the other hand there is thermal improvement as your
337system doesn't get as hot as running on full speed. The main disadvantage is
338obviously the loss of performance. Decreasing processor speed is a trade off
339between performance loss and energy saving.
340</p>
341
342<note>
343Not every laptop supports frequency scaling. If unsure, have a look at the list
344of supported processors in the <e>Troubleshooting</e> section to verify your's
345is supported.
346</note>
347
348<p>
349It's time to test whether CPU frequency changing works. To get comfortable with
350the interface to the kernel, first do some manual speed modifications. To set
351another CPU speed, use:
352</p>
353
354<pre caption="Manual CPU speed modifications">
355<comment>(Get current frequency)</comment>
356# <i>grep "cpu MHz" /proc/cpuinfo</i>
357
358<comment>(Lists supported frequencies. This might fail.)</comment>
359# <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i>
360# <i>cat scaling_available_frequencies</i>
361
362<comment>(Change frequency to 1 GHz (1000000 KHz)
363Replace with a frequency your laptop supports.)</comment>
364# <i>echo -n userspace > scaling_governor</i>
365# <i>echo -n 1000000 > scaling_setspeed</i>
366
367<comment>(Verify frequency was changed)</comment>
368# <i>grep "cpu MHz" /proc/cpuinfo</i>
369</pre>
370
371<p>
372If you are getting error messages, please refer to the <e>Troubleshooting</e>
373chapter in the end of this guide.
374</p>
375
376<p>
377You can also write to <path>scaling_max_freq</path> and
378<path>scaling_min_freq</path> to set boundaries the frequency should stay in
379between.
380</p>
381
382<note>
383Some kernel seem to be buggy about updating <path>/proc/cpuinfo</path>. If you
384don't see any change there, this doesn't neccessarily mean the CPU frequency
385wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your
386kernel as asked and check the current frequency with <c>x86info -mhz</c>.
387</note>
388
389</body>
390</section> 468<section>
391<section> 469<title>Installation</title>
392<title>Automated frequency adaption</title>
393<body> 470<body>
394 471
395<p> 472<p>
396The above is quite nice, but not doable in daily life. Better let your system 473The <c>cpufreqd</c> application allows you to manage CPU frequencies in a more
397set the appropriate frequency automatically. A couple of user space programs 474granular approach then what <c>laptop-mode-tools</c> supports. But before we
398like to do it for you. The following table gives a quick overview to help you 475dive into the installation of <c>cpufreqd</c>, let's first look at the USE flags
399decide on one of them. 476it supports.
400</p> 477</p>
401 478
402<table> 479<table>
403<tr> 480<tr>
404 <th>Name</th> 481 <th>USE flag</th>
405 <th>Pro</th> 482 <th>Description</th>
406 <th>Con</th> 483 <th>Suggested when...</th>
407</tr>
408<tr> 484</tr>
409 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
410 <ti>Also supports disk standby</ti>
411 <ti></ti>
412</tr> 485<tr>
413<tr> 486 <ti>acpi</ti>
414 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti>
415 <ti>Sophisticated setup possible</ti>
416 <ti>Complicated setup</ti>
417</tr>
418<tr>
419 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
420 <ti>
421 Small yet powerful<br />
422 Useful client/server interface
423 </ti> 487 <ti>
424 <ti>Kernel 2.6 series only</ti> 488 Enable support for ACPI, allowing <c>cpufreqd</c> to be notified about
425</tr> 489 specific events as well as govern power through the ACPI interface
490 </ti>
491 <ti>your laptop is not too old (~ year 2003 and later)</ti>
426<tr> 492</tr>
427 <ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti> 493<tr>
428 <ti>Supports SMP</ti>
429 <ti></ti> 494 <ti>apm</ti>
495 <ti>
496 Enable support for APM, allowing <c>cpufreqd</c> to be notified about
497 specific events as well as govern power through the APM interface
498 </ti>
499 <ti>your laptop is very old</ti>
500</tr>
501<tr>
502 <ti>lm_sensors</ti>
503 <ti>
504 Enable support for the Linux hardware sensors (through
505 <c>sys-apps/lm_sensors</c>), allowing to switch profiles based on hardware
506 sensor results
507 </ti>
508 <ti>
509 you want to use advanced events through lm_sensors
510 </ti>
511</tr>
512<tr>
513 <ti>nforce2</ti>
514 <ti>
515 Enable support for NForce, allowing <c>cpufreqd</c> to change the NForce FSB
516 clock and video card frequency
517 </ti>
518 <ti>
519 you have an NVidia graphical card based on the NForce chipset
520 </ti>
521</tr>
522<tr>
523 <ti>nvidia</ti>
524 <ti>
525 Enable support for NVidia graphical card configuration (through the NVidia
526 <e>nvclock</e> interface), allowing <c>cpufreqd</c> to change the video card
527 frequency of NVidia graphical cards
528 </ti>
529 <ti>
530 you have an NVidia graphical card
531 </ti>
532</tr>
533<tr>
534 <ti>pmu</ti>
535 <ti>
536 Enable the Power Management Unit plug-in of <c>cpufreqd</c>. This allows the
537 software to poll the Linux kernel Power Supply interface, getting more
538 detailed information on battery charge.
539 </ti>
540 <ti>
541 your laptop does not support ACPI or APM
542 </ti>
430</tr> 543</tr>
431</table> 544</table>
432 545
433<p> 546<p>
434While adjusting the frequency to the current load looks simple on the first 547The USE flags <c>acpi</c>, <c>apm</c> and <c>pmu</c> overlap, so you should only
435view, it's not such a trivial task. A bad algorithm can cause switching between 548have one active. If your laptop is sufficiently recent, <c>acpi</c> is your best
436two frequencies all the time or wasting energy when setting frequency to an 549bet. If not, <c>apm</c> offers all that is needed. When even APM isn't
437unnecessary high level. 550supported, you can try <c>pmu</c>.
438</p>
439
440<p> 551</p>
441Which one to choose? If you have no idea about it, first try <c>speedfreq</c>: 552
442</p> 553<p>
443 554With the USE flags configured, it is time to install <c>cpufreqd</c>.
444<pre caption="Installing speedfreq">
445# <i>emerge speedfreq</i>
446# <i>rc-update add speedfreq battery</i>
447</pre>
448
449<p> 555</p>
450<c>speedfreq</c> can be configured by editing
451<path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able
452to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to
453<c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon.
454</p>
455
456<pre caption="Starting speedfreq">
457# <i>/etc/init.d/speedfreq start</i>
458</pre>
459
460<p>
461Setting up cpufreq is a little bit more complicated.
462</p>
463
464<warn>
465Do not run more than one of the above programs at the same time. It may cause
466confusion like switching between two frequencies all the time. If you just
467installed speedfreq, skip cpufreq now.
468</warn>
469 556
470<pre caption="Installing cpufreqd"> 557<pre caption="Installing cpufreqd">
471# <i>emerge cpufreqd</i> 558# <i>emerge cpufreqd</i>
472# <i>rc-update add cpufreqd battery</i>
473</pre> 559</pre>
474 560
475<p> 561</body>
476<c>cpufreqd</c> comes with a default configuration in 562</section>
477<path>/etc/cpufreqd.conf</path>. 563<section>
478Change the config file to fit your needs. The following will save more energy 564<title>Configuration</title>
479than the default one - at the cost of less performance, of course. 565<body>
566
480</p> 567<p>
568The <c>cpufreqd</c> application monitors the status of the system through
569several plugins. Based on the feedback it receives from those plugins, it will
570adjust the policy used to govern the CPU frequency.
571</p>
481 572
573<p>
574<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>. It
575contains three different sections:
576</p>
577
578<ol>
579 <li>
580 The <c>[General]...[/General]</c> section contains general configuration
581 information
582 </li>
583 <li>
584 The <c>[Profile]...[/Profile]</c> section defines the policies that the
585 <c>cpufreqd</c> daemon can switch to. The section is very similar to the
586 information you use when manually setting the CPU frequency policy using
587 <c>cpufreq-set</c>.
588 </li>
589 <li>
590 The <c>[Rule]...[/Rule]</c> section is the work-horse of the <c>cpufreqd</c>
591 daemon, defining when the daemon decides to switch to a different profile.
592 </li>
593</ol>
594
595<p>
596Let's take a quick look at an example rule.
597</p>
598
482<pre caption="A sample cpufreqd config file"> 599<pre caption="Sample cpufreqd rule">
483[General]
484pidfile=/var/run/cpufreqd.pid
485poll_interval=2
486pm_type=acpi
487<comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5))
488# acpi_workaround=1</comment>
489verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
490
491<comment># Full performance</comment>
492[Profile] 600[Profile]
493name=ac 601name=On Demand High
494minfreq=600000 602minfreq=40%
495maxfreq=1400000 603maxfreq=100%
496policy=performance 604policy=ondemand
497
498<comment># Maximum power saving</comment>
499[Profile] 605[/Profile]
500name=battery
501minfreq=600000
502maxfreq=900000
503policy=powersave
504 606
505<comment># Constant frequency</comment>
506[Profile]
507name=dvd
508minfreq=900000
509maxfreq=1100000
510policy=powersave
511
512<comment># Full performance when running on AC</comment>
513[Rule] 607[Rule]
514name=ac_on 608name=AC Off - High Power
515ac=on
516profile=ac
517
518<comment># Compiling should be fast if battery state is ok</comment>
519[Rule]
520name=compiling
521ac=off 609ac=off
522battery_interval=30-100
523programs=emerge,make,gcc,cpp
524cpu_interval=0-100
525profile=ac
526
527<comment># watching DVD's gets sluggish with slow CPU frequency
528# Can also be used for games etc.</comment>
529[Rule]
530name=dvd_watching
531ac=off
532battery_interval=15-100
533programs=xine,mplayer,avidemux,kaffeine,kmplayer
534cpu_interval=0-100
535profile=dvd
536
537<comment># If above doesn't apply, maximise power saving</comment>
538[Rule]
539name=battery_on
540ac=off
541battery_interval=0-100 610battery_interval=70-100
542cpu_interval=0-100 611profile=On Demand High
543profile=battery 612[/Rule]
544</pre> 613</pre>
545 614
546<p>
547<c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
548<c>speedfreq</c>.
549</p> 615<p>
550 616In the above example, <c>cpufreqd</c> will switch the system to the <e>On Demand
617High</e> profile (also shown in the above excerpt). This profile by itself uses
618the <c>ondemand</c> governor with a minimum frequency of 40% (iow, a CPU of 2Ghz
619will have by this policy a minimum frequency of 800Mhz).
551<p> 620</p>
552The last thing to check is that your new policies do a good job. An easy way to 621
553do so is monitoring the CPU speed while working with your laptop:
554</p> 622<p>
555 623As you can see, the <c>cpufreqd</c> application can offer a more granular
556<pre caption="Monitoring CPU speed"> 624approach on CPU frequency scaling. But not only that, you can tweak the CPU
557# <i>watch -n 1 grep "cpu MHz" /proc/cpuinfo</i> 625frequency scaling based on various other metrics available. The default
558</pre> 626configuration offers a sample rule for when you watch a movie, where you want
559 627maximum performance, unless the CPU temperature is getting too high.
560<p> 628</p>
561If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU 629
562frequency with:
563</p> 630<p>
564 631When you have configured <c>cpufreqd</c>, it is time to start it (and make sure
565<pre caption="Alternative CPU speed monitoring"> 632the service is loaded automatically). Make sure that CPU frequency handling by
566# <i>watch -n 1 x86info -mhz</i> 633other tools (like <c>laptop-mode-tools</c>) is disabled!
567</pre>
568
569<p> 634</p>
570Depending on your setup, CPU speed should increase on heavy load, decrease on 635
571no activity or just stay at the same level. 636<pre caption="Starting cpufreqd">
637# <i>rc-service add cpufreqd default</i>
638# <i>/etc/init.d/cpufreqd start</i>
572</p> 639</pre>
573 640
574</body> 641</body>
575</section> 642</section>
576</chapter> 643</chapter>
577 644
578<chapter> 645<chapter>
579<title>LCD Power Management</title> 646<title>Resources</title>
580<section>
581<title>Energy consumer no. 1</title>
582<body>
583
584<p>
585As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display
586consumes the biggest part of energy (might not be the case for non-mobile
587CPU's). Thus it's quite important not only to shut the display off when not
588needed, but also to reduce it's backlight if possible. Most laptops offer the
589possibility to control the backlight dimming.
590</p>
591
592<p>
593First thing to check is the standby/suspend/off timings of the display. As this
594depends heavily on your windowmanager, I'll let you figure it out yourself.
595Just two common places: Blanking the terminal can be done with <c>setterm
596-blank &lt;number-of-minutesM&gt;</c>, <c>setterm -powersave on</c> and
597<c>setterm -powerdown &lt;number-of-minutesM&gt;</c>.
598For Xorg, modify <path>/etc/X11/xorg.conf</path> similar to this:
599</p>
600
601<pre caption="LCD suspend settings in Xorg and XFree86">
602Section "ServerLayout"
603 Identifier [...]
604 [...]
605 Option "BlankTime" "5" <comment># Blank the screen after 5 minutes (Fake)</comment>
606 Option "StandbyTime" "10" <comment># Turn off screen after 10 minutes (DPMS)</comment>
607 Option "SuspendTime" "20" <comment># Full suspend after 20 minutes</comment>
608 Option "OffTime" "30" <comment># Turn off after half an hour</comment>
609 [...]
610EndSection
611
612[...]
613
614Section "Monitor"
615 Identifier [...]
616 Option "DPMS" "true"
617 [...]
618EndSection
619</pre>
620
621<p>
622This is the same for XFree86 and <path>/etc/X11/XF86Config</path>.
623</p>
624
625<p>
626Probably more important is the backlight dimming. If you have access to the
627dimming settings via a tool, write a small script that dims the backlight in
628battery mode and place it in your <e>battery</e> runlevel.
629</p>
630
631</body>
632</section> 647<section>
633</chapter> 648<title>Tools</title>
634
635<chapter>
636<title>Disk Power Management</title>
637<section>
638<title>Sleep when idle</title>
639<body>
640
641<p>
642Let's bring the hard disk to sleep as early as possible whenever it is not
643needed. I'll show you two possibilities to do it. First <c>cpudyn</c> supports
644Disk Power Management. Uncomment the lines in the "Disk Options" section in
645<path>/etc/conf.d/cpudyn</path>. To put your first disk to sleep after 60
646seconds of no activity, you would modify it like this:
647</p>
648
649<pre caption="Using cpudyn for disk standby">
650<comment>################################################
651# DISK OPTIONS
652# (disabled by default)
653################################################
654
655#
656# Timeout to put the disk in standby mode if there was no
657# io during that period (in seconds)
658#
659</comment>
660TIMEOUT=60
661<comment>
662#
663# Specified disks to spindown (comma separated devices)
664#
665</comment>
666DISKS=/dev/hda
667</pre>
668
669<p>
670The second possibility is using a small script and hdparm. Create
671<path>/etc/init.d/pm.hda</path> like this:
672</p>
673
674<pre caption="Using hdparm for disk standby">
675#!/sbin/runscript
676start() {
677 ebegin "Activating Power Management for Hard Drives"
678 hdparm -q -S12 /dev/hda
679 eend $?
680}
681
682stop () {
683 ebegin "Deactivating Power Management for Hard Drives"
684 hdparm -q -S253 /dev/hda
685 eend $?
686}
687</pre>
688
689<p>
690See <c>man hdparm</c> for the options. If your script is ready, add it to the
691battery runlevel.
692</p>
693
694<pre caption="Automate disk standby settings">
695# <i>/sbin/depscan.sh</i>
696# <i>rc-update add pm.hda battery</i>
697</pre>
698
699<impo>
700Be careful with sleep/spin down settings of your hard drive. Setting it to
701small values might wear out your drive and lose warranty.
702</impo>
703
704</body> 649<body>
705</section>
706<section>
707<title>Increasing idle time - laptop-mode</title>
708<body>
709 650
710<p>
711Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches)
712include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
713written to disk on read calls or after 10 minutes (instead of 30 seconds). This
714minimizes the time the hard disk needs to be spun up.
715</p>
716
717<p>
718<!-- FIXME: bug #45593 -->
719To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can
720take the one included in
721<path>/usr/src/linux/Documentation/laptop-mode.txt</path>. Onces it's ready,
722make sure it gets called.
723</p>
724
725<pre caption="Automatic start of laptop-mode">
726# <i>rc-update add laptop-mode battery</i>
727</pre>
728
729<warn>
730Once again: Be careful with sleep/spin down settings of your hard drive.
731Setting it to small values might wear out your drive and lose warranty. Be sure
732to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode
733before your battery runs out of power and data gets written to disk - otherwise
734you will at least lose the last 10 minutes of your work.
735</warn>
736
737</body>
738</section>
739<section>
740<title>Other tricks</title>
741<body>
742
743<p>
744Besides putting your disk to sleep state as early as possible, it is a good
745idea to minimize disk accesses. Have a look at processes that write to your
746disk frequently - the syslogd is a good candidate. You probably don't want to
747shut it down completely, but it's possible to modify the config file so that
748"unnecessary" things don't get logged and thus don't create disk traffic. Cups
749writes to disk periodically, so consider shutting it down and only enable it
750manually when needed.
751</p>
752
753<pre caption="Disabling cups in battery mode">
754# <i>rc-update del cupsd battery</i>
755</pre>
756
757<p>
758Another possibility is to deactivate swap in battery mode. Before writing a
759swapon/swapoff switcher, make sure there is enough RAM and swap isn't used
760heavily, otherwise you'll be in big problems.
761</p>
762
763<p>
764If you don't want to use laptop-mode, it's still possible to minimize disk
765access by mounting certain directories as <e>tmpfs</e> - write accesses are not
766stored on a disk, but in main memory and get lost with unmounting. Often it's
767useful to mount <path>/tmp</path> like this - you don't have to pay special
768attention as it gets cleared on every reboot regardless whether it was mounted
769on disk or in RAM. Just make sure you have enough RAM and no program (like a
770download client or compress utility) needs extraordinary much space in
771<path>/tmp</path>. To activate this, enable tmpfs support in your kernel and
772add a line to <path>/etc/fstab</path> like this:
773</p>
774
775<pre caption="Editing /etc/fstab to make /tmp even more volatile">
776none /tmp tmpfs size=32m 0 0
777</pre>
778
779<warn>
780Pay attention to the size parameter and modify it for your system. If you're
781unsure, don't try this at all, it can become a perfomance bottleneck easily. In
782case you want to mount <path>/var/log</path> like this, make sure to merge the
783log files to disk before unmounting. They are essential. Don't attempt to mount
784/var/tmp like this. Portage uses it for compiling...
785</warn>
786
787</body>
788</section>
789</chapter>
790
791<chapter>
792<title>Power Management for other devices</title>
793<section>
794<title>Wireless Power Management</title>
795<body>
796
797<p>
798Wireless LAN cards consume quite a few energy. Put them in Power Management
799mode in analogy to the pm.hda script.
800</p>
801
802<pre caption="WLAN Power Management automated">
803#!/sbin/runscript
804start() {
805 ebegin "Activating Power Management for Wireless LAN"
806 iwconfig wlan0 power on power max period 3
807 eend $?
808}
809
810stop () {
811 ebegin "Deactivating Power Management for Wireless LAN"
812 iwconfig wlan0 power off
813 eend $?
814}
815</pre>
816
817<p>
818Starting this script will put wlan0 in Power Management mode, going to sleep at
819the latest three seconds after no traffic.
820Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel
821like the disk script above. See <c>man iwconfig</c> for details and more
822options. If your driver and access point support changing the beacon time, this
823is a good starting point to save even more energy.
824</p>
825
826</body>
827</section>
828<section>
829<title>USB Power Management</title>
830<body>
831
832<p>
833There are two problems with USB devices regarding energy consumption: First,
834devices like USB mice, digital cameras or USB sticks consume energy while
835plugged in. You cannot avoid this (nevertheless remove them in case they're not
836needed). Second, when there are USB devices plugged in, the USB host controller
837periodically accesses the bus which in turn prevents the CPU from going into
838C3/4 sleep mode. The OS answer to this problem is the so called "USB selective
839suspend", which has not yet been implemented in the kernel. USB selective
840suspend only allows bus accesses in case the device is in use. The cruel
841workaround until it's implemented is as following: Compile USB support and
842devices as modules and remove them via a script while they are not in use (e.g.
843when closing the lid).
844</p>
845
846</body>
847</section>
848</chapter>
849
850<chapter>
851<title>Sleep states: sleep, standby, suspend to disk</title>
852<section>
853<title>Overview</title>
854<body>
855
856<p>
857ACPI defines different sleep states. The more important ones are
858</p>
859
860<ul> 651<ul>
861 <li>S1 aka Standby</li> 652 <li>
862 <li>S3 aka Suspend to RAM aka Sleep</li> 653 <uri link="http://samwel.tk/laptop_mode/">Laptop Mode Tools Homepage</uri>,
863 <li>S4 aka Suspend to Disk aka Hibernate</li> 654 includes <uri link="http://samwel.tk/laptop_mode/laptop_mode">About laptop
655 mode</uri>.
656 </li>
657 <li>
658 <uri link="http://www.lesswatts.org/projects/powertop/">PowerTOP</uri>, an
659 interactive application helping users to find out which processes are
660 forcing wakeups on the CPU most often.
661 </li>
864</ul> 662</ul>
865 663
866<p>
867They can be called whenever the system is not in use, but a shutdown is not
868wanted due to the long boot time.
869</p>
870
871</body> 664</body>
872</section>
873<section> 665</section>
874<title>Sleep, Standby &amp; Hibernate</title>
875<body>
876
877<p>
878The ACPI support for these sleep states is marked as experimental for good
879reason. APM sleep states seem to be more stable, however you can't use APM and
880ACPI together.
881</p>
882
883<warn>
884Altough sleep state support is improving much, it's still rather experimental.
885At last I got swsusp2 and suspend to RAM to work, but be warned: This will very
886likely not work but damage your data/system.
887</warn>
888
889<p>
890There are currently three implementations for S4. The original one is swsusp,
891then there is swsusp2 which has the nicest interface (including bootsplash
892support), but requires manual kernel patching. Last not least we have
893Suspend-to-Disk, a fork of swsusp.
894</p>
895
896<p>
897If this confused you, have a look at a <uri
898link="http://softwaresuspend.berlios.de/features.html#compare">feature
899comparison</uri>. If you still are confused and don't know which one to choose,
900first give swsusp2 a try, it looks most promising.
901</p>
902
903<p>
904The kernel part for this is as following:
905</p>
906
907<pre caption="Kernel configuration for the various suspend types">
908Power Management Options ---&gt;
909
910 <comment>(sleep and standby)</comment>
911 ACPI( Advanced Configuration and Power Interface ) Support --->
912 [*] ACPI Support
913 [*] Sleep States
914
915 <comment>(hibernate with swsusp)</comment>
916 [*] Software Suspend (EXPERIMENTAL)
917
918 <comment>(hibernate with swsusp2)</comment>
919 Software Suspend 2
920 --- Image Storage (you need at least one writer)
921 [*] Swap Writer
922 --- Page Transformers
923 [*] LZF image compression
924 (/dev/"your-swap-here") Default resume device name
925
926 <comment>(hibernate with Suspend-to-Disk)</comment>
927 [*] Suspend-to-Disk Suport
928 (/dev/"your-swap-here") Default resume partition
929</pre>
930
931<p>
932Compile your kernel with the appropriate options enabled and issue <c>cat
933/proc/acpi/sleep</c> for 2.4 series respectively <c>cat /sys/power/state</c>
934for 2.6 to find out what is supported. The latter gives me <c>standby mem
935disk</c>. For swsusp, the kernel parameter <c>resume=/dev/"your-swap-here"</c>
936has to be appended. If booting is not possible due to a broken image, use
937<c>noresume</c> for swsusp, <c>pmdisk=off</c> for Suspend-to-Disk and
938<c>noresume2</c> for swsusp2.
939</p>
940
941<p>
942To put your system in one of the sleep states, use
943</p>
944
945<pre caption="Activating sleep states">
946<comment>(kernel 2.4 series)</comment>
947# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
948# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
949
950<comment>(kernel 2.6 series)</comment>
951# <i>echo -n standby &gt; /sys/power/state</i> <comment>standby</comment>
952# <i>echo -n mem &gt; /sys/power/state</i> <comment>sleep</comment>
953
954<comment>(swsusp)</comment>
955# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>hibernate</comment>
956
957<comment>(Suspend-to-Disk)</comment>
958# <i>echo -n disk &gt; /sys/power/state</i> <comment>hibernate</comment>
959
960<comment>(swsusp2)</comment>
961# <i>echo &gt; /proc/swsusp/activate</i>
962</pre>
963
964<warn>
965Backup your data before doing this. Run <c>sync</c> before executing one of the
966commands to have cached data written to disk. First try it outside of X, then
967with X running, but not logged in.
968</warn>
969
970<p>
971If you experience kernel panics due to uhci or similar, try to compile USB
972support as module and unload the modules before sending your laptop to sleep
973mode.
974</p>
975
976<p>
977While the above should be sufficient to get swsusp and Suspend-to-Disk running
978(I didn't say working), swsusp2 needs special care.
979The first thing to do is to patch the kernel with the patches provided at <uri
980link="http://softwaresuspend.berlios.de/">
981http://softwaresuspend.berlios.de/</uri>. Afterwards, install the hibernate
982script from the same page.
983</p>
984
985</body>
986</section> 666<section>
987</chapter> 667<title>Articles and Guides</title>
988
989<chapter>
990<title>Troubleshooting</title>
991<section>
992<title>If things go wrong...</title>
993<body> 668<body>
994 669
995<p> 670<ul>
996<e>Q:</e> I'm trying to change the CPU frequency, but 671 <li>
997<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor</path> does not 672 A ThinkWiki article on <uri
998exist. 673 link="http://www.thinkwiki.org/wiki/How_to_reduce_power_consumption">How to
999</p> 674 reduce power consumption</uri> (on Linux). This article offers an exhaustive
1000 675 list of measures one can take. However, it should be noted that the laptop
1001<p> 676 mode tools implements the majority of these (if properly configured).
1002<e>A:</e> Make sure your processor supports CPU frequency scaling and you chose 677 </li>
1003the right CPUFreq driver for your processor. Here is a list of processors that 678</ul>
1004are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100,
1005ARM-SA1110, AMD Elan - SC400, SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD
1006mobile Duron, AMD mobile Athlon, AMD Opteron, AMD Athlon 64, Cyrix Media GXm,
1007Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4,
1008Intel Xeon, Intel Pentium M (Centrino), National Semiconductors Geode GX,
1009Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH SH-3, SH-4, several
1010"PowerBook" and "iBook2" and various processors on some ACPI 2.0-compatible
1011systems (only if "ACPI Processor Performance States" are available to the
1012ACPI/BIOS interface).
1013</p>
1014
1015<p>
1016<e>Q:</e> My laptop supports frequency scaling, but
1017<path>/sys/devices/system/cpu/cpu0/cpufreq/</path> is empty.
1018</p>
1019
1020<p>
1021<e>A:</e> Look for ACPI related error messages with <c>dmesg | grep ACPI</c>.
1022Try to update the BIOS, especially if a broken DSDT is reported. You can also
1023try to fix it yourself (which is beyond the scope of this guide).
1024</p>
1025
1026<p>
1027<e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo
1028the speed never changes.
1029</p>
1030
1031<p>
1032<e>A:</e> This seems to be a kernel bug. Run <c>emerge x86info</c>, update your
1033kernel as asked and check the current frequency with <c>x86info -mhz</c>.
1034</p>
1035
1036<p>
1037<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1038another OS.
1039</p>
1040
1041<p>
1042<e>A:</e> You can combine frequency scaling with ACPI throttling to get a lower
1043minimum frequency. Notice that throttling doesn't save much energy and is
1044mainly used for thermal management (keeping your laptop cool and quiet). You
1045can read the current throttling state with <c>cat
1046/proc/acpi/processor/CPU/throttling</c> and change it with <c>echo -n "0:x" >
1047/proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in
1048<path>/proc/acpi/processor/CPU/throttling</path>.
1049</p>
1050
1051<p>
1052<e>Q:</e> Battery life time seems to be worse than before.
1053</p>
1054
1055<p>
1056<e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
1057settings.
1058</p>
1059
1060<p>
1061<e>Q:</e> My battery is charged, but KDE reports there would be 0% left and
1062immediately shuts down.
1063</p>
1064
1065<p>
1066<e>A:</e> Check that battery support is compiled into your kernel. If you use
1067it as a module, make sure the module is loaded.
1068</p>
1069
1070<p>
1071<e>Q:</e> I have a Dell Inspiron 51XX and I don't get any ACPI events.
1072</p>
1073
1074<p>
1075<e>A:</e> This seems to be a kernel bug. Read on <uri
1076link="http://bugme.osdl.org/show_bug.cgi?id=1752">here</uri>.
1077</p>
1078
1079<p>
1080<e>Q:</e> I just bought a brand new battery, but it only lasts for some
1081minutes! What am I doing wrong?
1082</p>
1083
1084<p>
1085<e>A:</e> First follow your manufacturer's advice on how to charge the battery
1086correctly.
1087</p>
1088
1089<p>
1090<e>Q:</e> The above didn't help. What should I do then?
1091</p>
1092
1093<p>
1094<e>A:</e> Some batteries sold as "new" are in fact old ones. Try the following:
1095</p>
1096
1097<pre caption="Querying battery state">
1098$ <i>grep capacity /proc/acpi/battery/BAT0/info</i>
1099design capacity: 47520 mWh
1100last full capacity: 41830 mWh
1101</pre>
1102
1103<p>
1104If the "last full capacity" differs significantly from the design capacity,
1105your battery is probably broken. Try to claim your warranty.
1106</p>
1107 679
1108</body> 680</body>
1109</section> 681</section>
1110</chapter> 682</chapter>
1111</guide> 683</guide>

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.20