/[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.11 Revision 1.12
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.11 2005/04/18 19:19:27 dertobi123 Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.12 2005/05/04 16:54:18 neysx Exp $ -->
4<guide link="power-management-guide.xml"> 4<guide link="power-management-guide.xml">
5<title>Power Management Guide</title> 5<title>Power Management Guide</title>
6 6
7<author title="Author"> 7<author title="Author">
8 <mail link="fragfred@gmx.de">Dennis Nienhüser</mail> 8 <mail link="fragfred@gmx.de">Dennis Nienhüser</mail>
15 15
16<!-- 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 -->
17<!-- See http://creativecommons.org/licenses/by-sa/2.0 --> 17<!-- See http://creativecommons.org/licenses/by-sa/2.0 -->
18<license/> 18<license/>
19 19
20<version>1.21</version> 20<version>1.22</version>
21<date>2005-04-18</date> 21<date>2005-05-04</date>
22 22
23<chapter> 23<chapter>
24<title>Introduction</title> 24<title>Introduction</title>
25
26<section> 25<section>
27<title>Why Power Management?</title> 26<title>Why Power Management?</title>
28
29<body> 27<body>
30 28
31<p> 29<p>
32Capacity 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.
33Nevertheless modern processors consume much more energy than older ones and 31Nevertheless modern processors consume much more energy than older ones and
147 [ ] Suspend-to-Disk Support 145 [ ] Suspend-to-Disk Support
148 146
149 ACPI( Advanced Configuration and Power Interface ) Support ---&gt; 147 ACPI( Advanced Configuration and Power Interface ) Support ---&gt;
150 [*] ACPI Support 148 [*] ACPI Support
151 [ ] Sleep States 149 [ ] Sleep States
152 &lt;M&gt; AC Adapter 150 [*] AC Adapter
153 &lt;M&gt; Battery 151 [*] Battery
154 &lt;M&gt; Button 152 &lt;M&gt; Button
155 &lt;M&gt; Fan 153 &lt;M&gt; Fan
156 &lt;M&gt; Processor 154 &lt;M&gt; Processor
157 &lt;M&gt; Thermal Zone 155 &lt;M&gt; Thermal Zone
158 &lt; &gt; ASUS/Medion Laptop Extras 156 &lt; &gt; ASUS/Medion Laptop Extras
171</pre> 169</pre>
172 170
173<p> 171<p>
174Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and 172Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and
175Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable 173Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable
176the appropriate section. Recent kernel versions (2.6.9 and later) include an 174the appropriate section.
177<e>'ondemand' governor</e> for CPU Frequency Scaling, activate it as well when
178using such a kernel.
179</p> 175</p>
180 176
181<p> 177<p>
182The kernel has to know how to enable CPU frequency scaling on your processor. As 178The kernel has to know how to enable CPU frequency scaling on your processor. As
183each type of CPU has a different interface, you've got to choose the right 179each type of CPU has a different interface, you've got to choose the right
188 184
189<p> 185<p>
190Compile 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
191into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get 187into your new ACPI-enabled kernel. Next run <c>emerge sys-power/acpid</c> to get
192the 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
193battery 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
194didn'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
195start</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
196soon see how to use it. 192it on startup. You'll soon see how to use it.
197</p> 193</p>
198 194
199<pre caption="Installing acpid"> 195<pre caption="Installing acpid">
200# <i>emerge sys-power/acpid</i> 196# <i>emerge sys-power/acpid</i>
201# <i>modprobe button</i>
202# <i>/etc/init.d/acpid start</i> 197# <i>/etc/init.d/acpid start</i>
203# <i>rc-update add acpid default</i> 198# <i>rc-update add acpid default</i>
204</pre> 199</pre>
205 200
206</body> 201</body>
244the sleep button. An important event is changing the power source, which should 239the sleep button. An important event is changing the power source, which should
245cause a runlevel switch. Create the following files to switch between 240cause a runlevel switch. Create the following files to switch between
246<e>default</e> and <e>battery</e> runlevel depending on the power source: 241<e>default</e> and <e>battery</e> runlevel depending on the power source:
247</p> 242</p>
248 243
249<pre caption="/etc/acpi/switch_runlevel.sh"> 244<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
250#!/bin/bash 245#!/bin/bash
251 246
247<comment># BEGIN configuration</comment>
252RUNLEVEL_AC="default" 248RUNLEVEL_AC="default"
253RUNLEVEL_BATTERY="battery" 249RUNLEVEL_BATTERY="battery"
250<comment># END configuration</comment>
254 251
255function on_ac () {
256 if which on_ac_power &amp;> /dev/null
257 then
258 on_ac_power
259 else
260 grep --quiet on-line /proc/acpi/ac_adapter/*/state
261 fi
262}
263 252
264function SwitchRunlevel () {
265
266 if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] 253if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
267 then 254then
268 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." 255 logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
269 exit 1 256 exit 1
270 fi 257fi
271 258
272
273 if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] 259if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
274 then 260then
275 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." 261 logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
276 exit 1 262 exit 1
277 fi 263fi
278 264
279 if on_ac 265if on_ac_power
266then
280 then if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] 267 if [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
281 then 268 then
282 logger "Switching to ${RUNLEVEL_AC} runlevel" 269 logger "Switching to ${RUNLEVEL_AC} runlevel"
283 /sbin/rc ${RUNLEVEL_AC} 270 /sbin/rc ${RUNLEVEL_AC}
284 fi 271 fi
285 elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] 272elif [[ "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
286 then 273then
287 logger "Switching to ${RUNLEVEL_BATTERY} runlevel" 274 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
288 /sbin/rc ${RUNLEVEL_BATTERY} 275 /sbin/rc ${RUNLEVEL_BATTERY}
289 fi 276fi
290}
291</pre> 277</pre>
292 278
293<pre caption="/etc/acpi/events/pmg_ac_adapter"> 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>
294event=ac_adapter.* 282event=ac_adapter.*
295action=/etc/acpi/actions/pmg_ac_adapter.sh %e 283action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
296</pre> 284</pre>
297 285
298<pre caption="/etc/acpi/events/pmg_battery"> 286<pre caption="/etc/acpi/events/pmg_battery">
287<comment># replace "battery" below with the event generated on your laptop</comment>
288<comment># See /var/log/acpid</comment>
299event=battery.* 289event=battery.*
300action=/etc/acpi/actions/pmg_battery.sh %e 290action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
301</pre> 291</pre>
302 292
303<pre caption="/etc/acpi/actions/pmg_ac_adapter.sh">
304#!/bin/bash
305
306source /etc/acpi/switch_runlevel.sh
307SwitchRunlevel
308</pre>
309
310<pre caption="/etc/acpi/actions/pmg_battery.sh">
311#!/bin/bash
312
313source /etc/acpi/switch_runlevel.sh
314SwitchRunlevel
315</pre>
316
317<p> 293<p>
318Some of these files must be executable. Last not least restart acpid to have 294Additionally you need the package sys-power/powermgmt-base which contains
319it recognize the changes. 295the <c>on_ac_power</c> utility. The file <path>pmg_switch_runlevel.sh</path>
296must be executable.
320</p> 297</p>
321 298
322<pre caption="Finishing runlevel switching with acpid"> 299<pre caption="Finishing runlevel switching with acpid">
323<i># emerge powermgmt-base</i> 300<i># emerge powermgmt-base</i>
324<i># chmod +x /etc/acpi/switch_runlevel.sh</i> 301<i># chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</i>
325<i># chmod +x /etc/acpi/actions/pmg_*</i>
326<i># /etc/init.d/acpid restart</i> 302<i># /etc/init.d/acpid restart</i>
327</pre> 303</pre>
328 304
329<p> 305<p>
330Give 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
342favourite editor and add these lines: 318favourite editor and add these lines:
343</p> 319</p>
344 320
345<pre caption="Runlevel switch at boot time by editing local.start"> 321<pre caption="Runlevel switch at boot time by editing local.start">
346<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>
347/etc/acpi/actions/pmg_battery.sh "battery/battery" 323/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
348</pre> 324</pre>
349 325
350<p> 326<p>
351Prepared like this you can activate Power Management policies for individual 327Prepared like this you can activate Power Management policies for individual
352devices. 328devices.
371First of all, the kernel has to be able to change the processor's frequency. The 347First of all, the kernel has to be able to change the processor's frequency. The
372<e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus 348<e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus
373it's important to choose the right one in your kernel. You should already have 349it's important to choose the right one in your kernel. You should already have
374done it above. Once the kernel knows how to change frequencies, it has to know 350done it above. Once the kernel knows how to change frequencies, it has to know
375which frequency it should set. This is done according to the <e>policy</e> which 351which frequency it should set. This is done according to the <e>policy</e> which
376consists of <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are 352consists of a <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are
377just two numbers which define a range the frequency has to stay between - 353just two numbers which define a range the frequency has to stay between -
378minimal and maximal frequency. The governor now decides which of the available 354minimal and maximal frequency. The governor now decides which of the available
379frequencies in between minimal and maximal frequency to choose. For example, the 355frequencies in between minimal and maximal frequency to choose. For example, the
380<e>powersave governor</e> always chooses the lowest frequency available, the 356<e>powersave governor</e> always chooses the lowest frequency available, the
381<e>performance governor</e> the highest one. The <e>userspace governor</e> makes 357<e>performance governor</e> the highest one. The <e>userspace governor</e> makes
387<p> 363<p>
388This doesn't sound like dynamic frequency changes yet and in fact it isn't. 364This doesn't sound like dynamic frequency changes yet and in fact it isn't.
389Dynamics however can be accomplished with various approaches. For example, 365Dynamics however can be accomplished with various approaches. For example,
390the <e>ondemand governor</e> makes its decisions depending on the current CPU 366the <e>ondemand governor</e> makes its decisions depending on the current CPU
391load. The same is done by various userland tools like <c>cpudyn</c>, 367load. The same is done by various userland tools like <c>cpudyn</c>,
392<c>speedfreq</c>, <c>powernowd</c> and many more. ACPI events can be used to 368<c>cpufreqd</c>, <c>powernowd</c> and many more. ACPI events can be used to
393enable or disable dynamic frequency changes depending on power source. 369enable or disable dynamic frequency changes depending on power source.
394</p> 370</p>
395 371
396</body> 372</body>
397</section> 373</section>
412of 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
413is supported. 389is supported.
414</note> 390</note>
415 391
416<p> 392<p>
417It'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
418the 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>
419another CPU speed, use:
420</p>
421
422<pre caption="Manual CPU speed modifications">
423<comment>(Get current frequency)</comment>
424# <i>grep "cpu MHz" /proc/cpuinfo</i>
425
426<comment>(Lists supported frequencies. This might fail.)</comment>
427# <i>cd /sys/devices/system/cpu/cpu0/cpufreq/</i>
428# <i>cat scaling_available_frequencies</i>
429
430<comment>(Change frequency to 1 GHz (1000000 KHz)
431Replace with a frequency your laptop supports.)</comment>
432# <i>echo -n userspace > scaling_governor</i>
433# <i>echo -n 1000000 > scaling_setspeed</i>
434
435<comment>(Verify frequency was changed)</comment>
436# <i>grep "cpu MHz" /proc/cpuinfo</i>
437</pre>
438
439<p> 395</p>
440If you are getting error messages, please refer to the <e>Troubleshooting</e> 396
441chapter 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
442</p> 402<p>
443 403Here is an example output:
444<p> 404</p>
445You can also write to <path>scaling_max_freq</path> and 405
446<path>scaling_min_freq</path> to set boundaries the frequency should stay in 406<pre caption="Sample output from cpufreq-info">
447between. 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
448</p> 421<p>
449 422Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
450<note> 423Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
451Some 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
452don'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
453wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your 426guide.
454kernel as asked and check the current frequency with <c>x86info -mhz</c>. 427</p>
455</note>
456 428
457</body> 429</body>
458</section> 430</section>
459<section> 431<section>
460<title>Automated frequency adaption</title> 432<title>Automated frequency adaption</title>
494</tr> 466</tr>
495<tr> 467<tr>
496 <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>
497 <ti>Daemon</ti> 469 <ti>Daemon</ti>
498 <ti>CPU load</ti> 470 <ti>CPU load</ti>
499 <ti>None</ti> 471 <ti>Performance, powersave</ti>
500 <ti>Dynamic</ti> 472 <ti>Dynamic</ti>
501 <ti> 473 <ti>
502 Also supports disk standby - notice however that <e>laptop mode</e> in most 474 Also supports disk standby - notice however that <e>laptop mode</e> in most
503 cases will do a better job. 475 cases will do a better job.
504 </ti> 476 </ti>
508 <ti>Daemon</ti> 480 <ti>Daemon</ti>
509 <ti>Battery state, CPU load, running programs</ti> 481 <ti>Battery state, CPU load, running programs</ti>
510 <ti>All available</ti> 482 <ti>All available</ti>
511 <ti>None</ti> 483 <ti>None</ti>
512 <ti> 484 <ti>
513 Sophisticated (but also complicated) setup. An optimal configuration 485 Sophisticated (but also complicated) setup.
514 requires detailed knowledge of your system.
515 </ti> 486 </ti>
516</tr> 487</tr>
517<tr> 488<tr>
518 <ti> 489 <ti>
519 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> 490 <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
532 <ti>CPU load</ti> 503 <ti>CPU load</ti>
533 <ti>None</ti> 504 <ti>None</ti>
534 <ti>Dynamic, powersave, performance, fixed speed</ti> 505 <ti>Dynamic, powersave, performance, fixed speed</ti>
535 <ti> 506 <ti>
536 Small yet powerful with an useful client/server interface. Requires a 2.6 507 Small yet powerful with an useful client/server interface. Requires a 2.6
537 kernel. 508 kernel. Doesn't seem to be maintained anymore and will be removed from
509 Portage in the near future.
538 </ti> 510 </ti>
539</tr> 511</tr>
540<tr> 512<tr>
541 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> 513 <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
542 <ti>Graphical</ti> 514 <ti>Graphical</ti>
543 <ti>None</ti> 515 <ti>None</ti>
544 <ti>None</ti> 516 <ti>None</ti>
545 <ti>None</ti> 517 <ti>None</ti>
546 <ti> 518 <ti>
547 Gnome application, a graphical tool to set CPU frequency manually. It does 519 Gnome application, a graphical tool to set CPU frequency manually. It does
548 not offer any automation and is mainly listed for the sake of completeness. 520 not offer any automation.
549 </ti> 521 </ti>
550</tr> 522</tr>
551<tr> 523<tr>
552 <ti>klaptopdaemon</ti> 524 <ti>klaptopdaemon</ti>
553 <ti>Graphical</ti> 525 <ti>Graphical</ti>
566two 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
567unnecessary high level. 539unnecessary high level.
568</p> 540</p>
569 541
570<p> 542<p>
571Which 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>:
572</p>
573
574<pre caption="Installing speedfreq">
575# <i>emerge speedfreq</i>
576# <i>rc-update add speedfreq battery</i>
577</pre>
578
579<p> 544</p>
580<c>speedfreq</c> can be configured by editing
581<path>/etc/conf.d/speedfreq</path>. For example, if you like users to be able
582to change the policy, modify <c>SPEEDFREQ_OPTS=""</c> to
583<c>SPEEDFREQ_OPTS="-u"</c>. Having done your changes, start the daemon.
584</p>
585
586<pre caption="Starting speedfreq">
587# <i>/etc/init.d/speedfreq start</i>
588</pre>
589
590<p>
591Setting up cpufreqd is a little bit more complicated.
592</p>
593
594<warn>
595Do not run more than one of the above programs at the same time. It may cause
596confusion like switching between two frequencies all the time. If you just
597installed speedfreq, skip cpufreqd now.
598</warn>
599 545
600<pre caption="Installing cpufreqd"> 546<pre caption="Installing cpufreqd">
601# <i>emerge cpufreqd</i> 547# <i>emerge cpufreqd</i>
602# <i>rc-update add cpufreqd battery</i>
603</pre> 548</pre>
604 549
605<p>
606<c>cpufreqd</c> comes with a default configuration in
607<path>/etc/cpufreqd.conf</path>.
608Change the config file to fit your needs. The following will save more energy
609than the default one - at the cost of less performance, of course.
610</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>
611 556
612<pre caption="A sample cpufreqd config file"> 557<pre caption="/etc/cpufreqd.conf">
613[General] 558[General]
614pidfile=/var/run/cpufreqd.pid 559pidfile=/var/run/cpufreqd.pid
615poll_interval=2 560poll_interval=2
616pm_type=acpi 561pm_type=acpi
617<comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5)) 562verbosity=5
618# acpi_workaround=1</comment>
619verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
620 563
621<comment># Full performance</comment>
622[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]
623name=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">
624minfreq=600000 607minfreq=600000
625maxfreq=1400000 608maxfreq=1400000
626policy=performance
627
628<comment># Maximum power saving</comment>
629[Profile]
630name=battery
631minfreq=600000
632maxfreq=900000
633policy=powersave
634
635<comment># Constant frequency</comment>
636[Profile]
637name=dvd
638minfreq=900000
639maxfreq=1100000
640policy=powersave
641
642<comment># Full performance when running on AC</comment>
643[Rule]
644name=ac_on
645ac=on
646profile=ac
647
648<comment># Compiling should be fast if battery state is ok</comment>
649[Rule]
650name=compiling
651ac=off
652battery_interval=30-100
653programs=emerge,make,gcc,cpp
654cpu_interval=0-100
655profile=ac
656
657<comment># watching DVD's gets sluggish with slow CPU frequency
658# Can also be used for games etc.</comment>
659[Rule]
660name=dvd_watching
661ac=off
662battery_interval=15-100
663programs=xine,mplayer,avidemux,kaffeine,kmplayer
664cpu_interval=0-100
665profile=dvd
666
667<comment># If above doesn't apply, maximise power saving</comment>
668[Rule]
669name=battery_on
670ac=off
671battery_interval=0-100
672cpu_interval=0-100
673profile=battery
674</pre> 609</pre>
675 610
676<p>
677<c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
678<c>speedfreq</c>.
679</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>
680 624
681</body> 625</body>
682</section> 626</section>
683 627
684<section> 628<section>
690The 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
691do so is monitoring CPU speed while working with your laptop: 635do so is monitoring CPU speed while working with your laptop:
692</p> 636</p>
693 637
694<pre caption="Monitoring CPU speed"> 638<pre caption="Monitoring CPU speed">
695# <i>watch -n 1 'grep "cpu MHz" /proc/cpuinfo'</i> 639# <i>watch grep "cpu MHz" /proc/cpuinfo</i>
696</pre> 640</pre>
697 641
698<p> 642<p>
699If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU 643If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting),
700frequency with: 644monitor the CPU frequency with:
701</p> 645</p>
702 646
703<pre caption="Alternative CPU speed monitoring"> 647<pre caption="Alternative CPU speed monitoring">
704# <i>watch -n 1 x86info -mhz</i> 648# <i>watch x86info -mhz</i>
705</pre> 649</pre>
706 650
707<p> 651<p>
708Depending 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
709no 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.
710</p> 656</p>
711 657
712</body> 658</body>
713</section> 659</section>
714</chapter> 660</chapter>
761</p> 707</p>
762 708
763<p> 709<p>
764Probably 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
765dimming 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
766battery 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
767</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>
768 796
769</body> 797</body>
770</section> 798</section>
771</chapter> 799</chapter>
772 800
809<path>/etc/init.d/pm.hda</path> like this: 837<path>/etc/init.d/pm.hda</path> like this:
810</p> 838</p>
811 839
812<pre caption="Using hdparm for disk standby"> 840<pre caption="Using hdparm for disk standby">
813#!/sbin/runscript 841#!/sbin/runscript
842
843depend() {
844 after hdparm
845}
846
814start() { 847start() {
815 ebegin "Activating Power Management for Hard Drives" 848 ebegin "Activating Power Management for Hard Drives"
816 hdparm -q -S12 /dev/hda 849 hdparm -q -S12 /dev/hda
817 eend $? 850 eend $?
818} 851}
851include 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
852written 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
853minimizes the time the hard disk needs to be spun up. 886minimizes the time the hard disk needs to be spun up.
854</p> 887</p>
855 888
856<p>
857<!-- TODO: bug #45593 -->
858Besides kernel support you also need a script that controls starting and
859stopping of laptop-mode. You kernel documentation in
860<path>/usr/src/linux/Documentation/laptop-mode.txt</path> contains one as well
861as the package <c>laptop-mode-tools</c>. None of them is easy to install
862though.
863</p>
864
865<p>
866Ebuilds for laptop-mode-tools are not in Portage, because Gentoo developers
867don't think they are production ready yet. Take that into consideration
868before using the ebuilds which can be found in <uri
869link="http://bugs.gentoo.org/show_bug.cgi?id=45593">Bugzilla</uri>. The Gentoo
870Handbook tells you how to use external ebuilds if you don't know where to put
871them. Once your PORTDIR_OVERLAY contains the ebuilds, install the
872script:
873</p>
874
875<warn>
876This package is not seen as production ready and installing custom ebuilds from
877Bugzilla is not recommended. Please don't use laptop-mode-tools if you're
878unsure.
879</warn>
880
881<pre caption="Automated start of laptop-mode"> 889<pre caption="Automated start of laptop-mode">
882# <i>emerge laptop-mode-tools</i> 890# <i>emerge laptop-mode-tools</i>
883</pre> 891</pre>
884 892
885<p> 893<p>
886<c>laptop-mode-tools</c> has it's configuration file in 894<c>laptop-mode-tools</c> has it's configuration file in
887<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it, 895<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
888it's well commented. If you have <e>apm</e> or <e>acpi</e> in your USE flags, 896it's well commented. Run <c>rc-update add laptop_mode battery</c> to start it
889laptop-mode will be started automatically in battery mode. Otherwise you can 897automatically.
890automate it by running <c>rc-update add laptop-mode battery</c>.
891</p> 898</p>
892 899
893</body> 900</body>
894</section> 901</section>
895<section> 902<section>

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.20