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>November 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})" != "" && "$(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})" != "" && "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]] |
293 |
fi |
|
|
294 |
|
295 |
|
296 |
if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] |
297 |
then |
298 |
logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." |
299 |
exit 1 |
300 |
fi |
301 |
|
302 |
if [ ! -f "${AC_STATE}" ] |
264 |
then |
303 |
then |
265 |
logger "Switching to ${RLVL_AC} runlevel" |
304 |
logger "${0}: File ${AC_STATE} does not exist. Aborting" |
266 |
/sbin/rc ${RLVL_AC} |
305 |
exit 1 |
|
|
306 |
fi |
307 |
|
308 |
|
309 |
if [[ "$(grep off-line ${AC_STATE})" != "" && "$(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})" != "" && "$(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> |
325 |
|
326 |
<pre caption="/etc/acpi/events/pmg_battery"> |
327 |
event=battery.* |
328 |
action=/etc/acpi/actions/pmg_battery.sh %e |
329 |
</pre> |
330 |
|
331 |
<pre caption="/etc/acpi/actions/pmg_ac_adapter.sh"> |
332 |
#! /bin/bash |
333 |
|
334 |
source /etc/acpi/switch_runlevel.sh |
335 |
SwitchRunlevel |
336 |
</pre> |
337 |
|
338 |
<pre caption="/etc/acpi/actions/pmg_battery.sh"> |
339 |
#! /bin/bash |
270 |
|
340 |
|
271 |
case "$group" in |
341 |
source /etc/acpi/switch_runlevel.sh |
272 |
battery) |
342 |
SwitchRunlevel |
273 |
case "$action" in |
|
|
274 |
battery) |
275 |
SwitchRunlevel |
276 |
;; |
277 |
*) |
278 |
logger "ACPI group battery / action $action is not defined" |
279 |
;; |
280 |
esac |
281 |
;; |
282 |
|
283 |
ac_adapter) |
284 |
case "$action" in |
285 |
ac_adapter) |
286 |
SwitchRunlevel |
287 |
;; |
288 |
*) |
289 |
logger "ACPI group ac_adapter / action $action is not defined" |
290 |
;; |
291 |
esac |
292 |
;; |
293 |
*) |
294 |
logger "ACPI group $group / action $action is not defined" |
295 |
;; |
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 |
<!-- FIXME: bug #68953 --> |
535 |
<uri |
536 |
link="http://fatcat.ftj.agh.edu.pl/~nelchael/index.php?id=ncpufreqd&language=en"> |
537 |
ncpufreqd</uri> |
538 |
</ti> |
539 |
<ti>Daemon</ti> |
540 |
<ti>CPU temperature</ti> |
541 |
<ti>Powersave, performance</ti> |
542 |
<ti>temperature governor</ti> |
543 |
<ti> |
544 |
It's main purpose is thermal management - whenever CPU temperature exceeds |
545 |
a user defined trip point, processor frequency will be lowered through |
546 |
frequency scaling or ACPI throttling. Very useful for laptops with mobile |
547 |
versions of desktops CPUs and other ones that have heat problems. See the |
548 |
"Thermal Management" chapter for details. |
549 |
</ti> |
550 |
</tr> |
551 |
<tr> |
552 |
<ti> |
553 |
<uri link="http://www.deater.net/john/powernowd.html">powernowd</uri> |
554 |
</ti> |
555 |
<ti>Daemon</ti> |
556 |
<ti>CPU load</ti> |
557 |
<ti>None</ti> |
558 |
<ti>Passive, sine, aggressive</ti> |
559 |
<ti> |
560 |
Supports SMP. |
561 |
</ti> |
417 |
</tr> |
562 |
</tr> |
418 |
<tr> |
563 |
<tr> |
419 |
<ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti> |
564 |
<ti><uri link="http://www.goop.org/~jeremy/speedfreq/">speedfreq</uri></ti> |
|
|
565 |
<ti>Daemon</ti> |
566 |
<ti>CPU load</ti> |
567 |
<ti>None</ti> |
568 |
<ti>Dynamic, powersave, performance, fixed speed</ti> |
420 |
<ti> |
569 |
<ti> |
421 |
Small yet powerful<br /> |
570 |
Small yet powerful with an useful client/server interface. Requires a 2.6 |
422 |
Useful client/server interface |
571 |
kernel. |
423 |
</ti> |
572 |
</ti> |
424 |
<ti>Kernel 2.6 series only</ti> |
|
|
425 |
</tr> |
573 |
</tr> |
426 |
<tr> |
574 |
<tr> |
427 |
<ti><uri link="http://www.deater.net/john/powernowd.html">powernowd</uri></ti> |
575 |
<ti><uri link="http://cpuspeedy.sourceforge.net/">gtk-cpuspeedy</uri></ti> |
428 |
<ti>Supports SMP</ti> |
576 |
<ti>Graphical</ti> |
429 |
<ti></ti> |
577 |
<ti>None</ti> |
|
|
578 |
<ti>None</ti> |
579 |
<ti>None</ti> |
580 |
<ti> |
581 |
Gnome application, a graphical tool to set CPU frequency manually. It does |
582 |
not offer any automation and is mainly listed for the sake of completeness. |
583 |
</ti> |
584 |
</tr> |
585 |
<tr> |
586 |
<ti>klaptopdaemon</ti> |
587 |
<ti>Graphical</ti> |
588 |
<ti>Battery state</ti> |
589 |
<ti>All available</ti> |
590 |
<ti>None</ti> |
591 |
<ti> |
592 |
KDE only, 'ondemand' governor required for dynamic frequency scaling. |
593 |
</ti> |
430 |
</tr> |
594 |
</tr> |
431 |
</table> |
595 |
</table> |
432 |
|
596 |
|
Lines 548-556
Link Here
|
548 |
<c>speedfreq</c>. |
712 |
<c>speedfreq</c>. |
549 |
</p> |
713 |
</p> |
550 |
|
714 |
|
|
|
715 |
</body> |
716 |
</section> |
717 |
<section> |
718 |
<title>Thermal Management</title> |
719 |
|
720 |
<body> |
721 |
|
722 |
<p> |
723 |
There's another area where throttling CPU frequency is useful. If your laptop |
724 |
(or Desktop system) has heat problems, frequency throttling can be the only |
725 |
alternative to a shutdown. <c>ncpufreqd</c> is a tool that keeps an eye on |
726 |
temperature and throttles CPU frequency whenever it gets too high. Make sure |
727 |
that no other daemon like speedfreqd, cpufreqd, powernowd or cpudyn is running |
728 |
and install <c>ncpufreqd</c>: |
729 |
</p> |
730 |
|
731 |
<pre caption="Installing ncpufreqd"> |
732 |
# <i> emerge ncpufreqd</i> |
733 |
# <i> rc-update add ncpufreqd default battery </i> |
734 |
</pre> |
735 |
|
736 |
<p> |
737 |
<c>ncpufreqd</c> is configured through <path>/etc/ncpufreqd.conf</path>. Modify |
738 |
it and start ncpufreqd afterwards: <c>/etc/init.d/ncpufreqd start</c>. |
739 |
</p> |
740 |
|
741 |
</body> |
742 |
</section> |
743 |
|
744 |
<section> |
745 |
<title>Verifying the result</title> |
746 |
|
747 |
<body> |
748 |
|
551 |
<p> |
749 |
<p> |
552 |
The last thing to check is that your new policies do a good job. An easy way to |
750 |
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: |
751 |
do so is monitoring CPU speed while working with your laptop: |
554 |
</p> |
752 |
</p> |
555 |
|
753 |
|
556 |
<pre caption="Monitoring CPU speed"> |
754 |
<pre caption="Monitoring CPU speed"> |
Lines 716-738
Link Here
|
716 |
|
914 |
|
717 |
<p> |
915 |
<p> |
718 |
<!-- FIXME: bug #45593 --> |
916 |
<!-- FIXME: bug #45593 --> |
719 |
To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can |
917 |
Besides kernel support you also need a script that controls starting and |
720 |
take the one included in |
918 |
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> |
919 |
</p> |
724 |
|
920 |
|
725 |
<pre caption="Automatic start of laptop-mode"> |
921 |
<pre caption="Automatic start of laptop-mode"> |
726 |
# <i>rc-update add laptop-mode battery</i> |
922 |
# <i>emerge laptop-mode-tools</i> |
727 |
</pre> |
923 |
</pre> |
728 |
|
924 |
|
729 |
<warn> |
925 |
<p> |
730 |
Once again: Be careful with sleep/spin down settings of your hard drive. |
926 |
<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 |
927 |
<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 |
928 |
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 |
929 |
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. |
930 |
automate it by running <c>rc-update add laptop-mode battery</c>. |
735 |
</warn> |
931 |
</p> |
736 |
|
932 |
|
737 |
</body> |
933 |
</body> |
738 |
</section> |
934 |
</section> |
Lines 1049-1054
Link Here
|
1049 |
</p> |
1245 |
</p> |
1050 |
|
1246 |
|
1051 |
<p> |
1247 |
<p> |
|
|
1248 |
<e>Q:</e> When configuring the kernel, powersave, performance and userspace |
1249 |
governors show up, but that ondemand thing is missing. Where do I get it? |
1250 |
</p> |
1251 |
|
1252 |
<p> |
1253 |
<e>A:</e> The ondemand governor is only included in recent kernel sources. Try |
1254 |
updating them. |
1255 |
</p> |
1256 |
|
1257 |
<p> |
1052 |
<e>Q:</e> Battery life time seems to be worse than before. |
1258 |
<e>Q:</e> Battery life time seems to be worse than before. |
1053 |
</p> |
1259 |
</p> |
1054 |
|
1260 |
|