/[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.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.7 2004/10/11 00:51:36 vapier Exp $ --> 3<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/power-management-guide.xml,v 1.13 2005/05/28 12:59:36 yoswink 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&#252;ser</mail> 8 <mail link="fragfred@gmx.de">Dennis Nienh├╝ser</mail>
9</author> 9</author>
10 10
11<abstract> 11<abstract>
12Power 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
13laptops. This guide assists you setting it up on your laptop. 13laptops. This guide assists you setting it up on your laptop.
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.17</version> 20<version>1.23</version>
21<date>October 10, 2004</date> 21<date>2005-05-28</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
162 CPU Frequency Scaling ---&gt; 160 CPU Frequency Scaling ---&gt;
163 [*] CPU Frequency scaling 161 [*] CPU Frequency scaling
164 Default CPUFreq governor (userspace) 162 Default CPUFreq governor (userspace)
165 &lt;*&gt; 'performance' governor 163 &lt;*&gt; 'performance' governor
166 &lt;*&gt; 'powersave' governor 164 &lt;*&gt; 'powersave' governor
165 &lt;*&gt; 'ondemand' cpufreq policy governor
167 &lt;*&gt; CPU frequency table helpers 166 &lt;*&gt; CPU frequency table helpers
168 &lt;M&gt; ACPI Processor P-States driver 167 &lt;M&gt; ACPI Processor P-States driver
169 &lt;*&gt; <i>CPUFreq driver for your processor</i> 168 &lt;*&gt; <i>CPUFreq driver for your processor</i>
170</pre> 169</pre>
171 170
172<p> 171<p>
173Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk 172Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and
174and 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
175enable 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.
176</p> 183</p>
177 184
178<p> 185<p>
179Compile 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
180into 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
181the 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
182battery 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
183didn'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
184start</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
185soon see how to use it. 192it on startup. You'll soon see how to use it.
186</p> 193</p>
187 194
188<pre caption="Installing acpid"> 195<pre caption="Installing acpid">
189# <i>emerge sys-apps/acpid</i> 196# <i>emerge sys-power/acpid</i>
190# <i>modprobe button</i>
191# <i>/etc/init.d/acpid start</i> 197# <i>/etc/init.d/acpid start</i>
192# <i>rc-update add acpid default</i> 198# <i>rc-update add acpid default</i>
193</pre> 199</pre>
194 200
195</body> 201</body>
228<title>Reacting on ACPI events</title> 234<title>Reacting on ACPI events</title>
229<body> 235<body>
230 236
231<p> 237<p>
232Typical 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
233the 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
234which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification 240cause a runlevel switch. Create the following files to switch between
235supporting runlevel switching: 241<e>default</e> and <e>battery</e> runlevel depending on the power source:
236</p> 242</p>
237 243
238<pre caption="Event driven runlevel switching with acpid"> 244<pre caption="/etc/acpi/actions/pmg_switch_runlevel.sh">
239#!/bin/sh 245#!/bin/bash
240 246
241set $* 247<comment># BEGIN configuration</comment>
242
243group=${1/\/*/}
244action=${1/*\//}
245
246<comment># runlevel to use in AC mode</comment>
247RLVL_AC="default" 248RUNLEVEL_AC="default"
248<comment># runlevel to use in battery mode</comment>
249RLVL_BATTERY="battery" 249RUNLEVEL_BATTERY="battery"
250<comment># END configuration</comment>
250 251
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 252
258function SwitchRunlevel() { 253if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
259 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}" ]]
260 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
261 logger "Switching to ${RLVL_BATTERY} runlevel" 274 logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
262 /sbin/rc ${RLVL_BATTERY} 275 /sbin/rc ${RUNLEVEL_BATTERY}
263 elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]] 276fi
264 then 277</pre>
265 logger "Switching to ${RLVL_AC} runlevel"
266 /sbin/rc ${RLVL_AC}
267 fi
268}
269 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>
270 285
271case "$group" in 286<pre caption="/etc/acpi/events/pmg_battery">
272 battery) 287<comment># replace "battery" below with the event generated on your laptop</comment>
273 case "$action" in 288<comment># See /var/log/acpid</comment>
274 battery) 289event=battery.*
275 SwitchRunlevel 290action=/etc/acpi/actions/pmg_switch_runlevel.sh %e
276 ;; 291</pre>
277 *)
278 logger "ACPI group battery / action $action is not defined"
279 ;;
280 esac
281 ;;
282 292
283 ac_adapter) 293<p>
284 case "$action" in 294Additionally you need the package sys-power/powermgmt-base which contains
285 ac_adapter) 295the <c>on_ac_power</c> utility. The file <path>pmg_switch_runlevel.sh</path>
286 SwitchRunlevel 296must be executable.
287 ;; 297</p>
288 *) 298
289 logger "ACPI group ac_adapter / action $action is not defined" 299<pre caption="Finishing runlevel switching with acpid">
290 ;; 300<i># emerge powermgmt-base</i>
291 esac 301<i># chmod +x /etc/acpi/actions/pmg_switch_runlevel.sh</i>
292 ;; 302<i># /etc/init.d/acpid restart</i>
293 *)
294 logger "ACPI group $group / action $action is not defined"
295 ;;
296esac
297</pre> 303</pre>
298 304
299<p> 305<p>
300Give 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
301mode" 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.
302</p> 309</p>
303 310
304<p> 311<p>
305Due 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
306<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
307to 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
308choosing 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
309process 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
310runlevel 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
311favourite editor and add these lines: 318favourite editor and add these lines:
312</p> 319</p>
313 320
314<pre caption="Runlevel switch at boot time by editing local.start"> 321<pre caption="Runlevel switch at boot time by editing local.start">
315<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>
316/etc/acpi/default.sh "battery/battery" 323/etc/acpi/actions/pmg_switch_runlevel.sh "battery/battery"
317</pre> 324</pre>
318 325
319<p> 326<p>
320Prepared like this you can activate Power Management policies for individual 327Prepared like this you can activate Power Management policies for individual
321devices. 328devices.
325</section> 332</section>
326</chapter> 333</chapter>
327 334
328<chapter> 335<chapter>
329<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>
330<section> 374<section>
331<title>Setting the frequency manually</title> 375<title>Setting the frequency manually</title>
332<body> 376<body>
333 377
334<p> 378<p>
344of 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
345is supported. 389is supported.
346</note> 390</note>
347 391
348<p> 392<p>
349It'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
350the 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>
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> 395</p>
372If you are getting error messages, please refer to the <e>Troubleshooting</e> 396
373chapter 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
374</p> 402<p>
375 403Here is an example output:
376<p> 404</p>
377You can also write to <path>scaling_max_freq</path> and 405
378<path>scaling_min_freq</path> to set boundaries the frequency should stay in 406<pre caption="Sample output from cpufreq-info">
379between. 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
380</p> 421<p>
381 422Now play around with <c>cpufreq-set</c> to make sure frequency switching works.
382<note> 423Run <c>cpufreq-set -g ondemand</c> for example to activate the ondemand
383Some 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
384don'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
385wasn't changed. If this happens to you, run <c>emerge x86info</c>, update your 426guide.
386kernel as asked and check the current frequency with <c>x86info -mhz</c>. 427</p>
387</note>
388 428
389</body> 429</body>
390</section> 430</section>
391<section> 431<section>
392<title>Automated frequency adaption</title> 432<title>Automated frequency adaption</title>
393<body> 433<body>
394 434
395<p> 435<p>
396The 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
397set the appropriate frequency automatically. A couple of user space programs 437set the appropriate frequency automatically. There are many different approaches
398like 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
399decide 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.
400</p> 443</p>
401 444
402<table> 445<table>
403<tr> 446<tr>
404 <th>Name</th> 447 <th>Name</th>
405 <th>Pro</th> 448 <th>Category</th>
449 <th>Switch decision</th>
450 <th>Kernel governors</th>
451 <th>Further governors</th>
406 <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>
407</tr> 466</tr>
408<tr> 467<tr>
409 <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>
410 <ti>Also supports disk standby</ti>
411 <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>
412</tr> 477</tr>
413<tr> 478<tr>
414 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti> 479 <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
415 <ti>Sophisticated setup possible</ti> 480 <ti>Daemon</ti>
416 <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>
417</tr> 499</tr>
418<tr> 500<tr>
419 <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>
420 <ti> 506 <ti>
421 Small yet powerful<br /> 507 Small yet powerful with an useful client/server interface. Requires a 2.6
422 Useful client/server interface 508 kernel. Doesn't seem to be maintained anymore and will be removed from
509 Portage in the near future.
423 </ti> 510 </ti>
424 <ti>Kernel 2.6 series only</ti>
425</tr> 511</tr>
426<tr> 512<tr>
427 <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>
428 <ti>Supports SMP</ti> 514 <ti>Graphical</ti>
429 <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>
430</tr> 532</tr>
431</table> 533</table>
432 534
433<p> 535<p>
434While 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
436two 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
437unnecessary high level. 539unnecessary high level.
438</p> 540</p>
439 541
440<p> 542<p>
441Which 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>:
442</p>
443
444<pre caption="Installing speedfreq">
445# <i>emerge speedfreq</i>
446# <i>rc-update add speedfreq battery</i>
447</pre>
448
449<p> 544</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 545
470<pre caption="Installing cpufreqd"> 546<pre caption="Installing cpufreqd">
471# <i>emerge cpufreqd</i> 547# <i>emerge cpufreqd</i>
472# <i>rc-update add cpufreqd battery</i>
473</pre> 548</pre>
474 549
475<p>
476<c>cpufreqd</c> comes with a default configuration in
477<path>/etc/cpufreqd.conf</path>.
478Change the config file to fit your needs. The following will save more energy
479than the default one - at the cost of less performance, of course.
480</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>
481 556
482<pre caption="A sample cpufreqd config file"> 557<pre caption="/etc/cpufreqd.conf">
483[General] 558[General]
484pidfile=/var/run/cpufreqd.pid 559pidfile=/var/run/cpufreqd.pid
485poll_interval=2 560poll_interval=2
486pm_type=acpi 561pm_type=acpi
487<comment># Uncomment the following line to enable ACPI workaround (see cpufreqd.conf(5)) 562verbosity=5
488# acpi_workaround=1</comment>
489verbosity=4 <comment>#(if you want a minimal logging set to 5)</comment>
490 563
491<comment># Full performance</comment>
492[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]
493name=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">
494minfreq=600000 607minfreq=600000
495maxfreq=1400000 608maxfreq=1400000
496policy=performance
497
498<comment># Maximum power saving</comment>
499[Profile]
500name=battery
501minfreq=600000
502maxfreq=900000
503policy=powersave
504
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]
514name=ac_on
515ac=on
516profile=ac
517
518<comment># Compiling should be fast if battery state is ok</comment>
519[Rule]
520name=compiling
521ac=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
542cpu_interval=0-100
543profile=battery
544</pre> 609</pre>
545 610
546<p>
547<c>cpudyn</c> and <c>powernowd</c> are installed in the same way as
548<c>speedfreq</c>.
549</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>
550 632
551<p> 633<p>
552The 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
553do so is monitoring the CPU speed while working with your laptop: 635do so is monitoring CPU speed while working with your laptop:
554</p> 636</p>
555 637
556<pre caption="Monitoring CPU speed"> 638<pre caption="Monitoring CPU speed">
557# <i>watch -n 1 grep "cpu MHz" /proc/cpuinfo</i> 639# <i>watch grep \"cpu MHz\" /proc/cpuinfo</i>
558</pre> 640</pre>
559 641
560<p> 642<p>
561If <path>/proc/cpuinfo</path> doesn't get updated (see above), monitor the CPU 643If <path>/proc/cpuinfo</path> doesn't get updated (see Troubleshooting),
562frequency with: 644monitor the CPU frequency with:
563</p> 645</p>
564 646
565<pre caption="Alternative CPU speed monitoring"> 647<pre caption="Alternative CPU speed monitoring">
566# <i>watch -n 1 x86info -mhz</i> 648# <i>watch x86info -mhz</i>
567</pre> 649</pre>
568 650
569<p> 651<p>
570Depending 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
571no 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.
572</p> 656</p>
573 657
574</body> 658</body>
575</section> 659</section>
576</chapter> 660</chapter>
623</p> 707</p>
624 708
625<p> 709<p>
626Probably 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
627dimming 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
628battery 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
629</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>
630 796
631</body> 797</body>
632</section> 798</section>
633</chapter> 799</chapter>
634 800
671<path>/etc/init.d/pm.hda</path> like this: 837<path>/etc/init.d/pm.hda</path> like this:
672</p> 838</p>
673 839
674<pre caption="Using hdparm for disk standby"> 840<pre caption="Using hdparm for disk standby">
675#!/sbin/runscript 841#!/sbin/runscript
842
843depend() {
844 after hdparm
845}
846
676start() { 847start() {
677 ebegin "Activating Power Management for Hard Drives" 848 ebegin "Activating Power Management for Hard Drives"
678 hdparm -q -S12 /dev/hda 849 hdparm -q -S12 /dev/hda
679 eend $? 850 eend $?
680} 851}
690See <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
691battery runlevel. 862battery runlevel.
692</p> 863</p>
693 864
694<pre caption="Automate disk standby settings"> 865<pre caption="Automate disk standby settings">
866# <i>chmod +x /etc/init.d/pm.hda</i>
695# <i>/sbin/depscan.sh</i> 867# <i>/sbin/depscan.sh</i>
696# <i>rc-update add pm.hda battery</i> 868# <i>rc-update add pm.hda battery</i>
697</pre> 869</pre>
698 870
699<impo> 871<impo>
712include 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
713written 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
714minimizes the time the hard disk needs to be spun up. 886minimizes the time the hard disk needs to be spun up.
715</p> 887</p>
716 888
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"> 889<pre caption="Automated start of laptop-mode">
726# <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.
727</pre> 898</p>
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 899
737</body> 900</body>
738</section> 901</section>
739<section> 902<section>
740<title>Other tricks</title> 903<title>Other tricks</title>
820Save 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
821like 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
822options. 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
823is a good starting point to save even more energy. 986is a good starting point to save even more energy.
824</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>
825 994
826</body> 995</body>
827</section> 996</section>
828<section> 997<section>
829<title>USB Power Management</title> 998<title>USB Power Management</title>
946<comment>(kernel 2.4 series)</comment> 1115<comment>(kernel 2.4 series)</comment>
947# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment> 1116# <i>echo 1 &gt; /proc/acpi/sleep</i> <comment>(standby)</comment>
948# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment> 1117# <i>echo 3 &gt; /proc/acpi/sleep</i> <comment>(sleep)</comment>
949 1118
950<comment>(kernel 2.6 series)</comment> 1119<comment>(kernel 2.6 series)</comment>
951# <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>
952# <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>
953 1122
954<comment>(swsusp)</comment> 1123<comment>(swsusp)</comment>
955# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>hibernate</comment> 1124# <i>echo 4 &gt; /proc/acpi/sleep</i> <comment>(hibernate)</comment>
956 1125
957<comment>(Suspend-to-Disk)</comment> 1126<comment>(Suspend-to-Disk)</comment>
958# <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>
959 1128
960<comment>(swsusp2)</comment> 1129<comment>(swsusp2)</comment>
961# <i>echo &gt; /proc/swsusp/activate</i> 1130# <i>/usr/sbin/hibernate</i> <comment>(hibernate, see below)</comment>
962</pre> 1131</pre>
963 1132
964<warn> 1133<warn>
965Backup 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
966commands 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
974</p> 1143</p>
975 1144
976<p> 1145<p>
977While 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
978(I didn't say working), swsusp2 needs special care. 1147(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 1148The first thing to do is patching the kernel with the patches provided at <uri
980link="http://softwaresuspend.berlios.de/"> 1149link="http://softwaresuspend.berlios.de/">
981http://softwaresuspend.berlios.de/</uri>. Afterwards, install the hibernate 1150http://softwaresuspend.berlios.de/</uri>. Additionally you've got to emerge
982script 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>
983</p> 1160</pre>
984 1161
985</body> 1162</body>
986</section> 1163</section>
987</chapter> 1164</chapter>
988 1165
1027<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
1028the speed never changes. 1205the speed never changes.
1029</p> 1206</p>
1030 1207
1031<p> 1208<p>
1032<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>,
1033kernel 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>.
1034</p> 1214</p>
1035 1215
1036<p> 1216<p>
1037<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
1038another OS. 1218another OS.
1047/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
1048<path>/proc/acpi/processor/CPU/throttling</path>. 1228<path>/proc/acpi/processor/CPU/throttling</path>.
1049</p> 1229</p>
1050 1230
1051<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>
1052<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.
1053</p> 1243</p>
1054 1244
1055<p> 1245<p>
1056<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
1103<p> 1293<p>
1104If the "last full capacity" differs significantly from the design capacity, 1294If the "last full capacity" differs significantly from the design capacity,
1105your battery is probably broken. Try to claim your warranty. 1295your battery is probably broken. Try to claim your warranty.
1106</p> 1296</p>
1107 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
1108</body> 1307</body>
1109</section> 1308</section>
1110</chapter> 1309</chapter>
1111</guide> 1310</guide>

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

  ViewVC Help
Powered by ViewVC 1.1.20