The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Поиск:  Каталог документации

3. Power Management Techniques

The basic goal of any power management technique is to reduce an entity's consumption. In the case of laptop power management, our focus is on decreasing CPU and hard drive usage. To make things a bit simpler, this is broken down into obvious, semi-obvious, and non-obvious techniques. Granted, your mileage may vary.

3.1. Power saving - The obvious stuff

There are some obvious things that you can do to reduce your system's power consumption:

3.2. Power saving - The semi-obvious stuff

hdparm is a Linux shell utility that can be used to improve the performance and power management of various IDE drives. If it's not included with your system, you can fetch the source from http://freshmeat.net/redir/hdparm/4062/url_homepage/hardware For example, running `hdparm -B128 -c1 -d1 -m16 -S60 -u1 -K1 -k1 -W1 /dev/hda` gains me tremendous performance with added power savings. Note that your mileage may vary, and you'll want to adjust this for your specific system to prevent data loss (especially the -B and -m flags!).

Pop open an xterm window and try running `top -i` while your system isn't doing much of anything. Look for any active processes; any that show up are potential battery drainers. Identification is the first step; the tricky part is determining whether or not you should disable a given daemon or simply modify its behavior.

Examine your syslog.conf file for unnecessary logging. If you don't want to log any system activity, consider disabling syslogd and klogd entirely. If you tend to debug programs from time to time, you can modify or minimize the amount of logging your system will do. For example, to log only messages with a priority of info or higher except for the mail facility, which will be logged only with priorities of error or higher, you can try this:

	*.info;mail.none		-/var/log/messages
	mail.err			-/var/log/messages

The hyphen before the logfile tells the system not to sync the log file each time after logging a system message. While you could loose logfile data in the event of a system crash, buffering your data to minimize writes to your hard drive will grant multiple blessings upon your battery life!

If you want your screen to actually turn off rather than use the fake blanking effect, you'll have to edit your XF86Config file. In the ServerLayout section, you can add four options:

	Option "BlankTime"	"time"	# Blank the screen
	Option "StandbyTime" 	"time"	# Turn off screen
	Option "SuspendTime"	"time"	# Full hibernation
	Option "OffTime"	"time"	# Turn off DPMS monitor

If you have a Dell Inspiron or Latitude, try enabling CONFIG_I8K when recompiling the kernel and you'll be able to access information about your laptop's performance from /proc/i8k. For example, running `cat /proc/i8k` on my Dell Latitude C400 reveals:

	1.0 A06 5X1F21 63 -22 0 1 3540 -1 0
Which can roughly be translated to [i8k ver] [BIOS] [serial #] [CPU temp] [Lfan status] [Rfan status] [Lfan rpm] [Rfan rpm] [ac status] [buttons status]. Significant information from this example would indicate that my CPU is currently running at 63 degrees 0 and that my right fan is on and running at 3,540 rpm.

After recompiling the kernel to support either APM or ACPI, you can gain added power-savings benefits by recompiling the Linux PCMCIA drivers as well. The package will detect that you have APM enabled (even if you are using ACPI, go figure) and will automatically add power management support within the PCMCIA system itself. This should be evidenced during the PCMCIA `make config` step with an output similar to, "Power management (APM) support is enabled". The PCMCIA source files are available from http://sourceforge.net/projects/pcmcia-cs/

Whether or not power management support is configured in your PCMCIA package, you should use `cardctl suspend` before suspending your laptop, and `cardctl resume` after resuming to cleanly shut down and restart your PCMCIA cards. This will not work with a modem that is in use, because the serial driver isn't able to save and restore the modem operating parameters. Some drivers, notably the PCMCIA SCSI drivers, cannot recover from a suspend/resume cycle. When using a PCMCIA SCSI card, always use `cardctl eject` prior to suspending the system. Many people refer to this as "apmcontinue" and you can use this as a key word search with your favorite search engine to find custom-made scripts for this.

Suspend-to-Disk is a tricky subject. The chief problem with it is twofold: First, it doesn't work properly under Linux ACPI (yet). Second, every laptop vendor seems to vary the methods used to create a "suspend-to-disk" or "hibernate" file, so there is no uniformity. For example, the Dell Inspiron 8000 uses Dell's phdisk utility, while the Latitude C400 requires Dell's mks2d utility. If you're really interested in getting suspend-to-disk working under Linux, find out if your vendor provides a suspend-to-disk (s2d) utility. Determine if it requires it's own partition, if that partition must be primary (not extended), etc. Most reports of successful s2d instances involve using a s2d partition on the first cylinder of the primary hard drive (e.g., /dev/hda1). If you use a boot manager that writes to the Master Boot Record (MBR), you'll probably need to modify it to write to the boot partition instead as some s2d utilities mark the s2d partition as active when suspending, which will 0 confuse both you and your boot manager. If you already have installed Linux and have never made a suspend partition, there is still hope. Using fips, parted, Partition Magic, or other similar utility to move your partition ahead leaving free space at the first cylinder of your hard drive. Then use your vendor supplied utility to format the partition.

3.3. Power saving - The not-so-obvious stuff

Disable your swap file in /etc/fstab to reduce hard drive access. If you've got lots of memory, this is definitely the way to go. One way to tell if you need your swap file is to enable it, use your system for a period of time, and examine /proc/meminfo and /proc/swaps (or just run `top` if this is unsettling to you) to determine how much free memory you've got on average, and whether or not your swap file is even being utilized. For example, my laptop has a ridiculous 512 MB RAM, and on any given day still has an average of 150 MB RAM unused with no swap file whatsoever.

Compile your kernel with TMPFS (temporary file system) enabled and mount your /tmp directory using it. The useful bit here is that nothing will be written to your hard drive on this mount point as it will act like a RAM disk (however nothing will be saved either!) The advantage of tmpfs over the more traditional ramfs is that it lives in the kernel internal cache and grows and shrinks to accommodate the files placed there. See your kernel's Documentation/filesystems/tmpfs.txt for full information. An example /etc/fstab with 100MB temporary ram file mounted on /tmp would look like:

	tmpfs	/tmp	tmpfs	size=100m	0	0
However this might create problems if you're downloading a large program and your download manager uses the /tmp directory to hold files prior to full download.

Boot your system and list the currently loaded modules with lsmod. Anything listed here most likely needs to be loaded on a regular basis; compiling these in as part of your kernel rather than as loadable modules may help to decrease the amount of time they must be loaded from disk, and to a very minor degree, decrease the amount of disk access required to start your system.

Examine your crontab settings to see if anything is being run on a regular basis. Comment out any unnecessary items. Don't forget to examine every user's crontab, including the user 'nobody'. If you don't need to schedule any background activity, consider disabling crond alltogether. The same advice goes for atd.

If you run httpd to test and/or develop web pages, try altering the values of MinSpareServers and StartServers to 1. Don't define any CustomLogging or at least increase the value of LogLevel to warn. If you're really sure of yourself, you can change the ErrorLog directive to point to /dev/null.

One popular practice in the past involved modifying the update/bdflush daemon to change the frequency of flushing the filesystem buffers (sync). However, newer kernels do not use a user space update daemon, so any modifications you make here will simply never take effect.




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру