NetBSD Documentation:Power Management for Laptops |
Currently most of the information on this page is i386 specific. When NetBSD starts supporting more laptop architectures, then this documentation will be expanded to cover the power management features for those architectures.
APM specifies two different power saving modes: standby and suspend. What this actually does at a hardware level is dependent on the particular laptop being used. "standby" typically means a light sleep, which consumes more power and is quicker to restore from than the "suspend" mode. Typically the APM timers for standby and suspend mode are configured in a machine's BIOS. After a machine has been determined "idle" for the appropriate period of time, the BIOS will request that the operating system go into the appropriate power saving mode.
At the NetBSD level, there are three components to APM support. The kernel driver, which is the interface to the APM BIOS, the apm daemon apmd, which interfaces with the APM kernel driver and runs the userland event scripts, and the command line program apm, which interfaces to apmd and can be used to query battery level or initiate a system suspend.
The way power management events generally flow is:
apm0 at mainbus0 # Advanced power managementSee how to build a kernel for details on how to build your own kernels.
Once you have a kernel with the APM kernel driver built, run the apm daemon (apmd) at boot time by setting the apmd variable /etc/rc.conf to YES.
Once you've done both of these steps, you can use the apm utility to interface with the APM system. For example:
% apm Battery charge state: high Battery remaining: 98 percent A/C adapter state: not connected Power management enabledRead apm(8) and apmd(8) for more detailed information on how to use the APM support.
Some things you might want to do in a standby or suspend script are:
New in NetBSD 1.4 is the atactl command. This command can be used to control power management features of ATA devices (more commonly known as IDE). You can use the setidle option of atactl to set the standby timer used to control disk spindown. See atactl(8) for more specific information.
If you're wondering what value to set for the ATA standby timer, I would recommend reading the following papers:
One problem with setting a low value value for the standby timer is that by default NetBSD writes to the disk often enough that the disk is constantly spinning up (at least once every 30 seconds, or however often update runs). It turns out the most common cause of this is the filesystem updating the last access timestamps on files and the last modified time on device special files (such as pseudo-ttys). This behavior can be suppressed by the mount(8) options noatime and (new in NetBSD 1.4) nodevmtime. If you decide to do this as well, you might want to also change or remove completely the atrun job inside of cron - by default it will run once every 10 minutes and append an entry to the cron log file, causing a disk spinup.
It is also desirable in some circumstances to use different or disable completely power management settings depending if one is powered by line power or battery. A new feature in NetBSD 1.4 is two additional apmd scripts: line and battery. These scripts are run by apmd whenever APM detects a power source change. The line script is run upon transition to line/AC power, and the battery script is run upon transition to battery power. The script corresponding to the current power source is also run when apmd is first started.
You can place commands inside of these scripts to change the power management settings when using battery or line power. Here are some example scripts:
#!/bin/sh mount -u / mount -u /usr atactl wd0 setidle 0
#!/bin/sh mount -u -o async,noatime,nodevmtime / mount -u -o async,noatime /usr atactl wd0 setidle 5
Another useful feature is the -a flag to apmd which will cause apmd to ignore standby or suspend events if the machine is currently on line power.
16 * 256 * 8k(block size)
= ~32mb
Squid will slowly work its way through this, each time a new directory is read that it missed in the buffer cache. Tweaking squid.conf to reduce the number of directories should fix the problem of a laptop disk spinning up.
|
|