--- power-management-guide-1.17.xml 2004-10-15 22:33:00.000000000 +0200 +++ power-management-guide.xml 2004-12-01 22:58:16.161976088 +0100 @@ -5,7 +5,7 @@
-Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk
-and Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop,
-enable the appropriate section.
+Decide yourself whether you want to enable Software Suspend, Suspend-to-Disk and
+Sleep States (see below). If you own an ASUS, Medion or Toshiba laptop, enable
+the appropriate section. Recent kernel versions (2.6.9 and later) include an
+
+The kernel has to know how to enable CPU frequency scaling on your processor. As
+each type of CPU has a different interface, you've got to choose the right
+driver for your processor. Be careful here - enabling
@@ -230,70 +240,106 @@
Typical ACPI events are closing the lid, changing the power source or pressing
-the sleep button. Every acpi event recognized by the kernel is catched by acpid
-which calls
-#!/bin/sh - -set $* - -group=${1/\/*/} -action=${1/*\//} - -# runlevel to use in AC mode -RLVL_AC="default" -# runlevel to use in battery mode -RLVL_BATTERY="battery" - -# file indicating the AC state. Verify the filename before using -AC_STATE="/proc/acpi/ac_adapter/AC/state" -# this string means running on AC -AC_ON="on-line" -# this string means running on batteries -AC_OFF="off-line" +the sleep button. Create the following files to switch betweendefault +andbattery runlevel depending on the power source: + + ++#!/bin/bash + +# This runlevel will be used in AC mode +#RUNLEVEL_AC="default" + +# This runlevel will be used in battery mode +#RUNLEVEL_BATTERY="battery" + +# This file indicates the AC state +# It's location may vary on your system. The script checks for +# /proc/acpi/ac_adapter/AC/state, /proc/acpi/ac_adapter/AC0/state, +# /proc/acpi/ac_adapter/AC1/state and /proc/acpi/ac_adapter/AC2/state +# If it is something else on your system, uncomment the next line +# and change appropriately. +#AC_STATE="/proc/acpi/ac_adapter/AC/state" ++ ++#!/bin/bash + +RUNLEVEL_AC="default" +RUNLEVEL_BATTERY="battery" + +if [ -f '/proc/acpi/ac_adapter/AC0/state' ] +then + AC_STATE="/proc/acpi/ac_adapter/AC0/state" +elif [ -f '/proc/acpi/ac_adapter/AC1/state' ] +then + AC_STATE="/proc/acpi/ac_adapter/AC1/state" +elif [ -f '/proc/acpi/ac_adapter/AC2/state' ] +then + AC_STATE="/proc/acpi/ac_adapter/AC2/state" +else + AC_STATE="/proc/acpi/ac_adapter/AC/state" +fi + + +source /etc/acpi/switch_runlevel.conf function SwitchRunlevel() { - if [[ "$(grep ${AC_OFF} ${AC_STATE})" != "" && "$(cat /var/lib/init.d/softlevel)" != "${RLVL_BATTERY}" ]] + + if [ ! -d "/etc/runlevels/${RUNLEVEL_AC}" ] then - logger "Switching to ${RLVL_BATTERY} runlevel" - /sbin/rc ${RLVL_BATTERY} - elif [[ "$(grep ${AC_ON} ${AC_STATE})" != "" && "$(cat /var/lib/init.d/softlevel)" != "${RLVL_AC}" ]] + logger "${0}: Runlevel ${RUNLEVEL_AC} does not exist. Aborting." + exit 1 + fi + + + if [ ! -d "/etc/runlevels/${RUNLEVEL_BATTERY}" ] then - logger "Switching to ${RLVL_AC} runlevel" - /sbin/rc ${RLVL_AC} + logger "${0}: Runlevel ${RUNLEVEL_BATTERY} does not exist. Aborting." + exit 1 + fi + + if [ ! -f "${AC_STATE}" ] + then + logger "${0}: File ${AC_STATE} does not exist. Aborting" + exit 1 + fi + + + if [[ "$(grep off-line ${AC_STATE})" != "" && "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_BATTERY}" ]] + then + logger "Switching to ${RUNLEVEL_BATTERY} runlevel" + /sbin/rc ${RUNLEVEL_BATTERY} + elif [[ "$(grep on-line ${AC_STATE})" != "" && "$(cat /var/lib/init.d/softlevel)" != "${RUNLEVEL_AC}" ]] + then + logger "Switching to ${RUNLEVEL_AC} runlevel" + /sbin/rc ${RUNLEVEL_AC} fi } +++event=ac_adapter.* +action=/etc/acpi/actions/pmg_ac_adapter.sh %e +-case "$group" in - battery) - case "$action" in - battery) - SwitchRunlevel - ;; - *) - logger "ACPI group battery / action $action is not defined" - ;; - esac - ;; - - ac_adapter) - case "$action" in - ac_adapter) - SwitchRunlevel - ;; - *) - logger "ACPI group ac_adapter / action $action is not defined" - ;; - esac - ;; - *) - logger "ACPI group $group / action $action is not defined" - ;; -esac ++event=battery.* +action=/etc/acpi/actions/pmg_battery.sh %e ++ ++#! /bin/bash + +source /etc/acpi/switch_runlevel.sh +SwitchRunlevel ++ ++#! /bin/bash + +source /etc/acpi/switch_runlevel.sh +SwitchRunlevel@@ -313,7 +359,7 @@
# Fake acpi event to switch runlevel if running on batteries -/etc/acpi/default.sh "battery/battery" +/etc/acpi/actions/pmg_battery.sh "battery/battery"@@ -328,6 +374,43 @@
+ + + +CPU Power Management + +Some technical terms + + ++CPU frequency scaling brings up some technical terms that might be unknown to +you. Here's a quick introduction. +
+ ++First of all, the kernel has to be able to change the processor's frequency. The +
+ +CPUfreq processor driver knows the commands to do it on your CPU. Thus +it's important to choose the right one in your kernel. You should already have +done it above. Once the kernel knows how to change frequencies, it has to know +which frequency it should set. This is done according to thepolicy which +consists ofCPUfreq policy and agovernor . A CPUfreq policy are +just two numbers which define a range the frequency has to stay between - +minimal and maximal frequency. The governor now decides which of the available +frequencies in between minimal and maximal frequency to choose. For example, the +powersave governor always chooses the lowest frequency available, the +performance governor the highest one. Theuserspace governor makes +no decision but chooses whatever the user (or a program in userspace) wants - +which means it reads the frequency from +/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed . ++This doesn't sound like dynamic frequency changes yet and in fact it isn't. +Dynamics however can be accomplished with various approaches. For example, +the
+ + +ondemand governor makes its decisions depending on the current CPU +load. The same is done by various userland tools likecpudyn , +speedfreq ,powernowd and many more. ACPI events can be used to +enable or disable dynamic frequency changes depending on power source. +Setting the frequency manually @@ -394,39 +477,101 @@The above is quite nice, but not doable in daily life. Better let your system -set the appropriate frequency automatically. A couple of user space programs -like to do it for you. The following table gives a quick overview to help you -decide on one of them. +set the appropriate frequency automatically. There are many different approaches +to do this. The following table gives a quick overview to help you decide on one +of them. It's roughly seperated in three categories
kernel for approaches +that only need kernel support,daemon for programs that run in the +background andgraphical for programs that provide a GUI for easy +configuration and changes.@@ -548,9 +693,17 @@
+ Name -Pro -Con +Category +Switch decision +Kernel governors +Further governors +Comments ++ 'ondemand' governor +Kernel +CPU load +N.A. +N.A. ++ Further tuning through files in + /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ . Still requires + userland tools (programs, scripts) if governor switching or similar is + desired. +- cpudyn Also supports disk standby -+ Daemon +CPU load +None +Dynamic ++ Also supports disk standby - notice however that laptop mode in most + cases will do a better job. +- +- cpufreq Sophisticated setup possible -Complicated setup ++ cpufreqd Daemon +Battery state, CPU load, running programs +All available +None ++ Sophisticated (but also complicated) setup. An optimal configuration + requires detailed knowledge of your system. + ++ + +powernowd +Daemon +CPU load +None +Passive, sine, aggressive ++ Supports SMP. + + + speedfreq Daemon +CPU load +None +Dynamic, powersave, performance, fixed speed ++ Small yet powerful with an useful client/server interface. Requires a 2.6 + kernel. + ++ + gtk-cpuspeedy Graphical +None +None +None - Small yet powerful -
- Useful client/server interface + Gnome application, a graphical tool to set CPU frequency manually. It does + not offer any automation and is mainly listed for the sake of completeness.Kernel 2.6 series only - - powernowd Supports SMP -+ klaptopdaemon +Graphical +Battery state +All available +None ++ KDE only, 'ondemand' governor required for dynamic frequency scaling. + speedfreq .+ @@ -1049,6 +1200,16 @@Verifying the result + + +The last thing to check is that your new policies do a good job. An easy way to -do so is monitoring the CPU speed while working with your laptop: +do so is monitoring CPU speed while working with your laptop:
@@ -716,23 +869,21 @@-To start and stop laptop-mode, create a script /etc/init.d/laptop-mode. You can -take the one included in -
/usr/src/linux/Documentation/laptop-mode.txt . Onces it's ready, -make sure it gets called. +Besides kernel support you also need a script that controls starting and +stopping of laptop-mode. The packagelaptop-mode-tools contains it.-# rc-update add laptop-mode battery +# emerge laptop-mode-tools--Once again: Be careful with sleep/spin down settings of your hard drive. -Setting it to small values might wear out your drive and lose warranty. Be sure -to read the documentation in laptop-mode.txt. Make sure to stop laptop-mode -before your battery runs out of power and data gets written to disk - otherwise -you will at least lose the last 10 minutes of your work. - ++
laptop-mode-tools has it's configuration file in +/etc/laptop-mode/laptop-mode.conf . Adjust it the way you like it, +it's well commented. If you haveapm oracpi in your USE flags, +laptop-mode will be started automatically in battery mode. Otherwise you can +automate it by runningrc-update add laptop-mode battery . ++
+ +Q: When configuring the kernel, powersave, performance and userspace +governors show up, but that ondemand thing is missing. Where do I get it? ++
+ +A: The ondemand governor is only included in recent kernel sources. Try +updating them. +
Q: Battery life time seems to be worse than before.