- About Us
When announcing the PowerTOP utility on the Linux kernel mailing list last week, Intel's Arjan van de Ven said that the tickless-idle feature in the latest 2.6.21 kernel helps save a lot of power by allowing the processor to be idle for long periods of time, instead of waking up every millisecond for the timer tick.
But there's more to a Linux distribution than the kernel; applications may also have tunables to help save power. How do you see which apps are hogging the processor and consuming power? The top utility gives the percentage of CPU and memory individual processes are taking, but that doesn't help much, since there's no power-related information there. That's where PowerTOP comes in.
Installing and using PowerTOP
PowerTOP needs the tickless idle (CONFIG_NO_HZ) parameter enabled in the kernel for best performance. This parameter is only in kernels 2.6.21 and above. It also needs the CONFIG_TIMER_STATS option enabled in the kernel in order to give you detailed statistics. Since most distributions have a custom kernel and maintain a development branch, grabbing a kernel using the appropriate repositories should be enough. I successfully run PowerTOP on Fedora Core 7 Test 4, which reports the kernel to be 2.6.20.
PowerTOP is already in the repositories of several distributions, but it's also easy to install from source. In fact, I suggest installing from source, since the app is under heavy development and new improved versions could take some time to creep into repositories.
|Interview: Arjan van de Ven|
To get details about the PowerTOP project and find out about its future, I emailed a few questions to project leader Arjan van de Ven of Intel.
NewsForge: Could you give us a little background on the project?
Arjan van de Ven: Power consumption of computers is a hot topic right now, be it servers for data centers or laptops for the mobile workforce. The tickless idle functionality as added by Thomas Gleixner and Ingo Molnar is a significant step forward in this regard on the Linux kernel side.
However, when measuring this new feature, we saw disappointing results: while the kernel wouldn't wake up every millisecond, user space would just do this instead. These frequent wake-ups prevented the OS from using all the advanced energy-saving features our hardware experts added to Intel's products, and it reduced the battery life of my own Linux laptop ... so there was some personal incentive for me to work on this as well.
NF: What are the objectives of the project? I see it divided between the PowerTOP utility and making application patches to save power.
AV: The primary objective is getting Linux to use less power, to have Linux make maximum use of the power-saving features within your computer. Intel can't do this alone; we want and need to cooperate with the wider Linux community. Providing fixes and patches for features is one thing, and we do that and have been doing that for a long time. With PowerTOP, we provide a tool that enables developers to quickly see issues on their own setups and to fix them. We will continue to use the tool ourselves, and that's where most of the patches to the other projects came from.
NF: Are you looking for community participation? What are the areas where users can contribute?
AV: Absolutely. This is already happening on the IRC channel (#powertop on irc.oftc.net); there usually are between 30 and 50 people exchanging ideas, patches for fixing issues, and bug reports to PowerTOP. Several of these active folks are also contributing patches to PowerTOP to fix bugs in it. Developers are contributing patches to fix issues found in various open source projects, end users are reporting things they see on their machines and are exchanging tunables they found. If there's good ideas that work well, we put them on the Web site for others to use on their systems.
In addition, I'm hoping (and we're seeing that happen already with the KDE and GNOME projects) that the various open source projects start using PowerTOP to check and fix their own software.
NF: As of now, the project doesn't have much documentation. There's a mailing list and an IRC channel -- any forums/wiki/static HTML documentation in the pipeline?
AV: We're constantly updating the Web site with suggestions and tips and tricks from users and with answers to questions people ask us on IRC or on the mailing list. We're working on a page aimed at developers of open source projects on how to diagnose sightings and ideas for how to code certain constructs in their applications that we see as common pattern.
The entire documentation on the Web site is a "write as we go" environment, with most of the input and suggestions coming from the IRC channel and the mailing list.
NF: From what I can gather, a 64-bit version of PowerTOP is in the pipeline. What more can we expect? More patches?
AV: PowerTOP already works on 64-bit, it's just the tickless kernel feature that isn't merged yet into the mainline kernel (there's a patch on lkml though). To get any real power savings, this tickless feature is needed. But to find software issues, you can do that on 64-bit today.
Going forward, the biggest outstanding feature request we have for PowerTOP is for it to show which applications keep the disk busy. Another enhancement we'll be looking at is increasing the number of "live" suggestions PowerTOP makes while running, and possibly even "press the <X> key to activate this suggestion now" functionality.
Download the latest PowerTOP tarball (version 1.2 at the time of writing), and uncompress it with
tar zxvf powertop-1.2.tar.gz. Change into the directory and compile the utility with the
make command. Once it's done compiling, change to the root user and execute the utility with
./powertop. It will gather information about the system for five seconds before launching.
The PowerTOP screen will vary slightly depending on whether you are running it on a desktop or a laptop. Laptop users will get the C-STATE information at the top. As per PowerTOP's Web site, "C-states are operating modes of the CPU when it's idle. The higher the C-state number, the less power is used by the CPU; however, the longer it will take to get the CPU back to executing instructions." This information is followed by the number of wakeups per second. The lower this number, the better.
Power usage is shown only when the laptop is running on battery. PowerTOP uses ACPI to display how much power the laptop is currently using and to calculate the hours of battery life remaining. This information is followed by the top 10 activities that are keeping the machine from sleeping. These could be hardware interrupts or applications. Depending on the activities, PowerTOP prints suggestions at the bottom. You'll notice increased battery life by following these suggestions.
In the images, you can clearly see how the number of wakeups dropped from 156.8 to 142.7 after I disabled Beagle as suggested by PowerTOP. After Beagle is disabled, PowerTOP suggests enabling the CONFIG_USB_SUSPEND option in the kernel, which will automatically disable UHCI USB interrupts, saving 1 watt of power.
Making applications power efficient
PowerTOP is just one part of a bigger power-saving project by Intel. The project Web site also hosts patches for several Linux apps and the kernel. Since there are certain apps we can't or don't want to close or disable, we can use the patches to tweak their behavior and reduce power consumption.
|Click to enlarge|
|Click to enlarge|
bunzip2 firefox-220.127.116.11-source.tar.bz2, then untar with
tar xvf firefox-18.104.22.168-source.tar. Then download Mike's Hommey Firefox patch and place it in the uncompressed Firefox's source directory. To test the patch, run
patch --dry-run -p0 -i firefox.patch. This will test the changes without actually making them. Once it's successful, apply the patch without the
patch -p0 -i firefox.patch. Once the patch is applied, continue with the ./configure, make, make install process to compile Firefox.
Applying a patch is a little complicated if you are not used to installing apps from source. But if you can wait, the patches will surely make their way into the apps. In fact, the development version of Pidgin already has a patch equivalent to the one on the PowerTOP Web site.
PowerTOP is part of a bigger project to help people reduce power usage and get the most out of their laptop battery. Monitoring consumption is just one aspect of saving power. Tweaking application behavior is where the rubber hits the road. By providing patches to various applications, PowerTOP developers ensure the apps aren't draining the battery by keeping the processor bus needlessly. Since applying patches isn't an easy trick to learn for a desktop Linux user, the developers are looking to work with application developers to tweak and incorporate patches into the app itself. PowerTOP itself is under heavy development and the developers have a list of features to implement, including one to activate PowerTOP's suggestions at the press of button.