Intel’s “powertop” gives hints on how to save power

I discovered this small ncurses based tool just yesterday… Just start it as root and it will spit out info on how often the CPU must return from C3 sleep mode to a more power consuming mode, and what the reasons are. It will also show various hints on how to reduce power consumption on your system. The tool is intended for computers with Intel mobile CPUs. It’s available through portage (sys-power/powertop).

Nice work, Intel!

Laptop battery consumption / learning gnuplot

Today I tested how long my laptop’s battery can last when I just keep it on the table, idling. Running Linux and a bunch of applications, the TFT set to the lowest brightness setting. Wireless activated.

After the laptop switched off, I plotted the power consumption curve with gnuplot, which I wanted to get to know for a long time already πŸ˜‰ The data file (fed from /proc/acpi/battery/BAT1/state) contained 1678 data points (ten samples per minute). The gnuplot session looks like this:

gnuplot> set terminal png picsize 800 600
Terminal type set to 'png'
Options are 'small color picsize 800 600 '
gnuplot> set output "test.png"
gnuplot> plot "powerlog3" using 1:2 title 'Power consumption (W) over time (min)' with lines, "powerlog3" using 1:3 title 'Remaining (%) over time (min)' with lines smooth unique

You can see the result here:
Plot of my laptop’s power consumption, tested on 2007-06-10, plotted with gnuplot

In the beginning I finished something I was working on, so you can see some spikes in the power consumption when I launched programs and such… After 60 minutes the monitor switched off, so the consumption drops. I guess I hit the table at minute 144 or so, because then the monitor seems to have switched on again, don’t remember though πŸ˜‰

I’ll do the test running Windows at a later time – but there I will only get one number – the total runtime. I have no idea how I could get statistics like that in Windows, and I’m not willing to try 10 shareware programs until I get a suitable result πŸ˜‰

UPDATE (2007-06-11):
I got around running the test in Windows. I tried to produce about the same conditions: display switches off automatically after 60 minutes, no automatic standby and stuff. I also remembered to switch on the display again after ~70 minutes of being switched off, so the results should really be comparable. One of the apps I kept running on the otherwise idle system was a PuTTY window. Therein I ran a shell script on my server, which touched a file every ten seconds, so I just would have to check the modification date of that file to know when the box went down. I started the test at 11:01 local time, which means 3:01 UTC. The file’s modification date is: 2007-06-11 05:22 (UTC). –> The laptop was shutdown automatically after 2:21h.

So it’s definitely not true that there is some energy wasting going on when Linux is running on a computer, as I have been told (and which eventually caused me conducting this experiment πŸ˜‰ ). If anything, Windows lost here, as usual.

P.S.: Some information about the two software environments:
Linux: Kernel 2.6.21-gentoo-r2, (for details, have a look at my current configuration). On top of it, running Xorg, KDE with Beryl as window manager, there are usually about 150 processes in the task list.
Windows: Windows Vista Business, everything left quite to the default (I never use it…). No special services running or anything.

Switch from old ATA/IDE driver to libata

Today I switched to libata on my laptop. Libata now not only handles SATA anymore, but also got PATA support. Read more here. I suppose I’m early with that switch, libata for PATA is still marked experimental… but sooner or later this will be standard.

On the surface there is not much change, except that my harddisk is /dev/sda now instead of /dev/hda (what caused me to have to change a few scripts and configs here and there). The optical drive is now /dev/sr0 instead of /dev/hdb.

If you want to switch, too, here is what you basically have to do:
In menuconfig, deactivate the whole “ATA/ATAPI/MFM/RLL support” tree under Device Drivers – this is the old driver architecture – nothing inside is needed anymore. Then go to “Serial ATA (prod) and Parallel ATA (experimental) drivers” (which will probably get renamed soon πŸ˜‰ ). Activate “ATA device support” and find the right option for your IDE controller. My laptop has an ICH 7 built in (00:1f.1 IDE interface: Intel Corporation 82801G (ICH7 Family) IDE Controller (rev 02)).
Now here is one thing which took me a while. Because I never needed /dev/sd* devices in an early stage of booting, I had “Device Drivers / SCSI device support / SCSI disk support” (CONFIG_BLK_DEV_SD) only compiled as module. But modules can only be loaded after the Kernel can access the root partition. So make sure this option is compiled into the kernel.
Then change your GRUB config so that root=/dev/hd* is root=/dev/sd* now. Furthermore you need to adjust the /dev/hd* entries in your /etc/fstab to also read as /dev/sd*.
After building the kernel you should be able to boot your system as normal.

I had another minor complication involving udev: It symlinked /dev/cdrom7 to /dev/sr0. Why the hell 7? I only have exactly one optical drive in my laptop. After poking around a bit in /etc/udev, I figured out that there was some cruft in /etc/udev/rules.d/70-persistent-cd.rules. After I deleted it and re-initialised udev (“udevstart”), the file respawned without the cruft, and I have my good old /dev/cdrom symlink back (which links to /dev/sr0).

That’s it. Enjoy the new technology πŸ™‚ I bet in a few years, we will consider /dev/hd* device names as archaic relics from long gone times πŸ˜‰