/[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.1 Revision 1.13
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.13 2005/05/28 12:59:36 yoswink Exp $ -->
3<guide link="power-management-guide.xml"> 4<guide link="power-management-guide.xml">
4<title>Power Management Guide</title> 5<title>Power Management Guide</title>
5 6
6<author> 7<author title="Author">
7 <mail link="fragfred@gmx.de">Dennis Nienh&#252;ser</mail> 8 <mail link="fragfred@gmx.de">Dennis Nienh├╝ser</mail>
8</author> 9</author>
9 10
10<abstract> 11<abstract>
11Power Management is the key to extend battery run time on mobile systems like 12Power Management is the key to extend battery run time on mobile systems like
12laptops. This guide assists you setting it up on your laptop. 13laptops. This guide assists you setting it up on your laptop.
14 15
15<!-- The content of this document is licensed under the CC-BY-SA license --> 16<!-- The content of this document is licensed under the CC-BY-SA license -->
16<!-- See http://creativecommons.org/licenses/by-sa/2.0 --> 17<!-- See http://creativecommons.org/licenses/by-sa/2.0 -->
17<license/> 18<license/>
18 19
19<version>1.15</version> 20<version>1.23</version>
20<date>August 29, 2004</date> 21<date>2005-05-28</date>
21 22
22<chapter> 23<chapter>
23<title>Introduction</title> 24<title>Introduction</title>
24
25<section> 25<section>
26<title>Why Power Management?</title> 26<title>Why Power Management?</title>
27
28<body> 27<body>
29 28
30<p> 29<p>
31Capacity and lifetime of laptop batteries has improved much in the last years. 30Capacity and lifetime of laptop batteries has improved much in the last years.
32Nevertheless modern processors consume much more energy than older ones and 31Nevertheless modern processors consume much more energy than older ones and
76 75
77<section> 76<section>
78<title>Power Budget for each component</title> 77<title>Power Budget for each component</title>
79<body> 78<body>
80 79
81<figure link="images/energy-budget.png" short="Which component consumes how 80<figure link="/images/energy-budget.png" short="Which component consumes how
82much energy?" caption="Power budget for each component"/> 81much energy?" caption="Power budget for each component"/>
83 82
84<p> 83<p>
85Nearly every component can operate in different states - off, sleep, idle, 84Nearly every component can operate in different states - off, sleep, idle,
86active to name a few - consuming a different amount of energy. Major parts are 85active to name a few - consuming a different amount of energy. Major parts are
146 [ ] Suspend-to-Disk Support 145 [ ] Suspend-to-Disk Support
147 146
148 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 147 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
149 [*] ACPI Support 148 [*] ACPI Support
150 [ ] Sleep States 149 [ ] Sleep States
151 &lt;M&gt; AC Adapter 150 [*] AC Adapter
152 &lt;M&gt; Battery 151 [*] Battery
153 &lt;M&gt; Button 152 &lt;M&gt; Button
154 &lt;M&gt; Fan 153 &lt;M&gt; Fan
155 &lt;M&gt; Processor 154 &lt;M&gt; Processor
156 &lt;M&gt; Thermal Zone 155 &lt;M&gt; Thermal Zone
157 &lt; &gt; ASUS/Medion Laptop Extras 156 &lt; &gt; ASUS/Medion Laptop Extras
161 CPU Frequency Scaling ---&gt; 160 CPU Frequency Scaling ---&gt;
162 [*] CPU Frequency scaling 161 [*] CPU Frequency scaling
163 Default CPUFreq governor (userspace) 162 Default CPUFreq governor (userspace)
164 &lt;*&gt; 'performance' governor 163 &lt;*&gt; 'performance' governor
165 &lt;*&gt; 'powersave' governor 164 &lt;*&gt; 'powersave' governor
165 &lt;*&gt; 'ondemand' cpufreq policy governor
166 &lt;*&gt; CPU frequency table helpers 166 &lt;*&gt; CPU frequency table helpers
167 &lt;M&gt; ACPI Processor P-States driver 167 &lt;M&gt; ACPI Processor P-States driver
168 &lt;*&gt; <i>CPUFreq driver for your processor</i> 168 &lt;*&gt; <i>CPUFreq driver for your processor</i>
169</pre> 169</pre>
170 170
171<p> 171<p>
172Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk 172Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and
173and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, 173Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable
174enable the appropriate section. 174the appropriate section.
175</p>
176
177<p>
178The kernel has to know how to enable CPU frequency scaling on your processor. As
179each type of CPU has a different interface, you've got to choose the right
180driver for your processor. Be careful here - enabling <e>Intel Pentium 4 clock
181modulation</e> on a Pentium M system will lead to strange results for example.
182Consult the kernel documentation if you're unsure which one to take.
175</p> 183</p>
176 184
177<p> 185<p>
178Compile your kernel, make sure the right modules get loaded at startup and boot 186Compile your kernel, make sure the right modules get loaded at startup and boot
179into your new ACPI-enabled kernel. Next run <c>emerge sys-apps/acpid</c> to get 187into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get
180the acpi daemon. This one informs you about events like switching from AC to 188the acpi daemon. This one informs you about events like switching from AC to
181battery or closing the lid. Make sure the module <e>button</e> is loaded if you 189battery or closing the lid. Make sure the modules are loaded if you didn't
182didn't compile it into the kernel and start acpid with <c>/etc/init.d/acpid 190compile them into the kernel and start acpid by executing
183start</c>. Run <c>rc-update add acpid default</c> to load it on startup. You'll 191<c>/etc/init.d/acpid start</c>. Run <c>rc-update add acpid default</c> to load
184soon see how to use it. 192it on startup. You'll soon see how to use it.
185</p> 193</p>
186 194
187<pre caption="Installing acpid"> 195<pre caption="Installing acpid">
188# <i>emerge sys-apps/acpid</i> 196# <i>emerge sys-power/acpid</i>
189# <i>modprobe button</i>
190# <i>/etc/init.d/acpid start</i> 197# <i>/etc/init.d/acpid start</i>
191# <i>rc-update add acpid default</i> 198# <i>rc-update add acpid default</i>
192</pre> 199</pre>
193 200
194</body> 201</body>
227<title>Reacting on ACPI events</title> 234<title>Reacting on ACPI events</title>
228<body> 235<body>
229 236
230<p> 237<p>
231Typical ACPI events are closing the lid, changing the power source or pressing 238Typical ACPI events are closing the lid, changing the power source or pressing
232the sleep button. Every acpi event recognized by the kernel is catched by acpid 239the sleep button. An important event is changing the power source, which should
233which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification 240cause a runlevel switch. Create the following files to switch between
234supporting runlevel switching: 241<e>default</e> and <e>battery</e> runlevel depending on the power source:
235</p> 242</p>
236 243
237<pre caption="Event driven runlevel switching with acpid"> 244<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
238#!/bin/sh 245#!/bin/bash
239 246
240set $* 247<comment># BEGIN configuration</comment>
241
242group=${1/\/*/}
243action=${1/*\//}
244
245<comment># runlevel to use in AC mode</comment>
246RLVL_AC="default" 248RUNLEVEL_AC="default"
247<comment># runlevel to use in battery mode</comment>
248RLVL_BATTERY="battery" 249RUNLEVEL_BATTERY="battery"
250<comment># END configuration</comment>
249 251
250<comment># file indicating the AC state</comment>
251AC_STATE="/proc/acpi/ac_adapter/AC/state"
252<comment># this string means running on AC</comment>
253AC_ON="on-line"
254<comment># this string means running on batteries</comment>
255AC_OFF="off-line"
256 252
257function SwitchRunlevel() { 253if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
258 if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]] 254then
255 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
256 exit 1
257fi
258
259if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
260then
261 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
262 exit 1
263fi
264
265if on_ac_power
266then
267 if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
259 then 268 then
269 logger "Switching to ${RUNLEVEL_AC} runlevel"
270 /sbin/rc ${RUNLEVEL_AC}
271 fi
272elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
273then
260 logger "Switching to ${RLVL_BATTERY} runlevel" 274 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
261 /sbin/rc ${RLVL_BATTERY} 275 /sbin/rc ${RUNLEVEL_BATTERY}
262 elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]] 276fi
263 then 277</pre>
264 logger "Switching to ${RLVL_AC} runlevel"
265 /sbin/rc ${RLVL_AC}
266 fi
267}
268 278
279<pre caption="/etc/acpi/events/pmg_ac_adapter">
280<comment># replace "ac_adapter" below with the event generated on your laptop</comment>
281<comment># See /var/log/acpid</comment>
282event=ac_adapter.*
283action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
284</pre>
269 285
270case "$group" in 286<pre caption="/etc/acpi/events/pmg_battery">
271 battery) 287<comment># replace "battery" below with the event generated on your laptop</comment>
272 case "$action" in 288<comment># See /var/log/acpid</comment>
273 battery) 289event=battery.*
274 SwitchRunlevel 290action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
275 ;; 291</pre>
276 *)
277 logger "ACPI group battery / action $action is not defined"
278 ;;
279 esac
280 ;;
281 292
282 ac_adapter) 293<p>
283 case "$action" in 294Additionally you need the package sys-power/powermgmt-base which contains
284 ac_adapter) 295the <c>on_ac_power</c> utility. The file <path>pmg_switch_runlevel.sh</path>
285 SwitchRunlevel 296must be executable.
286 ;; 297</p>
287 *) 298
288 logger "ACPI group ac_adapter / action $action is not defined" 299<pre caption="Finishing runlevel switching with acpid">
289 ;; 300<i># emerge powermgmt-base</i>
290 esac 301<i># chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</i>
291 ;; 302<i># /etc/init.d/acpid restart</i>
292 *)
293 logger "ACPI group $group / action $action is not defined"
294 ;;
295esac
296</pre> 303</pre>
297 304
298<p> 305<p>
299Give it a try: Plug AC in and out and watch syslog for the "Switching to AC 306Give it a try: Plug AC in and out and watch syslog for the "Switching to AC
300mode" or "Switching to battery mode" messages. 307mode" or "Switching to battery mode" messages. See the Troubleshooting
308section if the script is not able to detect the power source correctly.
301</p> 309</p>
302 310
303<p> 311<p>
304Due to the nature of the event mechanism, your laptop will boot into runlevel 312Due to the nature of the event mechanism, your laptop will boot into runlevel
305<e>default</e> regardless of the AC/battery state. You can add another entry 313<e>default</e> regardless of the AC/battery state. You can add another entry
306to the boot loader with <c>softlevel=boot</c>, but it's likely to forget 314to the boot loader with <c>softlevel=battery</c>, but it's likely to forget
307choosing it. A better way is faking an ACPI event in the end of the boot 315choosing it. A better way is faking an ACPI event in the end of the boot
308process and let the <path>/etc/acpi/default.sh</path> script decide whether a 316process and let the <path>/etc/acpi/default.sh</path> script decide whether a
309runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your 317runlevel change is necessary. Open <path>/etc/conf.d/local.start</path> in your
310favourite editor and add these lines: 318favourite editor and add these lines:
311</p> 319</p>
312 320
313<pre caption="Runlevel switch at boot time by editing local.start"> 321<pre caption="Runlevel switch at boot time by editing local.start">
314<comment># Fake acpi event to switch runlevel if running on batteries</comment> 322<comment># Fake acpi event to switch runlevel if running on batteries</comment>
315/etc/acpi/default.sh "battery/battery" 323/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
316</pre> 324</pre>
317 325
318<p> 326<p>
319Prepared like this you can activate Power Management policies for individual 327Prepared like this you can activate Power Management policies for individual
320devices. 328devices.
324</section> 332</section>
325</chapter> 333</chapter>
326 334
327<chapter> 335<chapter>
328<title>CPU Power Management</title> 336<title>CPU Power Management</title>
337<section>
338<title>Some technical terms</title>
339<body>
340
341<p>
342CPU frequency scaling brings up some technical terms that might be unknown to
343you. Here's a quick introduction.
344</p>
345
346<p>
347First of all, the kernel has to be able to change the processor's frequency. The
348<e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus
349it's important to choose the right one in your kernel. You should already have
350done it above. Once the kernel knows how to change frequencies, it has to know
351which frequency it should set. This is done according to the <e>policy</e> which
352consists of a <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are
353just two numbers which define a range the frequency has to stay between -
354minimal and maximal frequency. The governor now decides which of the available
355frequencies in between minimal and maximal frequency to choose. For example, the
356<e>powersave governor</e> always chooses the lowest frequency available, the
357<e>performance governor</e> the highest one. The <e>userspace governor</e> makes
358no decision but chooses whatever the user (or a program in userspace) wants -
359which means it reads the frequency from
360<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
361</p>
362
363<p>
364This doesn't sound like dynamic frequency changes yet and in fact it isn't.
365Dynamics however can be accomplished with various approaches. For example,
366the <e>ondemand governor</e> makes its decisions depending on the current CPU
367load. The same is done by various userland tools like <c>cpudyn</c>,
368<c>cpufreqd</c>, <c>powernowd</c> and many more. ACPI events can be used to
369enable or disable dynamic frequency changes depending on power source.
370</p>
371
372</body>
373</section>
329<section> 374<section>
330<title>Setting the frequency manually</title> 375<title>Setting the frequency manually</title>
331<body> 376<body>
332 377
333<p> 378<p>
343of supported processors in the <e>Troubleshooting</e> section to verify your's 388of supported processors in the <e>Troubleshooting</e> section to verify your's
344is supported. 389is supported.
345</note> 390</note>
346 391
347<p> 392<p>
348It's time to test whether CPU frequency changing works. To get comfortable with 393It's time to test whether CPU frequency changing works. Let's install another
349the interface to the kernel, first do some manual speed modifications. To set 394tool which is very handy for debugging purposes: <c>sys-power/cpufrequtils</c>
350another CPU speed, use:
351</p>
352
353<pre caption="Manual CPU speed modifications">
354<comment>(Get current frequency)</comment>
355# <i>cat /proc/cpuinfo | grep "cpu MHz"</i>
356
357<comment>(Lists supported frequencies. This might fail.)</comment>
358# <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i>
359# <i>cat scaling_available_frequencies</i>
360
361<comment>(Change frequency to 1 GHz (1000000 KHz)
362Replace with a frequency your laptop supports.)</comment>
363# <i>echo -n userspace > scaling_governor</i>
364# <i>echo -n 1000000 > scaling_setspeed</i>
365
366<comment>(Verify frequency was changed)</comment>
367# <i>cat /proc/cpuinfo | grep "cpu MHz"</i>
368</pre>
369
370<p> 395</p>
371If you are getting error messages, please refer to the <e>Troubleshooting</e> 396
372chapter in the end of this guide. 397<pre caption="Checking CPU frequency">
398# <i>emerge cpufrequtils</i>
399# <i>cpufreq-info</i>
400</pre>
401
373</p> 402<p>
374 403Here is an example output:
375<p> 404</p>
376You can also write to <path>scaling_max_freq</path> and 405
377<path>scaling_min_freq</path> to set boundaries the frequency should stay in 406<pre caption="Sample output from cpufreq-info">
378between. 407cpufrequtils 0.2: cpufreq-info (C) Dominik Brodowski 2004
408Report errors and bugs to linux@brodo.de, please.
409analyzing CPU 0:
410 driver: centrino
411 CPUs which need to switch frequency at the same time: 0
412 hardware limits: 600 MHz - 1.40 GHz
413 available frequency steps: 600 MHz, 800 MHz, 1000 MHz, 1.20 GHz, 1.40 GHz
414 available cpufreq governors: ondemand, powersave, userspace, performance
415 current policy: frequency should be within 924 MHz and 1.40 GHz.
416 The governor "performance" may decide which speed to use
417 within this range.
418 current CPU frequency is 1.40 GHz (asserted by call to hardware).
419</pre>
420
379</p> 421<p>
380 422Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
381<note> 423Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
382Some kernel seem to be buggy about updating <path>/proc/cpuinfo</path>. If you 424governor and verify the change with <c>cpufreq-info</c>. If it doesn't work as
383don't see any change there, this doesn't neccessarily mean the CPU frequency 425expected, you might find help in the Troubleshooting section in the end of this
384wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your 426guide.
385kernel as asked and check the current frequency with <c>x86info -mhz</c>. 427</p>
386</note>
387 428
388</body> 429</body>
389</section> 430</section>
390<section> 431<section>
391<title>Automated frequency adaption</title> 432<title>Automated frequency adaption</title>
392<body> 433<body>
393 434
394<p> 435<p>
395The above is quite nice, but not doable in daily life. Better let your system 436The above is quite nice, but not doable in daily life. Better let your system
396set the appropriate frequency automatically. A couple of user space programs 437set the appropriate frequency automatically. There are many different approaches
397like to do it for you. The following table gives a quick overview to help you 438to do this. The following table gives a quick overview to help you decide on one
398decide on one of them. 439of them. It's roughly seperated in three categories <e>kernel</e> for approaches
440that only need kernel support, <e>daemon</e> for programs that run in the
441background and <e>graphical</e> for programs that provide a GUI for easy
442configuration and changes.
399</p> 443</p>
400 444
401<table> 445<table>
402<tr> 446<tr>
403 <th>Name</th> 447 <th>Name</th>
404 <th>Pro</th> 448 <th>Category</th>
449 <th>Switch decision</th>
450 <th>Kernel governors</th>
451 <th>Further governors</th>
405 <th>Con</th> 452 <th>Comments</th>
453</tr>
454<tr>
455 <ti>'ondemand' governor</ti>
456 <ti>Kernel</ti>
457 <ti>CPU load</ti>
458 <ti>N.A.</ti>
459 <ti>N.A.</ti>
460 <ti>
461 Further tuning through files in
462 <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
463 userland tools (programs, scripts) if governor switching or similar is
464 desired.
465 </ti>
406</tr> 466</tr>
407<tr> 467<tr>
408 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti> 468 <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
409 <ti>Also supports disk standby</ti>
410 <ti></ti> 469 <ti>Daemon</ti>
470 <ti>CPU load</ti>
471 <ti>Performance, powersave</ti>
472 <ti>Dynamic</ti>
473 <ti>
474 Also supports disk standby - notice however that <e>laptop mode</e> in most
475 cases will do a better job.
476 </ti>
411</tr> 477</tr>
412<tr> 478<tr>
413 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti> 479 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
414 <ti>Sophisticated setup possible</ti> 480 <ti>Daemon</ti>
415 <ti>Complicated setup</ti> 481 <ti>Battery state, CPU load, running programs</ti>
482 <ti>All available</ti>
483 <ti>None</ti>
484 <ti>
485 Sophisticated (but also complicated) setup.
486 </ti>
487</tr>
488<tr>
489 <ti>
490 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
491 </ti>
492 <ti>Daemon</ti>
493 <ti>CPU load</ti>
494 <ti>None</ti>
495 <ti>Passive, sine, aggressive</ti>
496 <ti>
497 Supports SMP.
498 </ti>
416</tr> 499</tr>
417<tr> 500<tr>
418 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti> 501 <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
502 <ti>Daemon</ti>
503 <ti>CPU load</ti>
504 <ti>None</ti>
505 <ti>Dynamic, powersave, performance, fixed speed</ti>
419 <ti> 506 <ti>
420 Small yet powerful<br /> 507 Small yet powerful with an useful client/server interface. Requires a 2.6
421 Useful client/server interface 508 kernel. Doesn't seem to be maintained anymore and will be removed from
509 Portage in the near future.
422 </ti> 510 </ti>
423 <ti>Kernel 2.6 series only</ti>
424</tr> 511</tr>
425<tr> 512<tr>
426 <ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti> 513 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
427 <ti>Supports SMP</ti> 514 <ti>Graphical</ti>
428 <ti></ti> 515 <ti>None</ti>
516 <ti>None</ti>
517 <ti>None</ti>
518 <ti>
519 Gnome application, a graphical tool to set CPU frequency manually. It does
520 not offer any automation.
521 </ti>
522</tr>
523<tr>
524 <ti>klaptopdaemon</ti>
525 <ti>Graphical</ti>
526 <ti>Battery state</ti>
527 <ti>All available</ti>
528 <ti>None</ti>
529 <ti>
530 KDE only, 'ondemand' governor required for dynamic frequency scaling.
531 </ti>
429</tr> 532</tr>
430</table> 533</table>
431 534
432<p> 535<p>
433While adjusting the frequency to the current load looks simple on the first 536While adjusting the frequency to the current load looks simple on the first
435two frequencies all the time or wasting energy when setting frequency to an 538two frequencies all the time or wasting energy when setting frequency to an
436unnecessary high level. 539unnecessary high level.
437</p> 540</p>
438 541
439<p> 542<p>
440Which one to choose? If you have no idea about it, first try <c>speedfreq</c>: 543Which one to choose? If you have no idea about it, try <c>cpufreqd</c>:
441</p>
442
443<pre caption="Installing speedfreq">
444# <i>emerge speedfreq</i>
445# <i>rc-update add speedfreq battery</i>
446</pre>
447
448<p> 544</p>
449<c>speedfreq</c> can be configured by editing
450<path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able
451to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to
452<c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon.
453</p>
454
455<pre caption="Starting speedfreq">
456# <i>/etc/init.d/speedfreq start</i>
457</pre>
458
459<p>
460Setting up cpufreq is a little bit more complicated.
461</p>
462
463<warn>
464Do not run more than one of the above programs at the same time. It may cause
465confusion like switching between two frequencies all the time. If you just
466installed speedfreq, skip cpufreq now.
467</warn>
468 545
469<pre caption="Installing cpufreqd"> 546<pre caption="Installing cpufreqd">
470# <i>emerge cpufreqd</i> 547# <i>emerge cpufreqd</i>
471# <i>rc-update add cpufreqd battery</i>
472</pre> 548</pre>
473 549
474<p>
475<c>cpufreqd</c> comes with a default configuration in
476<path>/etc/cpufreqd.conf</path>.
477Change the config file to fit your needs. The following will save more energy
478than the default one - at the cost of less performance, of course.
479</p> 550<p>
551<c>cpufreqd</c> can be configured by editing <path>/etc/cpufreqd.conf</path>.
552The default one that ships with cpufreqd may look a bit confusing. I recommend
553replacing it with the one from Gentoo developer Henrik Brix Andersen (see
554below).
555</p>
480 556
481<pre caption="A sample cpufreqd config file"> 557<pre caption="/etc/cpufreqd.conf">
482[General] 558[General]
483pidfile=/var/run/cpufreqd.pid 559pidfile=/var/run/cpufreqd.pid
484poll_interval=2 560poll_interval=2
485pm_type=acpi 561pm_type=acpi
486<comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5)) 562verbosity=5
487# acpi_workaround=1</comment>
488verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
489 563
490<comment># Full performance</comment>
491[Profile] 564[Profile]
565name=ondemand
566minfreq=0%
567maxfreq=100%
568policy=ondemand
569
570[Profile]
571name=powersave
572minfreq=0%
573maxfreq=100%
574policy=powersave
575
576[Profile]
577name=performance
578minfreq=0%
579maxfreq=100%
580policy=performance
581
582[Rule]
583name=battery
584ac=off
585profile=ondemand
586
587[Rule]
588name=battery_low
589ac=off
590battery_interval=0-10
591profile=powersave
592
593[Rule]
492name=ac 594name=ac
595ac=on
596profile=performance
597</pre>
598
599<p>
600You can't use a percentage value like above for min_freq and max_freq if you
601are using kernel 2.6 with the sysfs interface (you probably do). Replace it
602with the lowest and highest frequency as reported by <c>cpufreq-info
603--hwlimits</c>. For example, on my 1.4 GHz Pentium M I put in
604</p>
605
606<pre caption="Sample values for minfreq and maxfreq">
493minfreq=600000 607minfreq=600000
494maxfreq=1400000 608maxfreq=1400000
495policy=performance
496
497<comment># Maximum power saving</comment>
498[Profile]
499name=battery
500minfreq=600000
501maxfreq=900000
502policy=powersave
503
504<comment># Constant frequency</comment>
505[Profile]
506name=dvd
507minfreq=900000
508maxfreq=1100000
509policy=powersave
510
511<comment># Full performance when running on AC</comment>
512[Rule]
513name=ac_on
514ac=on
515profile=ac
516
517<comment># Compiling should be fast if battery state is ok</comment>
518[Rule]
519name=compiling
520ac=off
521battery_interval=30-100
522programs=emerge,make,gcc,cpp
523cpu_interval=0-100
524profile=ac
525
526<comment># watching DVD's gets sluggish with slow CPU frequency
527# Can also be used for games etc.</comment>
528[Rule]
529name=dvd_watching
530ac=off
531battery_interval=15-100
532programs=xine,mplayer,avidemux,kaffeine,kmplayer
533cpu_interval=0-100
534profile=dvd
535
536<comment># If above doesn't apply, maximise power saving</comment>
537[Rule]
538name=battery_on
539ac=off
540battery_interval=0-100
541cpu_interval=0-100
542profile=battery
543</pre> 609</pre>
544 610
545<p>
546<c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
547<c>speedfreq</c>.
548</p> 611<p>
612Last not least start the daemon.
613</p>
614
615<pre caption="Starting cpufreqd">
616# <i>rc-update add cpufreqd default battery</i>
617# <i>rc</i>
618</pre>
619
620<warn>
621Do not run more than one of the above programs at the same time. It may cause
622confusion like switching between two frequencies all the time.
623</warn>
624
625</body>
626</section>
627
628<section>
629<title>Verifying the result</title>
630
631<body>
549 632
550<p> 633<p>
551The last thing to check is that your new policies do a good job. An easy way to 634The last thing to check is that your new policies do a good job. An easy way to
552do so is monitoring the CPU speed while working with your laptop: 635do so is monitoring CPU speed while working with your laptop:
553</p> 636</p>
554 637
555<pre caption="Monitoring CPU speed"> 638<pre caption="Monitoring CPU speed">
556# <i>watch -n 1 cat /proc/cpuinfo | grep "cpu MHz"</i> 639# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
557</pre> 640</pre>
558 641
559<p> 642<p>
560If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU 643If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting),
561frequency with: 644monitor the CPU frequency with:
562</p> 645</p>
563 646
564<pre caption="Alternative CPU speed monitoring"> 647<pre caption="Alternative CPU speed monitoring">
565# <i>watch -n 1 x86info -mhz</i> 648# <i>watch x86info -mhz</i>
566</pre> 649</pre>
567 650
568<p> 651<p>
569Depending on your setup, CPU speed should increase on heavy load, decrease on 652Depending on your setup, CPU speed should increase on heavy load, decrease on
570no activity or just stay at the same level. 653no activity or just stay at the same level. When using cpufreqd and verbosity
654set to 5 or higher in <path>cpufreqd.conf</path> you'll get additional
655information about what's happening reported to syslog.
571</p> 656</p>
572 657
573</body> 658</body>
574</section> 659</section>
575</chapter> 660</chapter>
579<section> 664<section>
580<title>Energy consumer no. 1</title> 665<title>Energy consumer no. 1</title>
581<body> 666<body>
582 667
583<p> 668<p>
584As you can see in <uri link="doc_chap1_fig1">figure 1.1</uri>, the LCD display 669As you can see in <uri link="#doc_chap1_fig1">figure 1.1</uri>, the LCD display
585consumes the biggest part of energy (might not be the case for non-mobile 670consumes the biggest part of energy (might not be the case for non-mobile
586CPU's). Thus it's quite important not only to shut the display off when not 671CPU's). Thus it's quite important not only to shut the display off when not
587needed, but also to reduce it's backlight if possible. Most laptops offer the 672needed, but also to reduce it's backlight if possible. Most laptops offer the
588possibility to control the backlight dimming. 673possibility to control the backlight dimming.
589</p> 674</p>
622</p> 707</p>
623 708
624<p> 709<p>
625Probably more important is the backlight dimming. If you have access to the 710Probably more important is the backlight dimming. If you have access to the
626dimming settings via a tool, write a small script that dims the backlight in 711dimming settings via a tool, write a small script that dims the backlight in
627battery mode and place it in your <e>battery</e> runlevel. 712battery mode and place it in your <e>battery</e> runlevel. The following script
713should work on most IBM Thinkpads. It needs the <c>app-laptop/ibm-acpi</c>
714package or the appropriate option in your kernel has to be enabled.
715</p>
716
717<warn>
718Support for setting brightness is marked experimental in ibm-acpi. It accesses
719hardware directly and may cause severe harm to your system. Please read the
720<uri link="http://ibm-acpi.sourceforge.net/">ibm-acpi website</uri>
721</warn>
722
628</p> 723<p>
724To be able to set the brightness level, the ibm_acpi module has to be loaded
725with the experimental parameter.
726</p>
727
728<pre caption="automatically loading the ibm_acpi module">
729<comment>(Please read the warnings above before doing this!)</comment>
730<i># emerge ibm-acpi</i>
731<i># echo "options ibm_acpi experimental=1" >> /etc/modules.d/ibm_acpi</i>
732<i># /sbin/modules-update</i>
733<i># echo ibm_acpi >> /etc/modules.autoload.d/kernel-2.6</i>
734<i># modprobe ibm_acpi</i>
735</pre>
736
737<p>
738This should work without error messages and a file
739<path>/proc/acpi/ibm/brightness</path> should be created after loading the
740module. An init script will take care of choosing the brightness according
741to the power source.
742</p>
743
744<pre caption="/etc/conf.d/lcd-brightness">
745<comment># See /proc/acpi/ibm/brightness for available values</comment>
746<comment># Please read /usr/share/doc/ibm-acpi-*/README.gz</comment>
747
748<comment># brigthness level in ac mode. Default is 7.</comment>
749BRIGHTNESS_AC=7
750
751<comment># brightness level in battery mode. Default is 4.</comment>
752BRIGHTNESS_BATTERY=4
753</pre>
754
755<pre caption="/etc/init.d/lcd-brightness">
756#!/sbin/runscript
757
758set_brightness() {
759 if on_ac_power
760 then
761 LEVEL=${BRIGHTNESS_AC:-7}
762 else
763 LEVEL=${BRIGHTNESS_BATTERY:-4}
764 fi
765
766 if [ -f /proc/acpi/ibm/brightness ]
767 then
768 ebegin "Setting LCD brightness"
769 echo "level ${LEVEL}" > /proc/acpi/ibm/brightness
770 eend $?
771 else
772 ewarn "Setting LCD brightness is not supported."
773 ewarn "Check that ibm_acpi is loaded into the kernel"
774 fi
775}
776
777start() {
778 set_brightness
779}
780
781stop () {
782 set_brightness
783}
784</pre>
785
786<p>
787When done, make sure brightness is adjusted automatically by adding it to the
788battery runlevel.
789</p>
790
791<pre caption="Enabling automatic brightness adjustment">
792<i># chmod +x /etc/init.d/lcd-brightness</i>
793<i># rc-update add lcd-brightness battery</i>
794<i># rc</i>
795</pre>
629 796
630</body> 797</body>
631</section> 798</section>
632</chapter> 799</chapter>
633 800
670<path>/etc/init.d/pm.hda</path> like this: 837<path>/etc/init.d/pm.hda</path> like this:
671</p> 838</p>
672 839
673<pre caption="Using hdparm for disk standby"> 840<pre caption="Using hdparm for disk standby">
674#!/sbin/runscript 841#!/sbin/runscript
842
843depend() {
844 after hdparm
845}
846
675start() { 847start() {
676 ebegin "Activating Power Management for Hard Drives" 848 ebegin "Activating Power Management for Hard Drives"
677 hdparm -q -S12 /dev/hda 849 hdparm -q -S12 /dev/hda
678 eend $? 850 eend $?
679} 851}
689See <c>man hdparm</c> for the options. If your script is ready, add it to the 861See <c>man hdparm</c> for the options. If your script is ready, add it to the
690battery runlevel. 862battery runlevel.
691</p> 863</p>
692 864
693<pre caption="Automate disk standby settings"> 865<pre caption="Automate disk standby settings">
866# <i>chmod +x /etc/init.d/pm.hda</i>
694# <i>/sbin/depscan.sh</i> 867# <i>/sbin/depscan.sh</i>
695# <i>rc-update add pm.hda battery</i> 868# <i>rc-update add pm.hda battery</i>
696</pre> 869</pre>
697 870
698<impo> 871<impo>
711include the so-called <e>laptop-mode</e>. When activated, dirty buffers are 884include the so-called <e>laptop-mode</e>. When activated, dirty buffers are
712written to disk on read calls or after 10 minutes (instead of 30 seconds). This 885written to disk on read calls or after 10 minutes (instead of 30 seconds). This
713minimizes the time the hard disk needs to be spun up. 886minimizes the time the hard disk needs to be spun up.
714</p> 887</p>
715 888
716<p>
717<!-- FIXME: bug #45593 -->
718To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can
719take the one included in
720<path>/usr/src/linux/Documentation/laptop-mode.txt</path>. Onces it's ready,
721make sure it gets called.
722</p>
723
724<pre caption="Automatic start of laptop-mode"> 889<pre caption="Automated start of laptop-mode">
725# <i>rc-update add laptop-mode battery</i> 890# <i>emerge laptop-mode-tools</i>
891</pre>
892
893<p>
894<c>laptop-mode-tools</c> has it's configuration file in
895<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
896it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
897automatically.
726</pre> 898</p>
727
728<warn>
729Once again: Be careful with sleep/spin down settings of your hard drive.
730Setting it to small values might wear out your drive and lose warranty. Be sure
731to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode
732before your battery runs out of power and data gets written to disk - otherwise
733you will at least lose the last 10 minutes of your work.
734</warn>
735 899
736</body> 900</body>
737</section> 901</section>
738<section> 902<section>
739<title>Other tricks</title> 903<title>Other tricks</title>
819Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel 983Save it as <path>/etc/init.d/pm.wlan0</path> and add it to the battery runlevel
820like the disk script above. See <c>man iwconfig</c> for details and more 984like the disk script above. See <c>man iwconfig</c> for details and more
821options. If your driver and access point support changing the beacon time, this 985options. If your driver and access point support changing the beacon time, this
822is a good starting point to save even more energy. 986is a good starting point to save even more energy.
823</p> 987</p>
988
989<pre caption="Power Management for WLAN">
990# <i>chmod +x /etc/init.d/pm.wlan0</i>
991# <i>/sbin/depscan.sh</i>
992# <i>rc-update add pm.wlan0 battery</i>
993</pre>
824 994
825</body> 995</body>
826</section> 996</section>
827<section> 997<section>
828<title>USB Power Management</title> 998<title>USB Power Management</title>
945<comment>(kernel 2.4 series)</comment> 1115<comment>(kernel 2.4 series)</comment>
946# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment> 1116# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
947# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment> 1117# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
948 1118
949<comment>(kernel 2.6 series)</comment> 1119<comment>(kernel 2.6 series)</comment>
950# <i>echo -n standby &gt; /sys/power/state</i> <comment>standby</comment> 1120# <i>echo -n standby &gt; /sys/power/state</i> <comment>(standby)</comment>
951# <i>echo -n mem &gt; /sys/power/state</i> <comment>sleep</comment> 1121# <i>echo -n mem &gt; /sys/power/state</i> <comment>(sleep)</comment>
952 1122
953<comment>(swsusp)</comment> 1123<comment>(swsusp)</comment>
954# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>hibernate</comment> 1124# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>(hibernate)</comment>
955 1125
956<comment>(Suspend-to-Disk)</comment> 1126<comment>(Suspend-to-Disk)</comment>
957# <i>echo -n disk &gt; /sys/power/state</i> <comment>hibernate</comment> 1127# <i>echo -n disk &gt; /sys/power/state</i> <comment>(hibernate)</comment>
958 1128
959<comment>(swsusp2)</comment> 1129<comment>(swsusp2)</comment>
960# <i>echo &gt; /proc/swsusp/activate</i> 1130# <i>/usr/sbin/hibernate</i> <comment>(hibernate, see below)</comment>
961</pre> 1131</pre>
962 1132
963<warn> 1133<warn>
964Backup your data before doing this. Run <c>sync</c> before executing one of the 1134Backup your data before doing this. Run <c>sync</c> before executing one of the
965commands to have cached data written to disk. First try it outside of X, then 1135commands to have cached data written to disk. First try it outside of X, then
973</p> 1143</p>
974 1144
975<p> 1145<p>
976While the above should be sufficient to get swsusp and Suspend-to-Disk running 1146While the above should be sufficient to get swsusp and Suspend-to-Disk running
977(I didn't say working), swsusp2 needs special care. 1147(I didn't say working), swsusp2 needs special care.
978The first thing to do is to patch the kernel with the patches provided at <uri 1148The first thing to do is patching the kernel with the patches provided at <uri
979link="http://softwaresuspend.berlios.de/"> 1149link="http://softwaresuspend.berlios.de/">
980http://softwaresuspend.berlios.de/</uri>. Afterwards, install the hibernate 1150http://softwaresuspend.berlios.de/</uri>. Additionally you've got to emerge
981script from the same page. 1151<c>hibernate-script</c>. Once it is installed, configure
1152<path>/etc/hibernate/hibernate.conf</path> and try whether it works:
1153</p>
1154
1155<pre>
1156<i># emerge hibernate-script</i>
1157<i># $EDITOR /etc/hibernate/hibernate.conf</i>
1158<comment>(Last chance to backup any data)</comment>
1159<i># hibernate</i>
982</p> 1160</pre>
983 1161
984</body> 1162</body>
985</section> 1163</section>
986</chapter> 1164</chapter>
987 1165
1026<e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo 1204<e>Q:</e> My laptop supports frequency scaling, but according to /proc/cpuinfo
1027the speed never changes. 1205the speed never changes.
1028</p> 1206</p>
1029 1207
1030<p> 1208<p>
1031<e>A:</e> This seems to be a kernel bug. Run <c>emerge x86info</c>, update your 1209<e>A:</e> Probably you have activated symmetric multiprocessing support
1210(CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older
1211kernels had a bug causing this. In that case, run <c>emerge x86info</c>,
1032kernel as asked and check the current frequency with <c>x86info -mhz</c>. 1212update your kernel as asked and check the current frequency with
1213<c>x86info -mhz</c>.
1033</p> 1214</p>
1034 1215
1035<p> 1216<p>
1036<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in 1217<e>Q:</e> I can change the CPU frequency, but the range is not as wide as in
1037another OS. 1218another OS.
1046/proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in 1227/proc/acpi/processor/CPU/limit</c>, where x is one of the Tx states listed in
1047<path>/proc/acpi/processor/CPU/throttling</path>. 1228<path>/proc/acpi/processor/CPU/throttling</path>.
1048</p> 1229</p>
1049 1230
1050<p> 1231<p>
1232<e>Q:</e> When configuring the kernel, powersave, performance and userspace
1233governors show up, but that ondemand thing is missing. Where do I get it?
1234</p>
1235
1236<p>
1237<e>A:</e> The ondemand governor is only included in recent kernel sources. Try
1238updating them.
1239</p>
1240
1241<p>
1051<e>Q:</e> Battery life time seems to be worse than before. 1242<e>Q:</e> Battery life time seems to be worse than before.
1052</p> 1243</p>
1053 1244
1054<p> 1245<p>
1055<e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the 1246<e>A:</e> Check your BIOS settings. Maybe you forgot to re-enable some of the
1102<p> 1293<p>
1103If the "last full capacity" differs significantly from the design capacity, 1294If the "last full capacity" differs significantly from the design capacity,
1104your battery is probably broken. Try to claim your warranty. 1295your battery is probably broken. Try to claim your warranty.
1105</p> 1296</p>
1106 1297
1298<p>
1299<e>Q:</e> My problem is not listed above. Where should I go next?
1300</p>
1301
1302<p>
1303<e>A:</e> Don't fear to contact me, <mail link="fragfred@gmx.de">Dennis
1304Nienh├╝ser</mail>, directly.
1305</p>
1306
1107</body> 1307</body>
1108</section> 1308</section>
1109</chapter> 1309</chapter>
1110</guide> 1310</guide>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.20