Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 69734 | Differences between
and this patch

Collapse All | Expand All

(-)power-management-guide-1.17.xml (-92 / +253 lines)
Lines 5-11 Link Here
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>
Lines 17-24 Link Here
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.18</version>
21
<date>October 10, 2004</date>
21
<date>December 01, 2004</date>
22
22
23
<chapter>
23
<chapter>
24
<title>Introduction</title>
24
<title>Introduction</title>
Lines 170-178 Link Here
170
</pre>
170
</pre>
171
171
172
<p>
172
<p>
173
Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk
173
Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and
174
and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop,
174
Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable
175
enable the appropriate section.
175
the appropriate section. Recent kernel versions (2.6.9 and later) include an
176
<e>'ondemand' governor</e> for CPU Frequency Scaling, activate it as well when
177
using such a kernel.
178
</p>
179
180
<p>
181
The kernel has to know how to enable CPU frequency scaling on your processor. As
182
each type of CPU has a different interface, you've got to choose the right
183
driver for your processor. Be careful here - enabling <e>Intel Pentium 4 clock
184
modulation</e> on a Pentium M system will lead to strange results for example.
185
Consult the kernel documentation if you're unsure which one to take.
176
</p>
186
</p>
177
187
178
<p>
188
<p>
Lines 230-299 Link Here
230
240
231
<p>
241
<p>
232
Typical ACPI events are closing the lid, changing the power source or pressing
242
Typical ACPI events are closing the lid, changing the power source or pressing
233
the sleep button. Every acpi event recognized by the kernel is catched by acpid
243
the sleep button. Create the following files to switch between <e>default</e>
234
which calls <path>/etc/acpi/default.sh</path>. Here is a basic modification
244
and <e>battery</e> runlevel depending on the power source:
235
supporting runlevel switching:
245
</p>
236
</p>
246
237
247
<pre caption="/etc/acpi/switch_runlevel.conf">
238
<pre caption="Event driven runlevel switching with acpid">
248
#!/bin/bash
239
#!/bin/sh
249
240
250
# This runlevel will be used in AC mode
241
set $*
251
#RUNLEVEL_AC="default"
242
252
243
group=${1/\/*/}
253
# This runlevel will be used in battery mode
244
action=${1/*\//}
254
#RUNLEVEL_BATTERY="battery"
245
255
246
<comment># runlevel to use in AC mode</comment>
256
# This file indicates the AC state
247
RLVL_AC="default"
257
# It's location may vary on your system. The script checks for
248
<comment># runlevel to use in battery mode</comment>
258
# /proc/acpi/ac_adapter/AC/state, /proc/acpi/ac_adapter/AC0/state,
249
RLVL_BATTERY="battery"
259
# /proc/acpi/ac_adapter/AC1/state and /proc/acpi/ac_adapter/AC2/state
250
260
# If it is something else on your system, uncomment the next line
251
<comment># file indicating the AC state. Verify the filename before using</comment>
261
# and change appropriately.
252
AC_STATE="/proc/acpi/ac_adapter/AC/state"
262
#AC_STATE="/proc/acpi/ac_adapter/AC/state"
253
<comment># this string means running on AC</comment>
263
</pre>
254
AC_ON="on-line"
264
255
<comment># this string means running on batteries</comment>
265
<pre caption="/etc/acpi/switch_runlevel.sh">
256
AC_OFF="off-line"
266
#!/bin/bash
267
268
RUNLEVEL_AC="default"
269
RUNLEVEL_BATTERY="battery"
270
271
if [ -f '/proc/acpi/ac_adapter/AC0/state' ]
272
then
273
    AC_STATE="/proc/acpi/ac_adapter/AC0/state"
274
elif [ -f '/proc/acpi/ac_adapter/AC1/state' ]
275
then
276
    AC_STATE="/proc/acpi/ac_adapter/AC1/state"
277
elif [ -f '/proc/acpi/ac_adapter/AC2/state' ]
278
then
279
    AC_STATE="/proc/acpi/ac_adapter/AC2/state"
280
else
281
    AC_STATE="/proc/acpi/ac_adapter/AC/state"
282
fi
283
284
285
source /etc/acpi/switch_runlevel.conf
257
286
258
function SwitchRunlevel() {
287
function SwitchRunlevel() {
259
  if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]]
288
289
    if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ]
260
  then
290
  then
261
    logger "Switching to ${RLVL_BATTERY} runlevel"
291
        logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting."
262
    /sbin/rc ${RLVL_BATTERY}
292
        exit 1
263
  elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]]
293
    fi
294
295
296
    if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ]
264
  then
297
  then
265
    logger "Switching to ${RLVL_AC} runlevel"
298
        logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting."
266
    /sbin/rc ${RLVL_AC}
299
        exit 1
300
    fi
301
302
    if [ ! -f "${AC_STATE}" ]
303
    then
304
        logger "${0}: File ${AC_STATE} does not exist. Aborting"
305
        exit 1
306
    fi
307
308
309
    if [[ "$(grep off-line ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]]
310
    then
311
        logger "Switching to ${RUNLEVEL_BATTERY} runlevel"
312
        /sbin/rc ${RUNLEVEL_BATTERY}
313
    elif [[ "$(grep on-line ${AC_STATE})" != "" &amp;&amp; "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]]
314
    then
315
        logger "Switching to ${RUNLEVEL_AC} runlevel"
316
        /sbin/rc ${RUNLEVEL_AC}
267
  fi
317
  fi
268
}
318
}
319
</pre>
269
320
321
<pre caption="/etc/acpi/events/pmg_ac_adapter">
322
event=ac_adapter.*
323
action=/etc/acpi/actions/pmg_ac_adapter.sh %e
324
</pre>
270
325
271
case "$group" in
326
<pre caption="/etc/acpi/events/pmg_battery">
272
  battery)
327
event=battery.*
273
    case "$action" in
328
action=/etc/acpi/actions/pmg_battery.sh %e
274
      battery) 
329
</pre>
275
        SwitchRunlevel
330
276
        ;;
331
<pre caption="/etc/acpi/actions/pmg_ac_adapter.sh">
277
      *) 
332
#! /bin/bash
278
        logger "ACPI group battery / action $action is not defined"
333
279
        ;;
334
source /etc/acpi/switch_runlevel.sh
280
    esac
335
SwitchRunlevel
281
    ;;
336
</pre>
282
337
283
  ac_adapter)
338
<pre caption="/etc/acpi/actions/pmg_battery.sh">
284
    case "$action" in
339
#! /bin/bash
285
      ac_adapter)
340
286
        SwitchRunlevel
341
source /etc/acpi/switch_runlevel.sh
287
        ;;
342
SwitchRunlevel
288
      *)
289
        logger "ACPI group ac_adapter / action $action is not defined"
290
        ;;
291
    esac
292
    ;;
293
  *)
294
    logger "ACPI group $group / action $action is not defined"
295
    ;;
296
esac
297
</pre>
343
</pre>
298
344
299
<p>
345
<p>
Lines 313-319 Link Here
313
359
314
<pre caption="Runlevel switch at boot time by editing local.start">
360
<pre caption="Runlevel switch at boot time by editing local.start">
315
<comment># Fake acpi event to switch runlevel if running on batteries</comment>
361
<comment># Fake acpi event to switch runlevel if running on batteries</comment>
316
/etc/acpi/default.sh "battery/battery"
362
/etc/acpi/actions/pmg_battery.sh "battery/battery"
317
</pre>
363
</pre>
318
364
319
<p>
365
<p>
Lines 328-333 Link Here
328
<chapter>
374
<chapter>
329
<title>CPU Power Management</title>
375
<title>CPU Power Management</title>
330
<section>
376
<section>
377
<title>Some technical terms</title>
378
<body>
379
380
<p>
381
CPU frequency scaling brings up some technical terms that might be unknown to
382
you. Here's a quick introduction.
383
</p>
384
385
<p>
386
First of all, the kernel has to be able to change the processor's frequency. The
387
<e>CPUfreq processor driver</e> knows the commands to do it on your CPU. Thus
388
it's important to choose the right one in your kernel. You should already have
389
done it above. Once the kernel knows how to change frequencies, it has to know
390
which frequency it should set. This is done according to the <e>policy</e> which
391
consists of <e>CPUfreq policy</e> and a <e>governor</e>. A CPUfreq policy are
392
just two numbers which define a range the frequency has to stay between -
393
minimal and maximal frequency. The governor now decides which of the available
394
frequencies in between minimal and maximal frequency to choose. For example, the
395
<e>powersave governor</e> always chooses the lowest frequency available, the
396
<e>performance governor</e> the highest one. The <e>userspace governor</e> makes
397
no decision but chooses whatever the user (or a program in userspace) wants -
398
which means it reads the frequency from
399
<path>/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed</path>.
400
</p>
401
402
<p>
403
This doesn't sound like dynamic frequency changes yet and in fact it isn't.
404
Dynamics however can be accomplished with various approaches. For example,
405
the <e>ondemand governor</e> makes its decisions depending on the current CPU
406
load. The same is done by various userland tools like <c>cpudyn</c>,
407
<c>speedfreq</c>, <c>powernowd</c> and many more. ACPI events can be used to
408
enable or disable dynamic frequency changes depending on power source.
409
</p>
410
411
</body>
412
</section>
413
<section>
331
<title>Setting the frequency manually</title>
414
<title>Setting the frequency manually</title>
332
<body>
415
<body>
333
416
Lines 394-432 Link Here
394
477
395
<p>
478
<p>
396
The above is quite nice, but not doable in daily life. Better let your system
479
The above is quite nice, but not doable in daily life. Better let your system
397
set the appropriate frequency automatically. A couple of user space programs
480
set the appropriate frequency automatically. There are many different approaches
398
like to do it for you. The following table gives a quick overview to help you
481
to do this. The following table gives a quick overview to help you decide on one
399
decide on one of them.
482
of them. It's roughly seperated in three categories <e>kernel</e> for approaches
483
that only need kernel support, <e>daemon</e> for programs that run in the
484
background and <e>graphical</e> for programs that provide a GUI for easy
485
configuration and changes.
400
</p>
486
</p>
401
487
402
<table>
488
<table>
403
<tr>
489
<tr>
404
  <th>Name</th>
490
  <th>Name</th>
405
  <th>Pro</th>
491
  <th>Category</th>
406
  <th>Con</th>
492
  <th>Switch decision</th>
493
  <th>Kernel governors</th>
494
  <th>Further governors</th>
495
  <th>Comments</th>
496
</tr>
497
<tr>
498
  <ti>'ondemand' governor</ti>
499
  <ti>Kernel</ti>
500
  <ti>CPU load</ti>
501
  <ti>N.A.</ti>
502
  <ti>N.A.</ti>
503
  <ti>
504
    Further tuning through files in
505
    <path>/sys/devices/system/cpu/cpu0/cpufreq/ondemand/</path>. Still requires
506
    userland tools (programs, scripts) if governor switching or similar is
507
    desired.
508
  </ti>
407
</tr>
509
</tr>
408
<tr>
510
<tr>
409
  <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
511
  <ti><uri link="http://mnm.uib.es/~gallir/cpudyn/">cpudyn</uri></ti>
410
  <ti>Also supports disk standby</ti>
512
  <ti>Daemon</ti>
411
  <ti></ti>
513
  <ti>CPU load</ti>
514
  <ti>None</ti>
515
  <ti>Dynamic</ti>
516
  <ti>
517
    Also supports disk standby - notice however that <e>laptop mode</e> in most
518
    cases will do a better job.
519
  </ti>
412
</tr>
520
</tr>
413
<tr>
521
<tr>
414
  <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreq</uri></ti>
522
  <ti><uri link="http://sourceforge.net/projects/cpufreqd/">cpufreqd</uri></ti>
415
  <ti>Sophisticated setup possible</ti>
523
  <ti>Daemon</ti>
416
  <ti>Complicated setup</ti>
524
  <ti>Battery state, CPU load, running programs</ti>
525
  <ti>All available</ti>
526
  <ti>None</ti>
527
  <ti>
528
    Sophisticated (but also complicated) setup. An optimal configuration
529
    requires detailed knowledge of your system.
530
  </ti>
531
</tr>
532
<tr>
533
  <ti>
534
    <uri link="http://www.deater.net/john/powernowd.html">powernowd</uri>
535
  </ti>
536
  <ti>Daemon</ti>
537
  <ti>CPU load</ti>
538
  <ti>None</ti>
539
  <ti>Passive, sine, aggressive</ti>
540
  <ti>
541
    Supports SMP.
542
  </ti>
417
</tr>
543
</tr>
418
<tr>
544
<tr>
419
  <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
545
  <ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti>
546
  <ti>Daemon</ti>
547
  <ti>CPU load</ti>
548
  <ti>None</ti>
549
  <ti>Dynamic, powersave, performance, fixed speed</ti>
550
  <ti>
551
    Small yet powerful with an useful client/server interface. Requires a 2.6
552
    kernel.
553
  </ti>
554
</tr>
555
<tr>
556
  <ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti>
557
  <ti>Graphical</ti>
558
  <ti>None</ti>
559
  <ti>None</ti>
560
  <ti>None</ti>
420
  <ti>
561
  <ti>
421
    Small yet powerful<br />
562
    Gnome application, a graphical tool to set CPU frequency manually. It does
422
    Useful client/server interface
563
    not offer any automation and is mainly listed for the sake of completeness.
423
  </ti>
564
  </ti>
424
  <ti>Kernel 2.6 series only</ti>
425
</tr>
565
</tr>
426
<tr>
566
<tr>
427
  <ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti>
567
  <ti>klaptopdaemon</ti>
428
  <ti>Supports SMP</ti>
568
  <ti>Graphical</ti>
429
  <ti></ti>
569
  <ti>Battery state</ti>
570
  <ti>All available</ti>
571
  <ti>None</ti>
572
  <ti>
573
    KDE only, 'ondemand' governor required for dynamic frequency scaling.
574
  </ti>
430
</tr>
575
</tr>
431
</table>
576
</table>
432
577
Lines 548-556 Link Here
548
<c>speedfreq</c>.
693
<c>speedfreq</c>.
549
</p>
694
</p>
550
695
696
</body>
697
</section>
698
699
<section>
700
<title>Verifying the result</title>
701
702
<body>
703
551
<p>
704
<p>
552
The last thing to check is that your new policies do a good job. An easy way to
705
The last thing to check is that your new policies do a good job. An easy way to
553
do so is monitoring the CPU speed while working with your laptop:
706
do so is monitoring CPU speed while working with your laptop:
554
</p>
707
</p>
555
708
556
<pre caption="Monitoring CPU speed">
709
<pre caption="Monitoring CPU speed">
Lines 716-738 Link Here
716
869
717
<p>
870
<p>
718
<!-- FIXME: bug #45593 -->
871
<!-- FIXME: bug #45593 -->
719
To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can
872
Besides kernel support you also need a script that controls starting and
720
take the one included in
873
stopping of laptop-mode. The package <c>laptop-mode-tools</c> contains it.
721
<path>/usr/src/linux/Documentation/laptop-mode.txt</path>. Onces it's ready,
722
make sure it gets called.
723
</p>
874
</p>
724
875
725
<pre caption="Automatic start of laptop-mode">
876
<pre caption="Automatic start of laptop-mode">
726
# <i>rc-update add laptop-mode battery</i>
877
# <i>emerge laptop-mode-tools</i>
727
</pre>
878
</pre>
728
879
729
<warn>
880
<p>
730
Once again: Be careful with sleep/spin down settings of your hard drive.
881
<c>laptop-mode-tools</c> has it's configuration file in
731
Setting it to small values might wear out your drive and lose warranty. Be sure
882
<path>/etc/laptop-mode/laptop-mode.conf</path>. Adjust it the way you like it,
732
to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode
883
it's well commented. If you have <e>apm</e> or <e>acpi</e> in your USE flags,
733
before your battery runs out of power and data gets written to disk - otherwise
884
laptop-mode will be started automatically in battery mode. Otherwise you can
734
you will at least lose the last 10 minutes of your work.
885
automate it by running <c>rc-update add laptop-mode battery</c>.
735
</warn>
886
</p>
736
887
737
</body>
888
</body>
738
</section>
889
</section>
Lines 1049-1054 Link Here
1049
</p>
1200
</p>
1050
1201
1051
<p>
1202
<p>
1203
<e>Q:</e> When configuring the kernel, powersave, performance and userspace
1204
governors show up, but that ondemand thing is missing. Where do I get it?
1205
</p>
1206
1207
<p>
1208
<e>A:</e> The ondemand governor is only included in recent kernel sources. Try
1209
updating them.
1210
</p>
1211
1212
<p>
1052
<e>Q:</e> Battery life time seems to be worse than before.
1213
<e>Q:</e> Battery life time seems to be worse than before.
1053
</p>
1214
</p>
1054
1215

Return to bug 69734