Contents
Power management is especially important on laptop computers, but is also useful on other systems. ACPI (advanced configuration and power interface) is available on all modern computers (laptops, desktops, and servers). Power management technologies require suitable hardware and BIOS routines. Most laptops and many modern desktops and servers meet these requirements. It is also possible to control CPU frequency scaling to save power or decrease noise.
Power saving functions are not only significant for the mobile use of laptops, but also for desktop systems. The main functions and their use in ACPI are:
not supported.
This mode writes the entire system state to the RAM. Subsequently, the entire system except the RAM is put to sleep. In this state, the computer consumes very little power. The advantage of this state is the possibility of resuming work at the same point within a few seconds without having to boot and restart applications. This function corresponds to the ACPI state S3. The support of this state is still under development and therefore largely depends on the hardware.
In this operating mode, the entire system state is written to the hard disk and the system is powered off. There must be a swap partition at least as big as the RAM to write all the active data. Reactivation from this state takes about 30 to 90 seconds. The state prior to the suspend is restored. Some manufacturers offer useful hybrid variants of this mode, such as RediSafe in IBM Thinkpads. The corresponding ACPI state is S4. In Linux, suspend to disk is performed by kernel routines that are independent from ACPI.
ACPI checks the battery charge status and provides information about it. Additionally, it coordinates actions to perform when a critical charge status is reached.
Following a shutdown, the computer is powered off. This is especially important when an automatic shutdown is performed shortly before the battery is empty.
In connection with the CPU, energy can be saved in three different ways: frequency and voltage scaling (also known as PowerNow! or Speedstep), throttling and putting the processor to sleep (C states). Depending on the operating mode of the computer, these methods can also be combined.
ACPI (advanced configuration and power interface) was designed to enable the operating system to set up and control the individual hardware components. ACPI supersedes both PnP and APM. It delivers information about the battery, AC adapter, temperature, fan and system events, like “close lid” or “battery low.”
The BIOS provides tables containing information about the individual
components and hardware access methods. The operating system uses this
information for tasks like assigning interrupts or activating and
deactivating components. Because the operating system executes commands
stored in the BIOS, the functionality depends on the BIOS implementation.
The tables ACPI can detect and load are reported in
/var/log/boot.msg
. See
Section 31.2.3, “Troubleshooting” for more information about
troubleshooting ACPI problems.
The CPU can save energy in three ways. Depending on the operating mode of the computer, these methods can be combined. Saving energy also means that the system heats up less and the fans are activated less frequently.
PowerNow! and
Speedstep are the designations AMD and
Intel use for this technology. However, this technology is also
applied in processors of other manufacturers. The clock frequency of
the CPU and its core voltage are reduced at the same time, resulting
in more than linear energy savings. This means that when the
frequency is halved (half performance), far less than half of the
energy is consumed. This technology is independent from ACPI. There
are two main approaches to performing CPU frequency scaling—by
the kernel itself or by a userspace application. Therefore, there are
different kernel governors that can be set below
/sys/devices/system/cpu/cpu*/cpufreq/
.
If the userspace governor is set, the kernel gives the control of CPU frequency scaling to a userspace application, usually a daemon. In openSUSE distributions, this daemon is the powersaved package. When this implementation is used, the CPU frequency is adjusted in regard to the current system load. By default, one of the kernel implementations is used. However, on some hardware or in regard to specific processors or drivers, the userspace implementation is still the only working solution.
This is the kernel implementation of a dynamic CPU frequency policy and should work on most systems. As soon as there is a high system load, the CPU frequency is immediately increased. It is lowered on a low system load.
This governor is similar to the on demand implementation, except that a more conservative policy is used. The load of the system must be high for a specific amount of time before the CPU frequency is increased.
The cpu frequency is statically set to the lowest possible.
The cpu frequency is statically set to the highest possible.
This technology omits a certain percentage of the clock signal
impulses for the CPU. At 25% throttling, every fourth impulse is
omitted. At 87.5%, only every eighth impulse reaches the processor.
However, the energy savings are a little less than linear. Normally,
throttling is only used if frequency scaling is not available or to
maximize power savings. This technology must be controlled by a
special process, as well. The system interface is
/proc/acpi/processor/*/throttling
.
The operating system puts the processor to sleep whenever there is no
activity. In this case, the operating system sends the CPU a
halt command. There are three states: C1, C2, and
C3. In the most economic state, C3, even the synchronization of the
processor cache with the main memory is halted. Therefore, this state
can only be applied if no other device modifies the contents of the
main memory via bus master activity. Some drivers prevent the use of
C3. The current state is displayed in
/proc/acpi/processor/*/power
.
Frequency scaling and throttling are only relevant if the processor is busy, because the most economic C state is applied anyway when the processor is idle. If the CPU is busy, frequency scaling is the recommended power saving method. Often the processor only works with a partial load. In this case, it can be run with a lower frequency. Usually, dynamic frequency scaling controlled by the kernel on demand governor or a daemon, such as powersaved, is the best approach. A static setting to a low frequency is useful for battery operation or if you want the computer to run cool or be quiet.
Throttling should be used as the last resort, for example, to extend the battery operation time despite a high system load. However, some systems do not run smoothly when they are throttled too much. Moreover, CPU throttling does not make sense if the CPU has little to do.
The range of more or less comprehensive ACPI utilities includes tools
that merely display information, like the battery charge level and the
temperature (acpi, klaptopdaemon, etc.), tools that facilitate the
access to the structures in /proc/acpi
or that
assist in monitoring changes (akpi, acpiw, gtkacpiw) and tools for
editing the ACPI tables in the BIOS (package
acpica
).
There are two different types of problems. On one hand, the ACPI code of the kernel may contain bugs that were not detected in time. In this case, a solution will be made available for download. More often, the problems are caused by the BIOS. Sometimes, deviations from the ACPI specification are purposely integrated in the BIOS to circumvent errors in the ACPI implementation of other widespread operating systems. Hardware components that have serious errors in the ACPI implementation are recorded in a blacklist that prevents the Linux kernel from using ACPI for these components.
The first thing to do when problems are encountered is to update the BIOS. If the computer does not boot at all, one of the following boot parameters may be helpful:
Do not use ACPI for configuring the PCI devices.
Only perform a simple resource configuration. Do not use ACPI for other purposes.
Disable ACPI.
![]() | Problems Booting without ACPI |
---|---|
Some newer machines (especially SMP systems and AMD64 systems) need ACPI for configuring the hardware correctly. On these machines, disabling ACPI can cause problems. |
Sometimes, the machine is confused by hardware that is attached over USB or FireWire. If a machine refuses to boot, unplug all unneeded hardware and try again.
Monitor the boot messages of the system with the command dmesg
| grep -2i acpi
(or all messages, because the
problem may not be caused by ACPI) after booting. If an error occurs
while parsing an ACPI table, the most important table—the DSDT
(Differentiaed System Description Table)—can
be replaced with an improved version. In this case, the faulty DSDT of
the BIOS is ignored. The procedure is described in
Section 31.4, “Troubleshooting”.
In the kernel configuration, there is a switch for activating ACPI debug messages. If a kernel with ACPI debugging is compiled and installed, experts searching for an error can be supported with detailed information.
If you experience BIOS or hardware problems, it is always advisable to contact the manufacturers. Especially if they do not always provide assistance for Linux, they should be confronted with the problems. Manufacturers will only take the issue seriously if they realize that an adequate number of their customers use Linux.
http://tldp.org/HOWTO/ACPI-HOWTO/ (detailed ACPI HOWTO, contains DSDT patches)
http://www.intel.com/technology/iapc/acpi/index.htm (Advanced Configuration & Power Interface)
http://www.lesswatts.org/projects/acpi/ (the ACPI4Linux project at Sourceforge)
http://acpi.sourceforge.net/dsdt/index.php (DSDT patches by Bruno Ducrot)
In Linux, the hard disk can be put to sleep entirely if it is not needed or it can be run in a more economic or quieter mode. On modern laptops, you do not need to switch off the hard disks manually, because they automatically enter an economic operating mode whenever they are not needed. However, if you want to maximize power savings, test some of the following methods.
The hdparm command can be used to modify various hard
disk settings. The option -y
instantly switches the hard
disk to the standby mode. -Y
puts it to sleep.
hdparm -S x
causes the hard disk to
be spun down after a certain period of inactivity. Replace
x
as follows: 0
disables
this mechanism, causing the hard disk to run continuously. Values from
1
to 240
are multiplied by 5
seconds. Values from 241
to 251
correspond to 1 to 11 times 30 minutes.
Internal power saving options of the hard disk can be controlled with the
option -B
. Select a value from 0
to
255
for maximum saving to maximum throughput. The
result depends on the hard disk used and is difficult to assess. To make
a hard disk quieter, use the option -M
. Select a value
from 128
to 254
for quiet to fast.
Often, it is not so easy to put the hard disk to sleep. In Linux, numerous processes write to the hard disk, waking it up repeatedly. Therefore, it is important to understand how Linux handles data that needs to be written to the hard disk. First, all data is buffered in the RAM. This buffer is monitored by the pdflush daemon. When the data reaches a certain age limit or when the buffer is filled to a certain degree, the buffer content is flushed to the hard disk. The buffer size is dynamic and depends on the size of the memory and the system load. By default, pdflush is set to short intervals to achieve maximum data integrity. It checks the buffer every 5 seconds and writes the data to the hard disk. The following variables are interesting:
/proc/sys/vm/dirty_writeback_centisecs
Contains the delay until a pdflush thread wakes up (in hundreths of a second).
/proc/sys/vm/dirty_expire_centisecs
Defines after which timeframe a dirty page should be written out latest. Default is 3000, which means 30 seconds.
/proc/sys/vm/dirty_background_ratio
Maximum percentage of dirty pages until pdflush begins to write them. Default is 5%.
/proc/sys/vm/dirty_ratio
When the dirty page exceeds this percentage of the total memory, processes are forced to write dirty buffers during their time slice instead of continuing to write.
![]() | Impairment of the Data Integrity |
---|---|
Changes to the pdflush daemon settings endanger the data integrity. |
Apart from these processes, journaling file systems, like
ReiserFS
,
Ext3
,
Ext4
and others write
their metadata independently from pdflush, which also prevents the hard
disk from spinning down. To avoid this, a special kernel extension has
been developed for mobile devices. See
/usr/src/linux/Documentation/laptop-mode.txt
for
details.
Another important factor is the way active programs behave. For example, good editors regularly write hidden backups of the currently modified file to the hard disk, causing the disk to wake up. Features like this can be disabled at the expense of data integrity.
In this connection, the mail daemon postfix makes use of the variable
POSTFIX_LAPTOP
. If this variable is set to
yes
, postfix accesses the hard disk far less
frequently.
All error messages and alerts are logged in the file
/var/log/messages
. If you cannot find the needed
information, increase the verbosity of the messages of powersave using
DEBUG
in the file
/etc/sysconfig/powersave/common
. Increase the value
of the variable to 7
or even 15
and
restart the daemon. The more detailed error messages in
/var/log/messages
should help you to find the error.
The following sections cover the most common problems with powersave and
the different sleep modes.
If you experience problems with ACPI, use the command
dmesg|grep -i acpi
to search the
output of dmesg for ACPI-specific messages. A BIOS
update may be required to resolve the problem. Go to the home page of
your laptop manufacturer, look for an updated BIOS version, and install
it. Ask the manufacturer to comply with the latest ACPI specification.
If the errors persist after the BIOS update, proceed as follows to
replace the faulty DSDT table in your BIOS with an updated DSDT:
Download the DSDT for your system from
http://acpi.sourceforge.net/dsdt/index.php.
Check if the file is decompressed and compiled as shown by the file
extension .aml
(ACPI machine language). If this is
the case, continue with step 3.
If the file extension of the downloaded table is
.asl
(ACPI source language), compile it with iasl
(package acpica
). Enter the
command iasl -sa file.asl
.
Copy the file DSDT.aml
to any location
(/etc/DSDT.aml
is recommended). Edit
/etc/sysconfig/kernel
and adapt the path to the
DSDT file accordingly. Start mkinitrd (package
mkinitrd
). Whenever
you install the kernel and use mkinitrd to create
an initrd
, the modified DSDT is integrated and
loaded when the system is booted.
Refer to the kernel sources
(kernel-source
) to see if your
processor is supported. You may need a special kernel module or module
option to activate CPU frequency control. This information is available
in /usr/src/linux/Documentation/cpu-freq/*
.
ACPI systems may have problems with suspend and standby due to a faulty DSDT implementation (BIOS). If this is the case, update the BIOS.
When the system tries to unload faulty modules, the system is arrested
or the suspend event is not triggered. The same can also happen if you
do not unload modules or stop services that prevent a successful
suspend. In both cases, try to identify the faulty module that prevented
the sleep mode. The log file
/var/log/pm-suspend.log
contains detailed
information about what is going on and where possible errors are. Modify
the SUSPEND_MODULES
variable in
/usr/lib/pm-utils/defaults
to unload problematic
modules prior to a suspend or standby.
Refer to http://en.opensuse.org/Pm-utils and http://en.opensuse.org/S2ram to get more detailed information on how to modify the suspend and resume process.
http://www.intel.com/technology/iapc/acpi/index.htm (Advanced Configuration & Power Interface)
http://www.lesswatts.org/projects/acpi/ (the ACPI4Linux project at Sourceforge)
http://www.poupinou.org/acpi/ (DSDT patches by Bruno Ducrot)
http://en.opensuse.org/S2ram—How to get Suspend to RAM working
http://en.opensuse.org/Pm-utils—How to modify the general suspend framework