Tip ‘o the hat, wag o’ the finger — Linux power savings for laptop users

It’s interesting to see how far, and yet how much more work we need to do on power management for Linux. I recently got a new laptop — a Lenovo Thinkpad X61s — and using the powertop tool, I was able to configure my system to the point where in what I can “airplane mail reading mode” (mailbox preloaded into memory, USB disabled, wireless and ethernet disabled, backlight down to 30% brightness, sloppily written power hogs like Firefox and Notes — every single application writer should be forced to run powertap and explain why their program feels it necessary to constantly wake up the CPU), I can get my usage down to about 9.8 watts. Using the 8 hours extended battery, that’s 8 hours of battery life, although granted doing very little. On the flip side, if I’m doing a major kernel compile, I can drive up utilization up to almost 30 watts, which means less than 3 hours of battery life. So that’s definitely the good news; Linux can sharply reduce its power consumption to the point where it is highly competitive with Windows. (And probably better than Vista, just because that OS is so heavy and bloated.) So thanks and and a tip of the hat to Intel and to Arjan van de Ven for making such a useful tool like Powertop available.

So now for the bad news. Getting down to this level of power saving thriftness, where the laptop is carefully sipping only the minimal amounts of power from the battery, is definitely a work in progress. First of all, you can only get this level of power savings by unloading a specific USB driver, uhci_hcd. This will disable low speed devices (including unfortunately the fingerprint reader and the EVDO WWAN device if you were silly enough to buy one that was built into the laptop as opposed to a stand-alone card that you can swap between laptops and lend out to friends as necessary). But how many users are going to open up a terminal window, su to root and type the command “rmmod uhci_hcd”? And know how to reload the driver using “modprobe uhci_hcd” when they need to use the USB devices again?

A similar problem exists for Network Manager; when the user disables the network by right-clicking on the applet, why doesn’t it automatically bring down the interface, instead of forcing the user to manually su to root and then type the command “ifconfig eth0 down; ifconfig wlan0 down”?

A more serious problem is the Intel Wireless driver for the 4965. Even with the wlan0 interface configured down, and with the RF kill switch enabled, keeping the iwl4965 driver loaded will still cost you an extra full watt of power. When you’re down to 9.6 watts, that means that keeping the iwl4965 driver loaded when you don’t need it will cost you a 10% reduction in your battery life! That’s just sloppy, and hopefully it will be fixed in a future update to the iwl4965 driver, but as long as you don’t mind manually removing and reloading it, you can work around this power-saving oversight.

A bigger issue, though, one for which no workaround exists, is that unlike the ipw3945 drivers, which at least had private, non-standard iwpriv commands to engage the 802.11’s power-saving features, the iwl4965 driver has neither the non-standard Intel iwpriv interfaces, nor the standard iwconfig interfaces for enabling any kind of powersaving features, including changing the transmit power of the card. So while powertop deserves plenty of   kudos, iwl4965 deserves a wag of the finger from a power saving viewpoint. No doubt Intel just needs to allocate more money to its Open Source Technology Center so it get more of its crack developers to work improving Linux support for their processors and chipsets.

Speaking of which, I’m still waiting for an Intel x.org 965GM driver that can support compiz/beryl and simultaneously show video clips at the same time… And being able turn off the 50 interrupts/second generated by the video card when they aren’t needed because 3-d graphics aren’t currently in use, without requiring a restart of the X server, would also be a nice touch. The bottom line is that Linux power savings and Linux support for laptops in general is much better than it was a year ago, and a lot of credit has to go to the efforts of Intel’s teams producing such good work as powertop, their wireless drivers, and their open X server drivers. We still have a lot of work left to be done, though!

26 thoughts on “Tip ‘o the hat, wag o’ the finger — Linux power savings for laptop users

  1. I think you raise some good points here. Have these been logged as feature requests anywhere? I’d add my vote to it if it has been. I’m continually impressed with what I see out of Debian-based parts of Linux, and I think it has really done very well to close the gap between being something for enthusiasts, and something for “The People”. Making features like power management more easily accessible to the end user will go a long way to making the OS more easily adopted by those comfortable in MSFT Win*.

  2. a power management question, maybe not quite linux-related: amd’s cool’n’quiet/powernow and intel’s speedstep reduce the processor’s clock rate and voltage when idle. is there a way of enforcing the low settings even when the cpu load increases? (keeping it at 800 mhz/100% usage vs 1.6 ghz/70% usage) if possible, is there anyone working on adding some ui for this?

  3. Corsac: thanks for the tip. I particularly despise the sysfs interface, because accessing it correctly is difficult so that it is portable across different kernel versions, and almost impossible to do so safely from a shell script. (See /usr/src/linux/Documentation/sysfs-rules.txt and be very afraid. As near as I can tell, if you depend on /sys/bus/pci/drivers/iwl4965/*/powerlevel, it may break on you at any time, and then Greg K-H will mock you for not following the according-to-him very clear rules….)

  4. On the USB thing: This is what selective suspend is for, it’s in the 2.6.21+ kernels but disabled by default unfortunately. Also not all USB drivers have support for this yet, it’s still a bit of a work in progress…

  5. ‘A similar problem exists for Network Manager; when the user disables the network by right-clicking on the applet, why doesn’t it automatically bring down the interface, instead of forcing the user to manually su to root and then type the command “ifconfig eth0 down; ifconfig wlan0 down”?’

    Many NIC drivers don’t report link beat status when the interface is down, and wireless drivers certainly can’t report available networks when the tranciever is off.

    The first is a kernel bug in cases where the hardware supports it.

    But yeah, the solution is to get N-M to offer a separate “disable” option — confusing the network state with the link state just won’t work.

  6. As for video, if you use Option “AccelMethod” “EXA” in the intel driver section of your xorg.conf you should be able to use compiz and see videos too (we’re in the process of moving to EXA by default, but we’re not quite there yet).

    As for vblank interrupts, the work is done, but the code isn’t upstream yet. You can check it out in the vblank-rework branch of the DRM tree (git://git.freedesktop.org/git/xorg/mesa/drm) if you’re curious.

  7. Dizzy: you can fix the ACPI P-State (therefore, CPU frequency) manually through tunables in /sys/devices/system/cpu/*/cpufreq .

    But that won’t save you battery, quite the contrary. On modern x86 CPUs, it’s better to “do the work fast so the CPU can return sleeping sooner, then sleep longer”. Because staying longer in a deep C-state is more economic than just staying longer in a deep P-state.

    See this Intel explanation : http://www.lesswatts.org/projects/applications-power-management/race-to-idle.php

  8. Pavel Macheck had some additional tips on his blog, but since he’s using live journal, he can’t do automatic trackbacks (why I ultimately moved from LJ :-). Excerpted from his LJ:

    “USB should be solved in recent kernels. You just need to enable CONFIG_USB_SUSPEND.

    You can save additional 300mW by unloading sound driver (or enabling its powersaving), and ~1W by enabling powersaving in SATA; Kristen Accardi has patches for that. You can save additional ~500mW by spinning down the harddrives. (With ext2 it was easy, just set bdflush interval to half an hour; but I’m told it is harder these days. But maybe you can help with ext4? ;-). Lower screen resolution, lower refresh and lower color depth also helps. Difference between vga=1 and high-res graphics mode is ~500mW.

    And then comes the crazy stuff. Try s2ram + resume, that saves 300mW, and I’m not sure why. One theory says difference is in PCI setup. Then… you are running CPU fan; probably unnecessarily. As much as 300mW can be saved here.

    Good luck!

    (Unfortunately, “extended battery” I have here is pretty much dead now, and it is not even that old:
    present: yes
    design capacity: 74880 mWh
    last full capacity: 11830 mWh
    battery technology: rechargeable)”

  9. Arjan, Pavel: Yes, I should have mentioned usbcore.autosuspend=1, but I believe I actually saw greater power savings still by rmmod’ing uhci_hcd, even when usb autosuspend was enabled. And of course you get even greater savings from rmmod ehci_hcd, and completely shutting down the USB altogether — and there you really want a GUI interface to make easy for an end-user to toggle, much like Lenovo’s “Battery Stretch” wizard under Windows.

    I have noticed that suspending and resuming can drop the power draw significantly — in my case, up to a watt. Interestingly, removing for the secure digital and firewire drivers don’t seem to make a difference; I don’t know if that’s because the hardware/drivers are particularly well designed, or just because removing the drivers doesn’t actually cut off power to those devices. :-)

    The 9.6 watt number was with sound disabled (and that’s a pain to do since you have to su to root, killall mixer_applet2, and then rmmod snd_hda_intel), and with killall -STOP multiload-applet-2, since that’s a wakeup hog that I don’t need when I’m running on batteries in economy class. I have not been willing to turn off the CPU fan, because I’m paranoid about damaging the laptop. I need to take a much more careful look at the fan control script on thinkwiki, and even then, I’m nervous about what might happen if I leave my laptop unattended, and then it crashes or wedges in such a way that the fan script doesn’t run. If I use it, I’m going to want some kind of kernel level watchdog timer to force reboot the system….

    I know about Kristen Accardi’s SATA powersaving patches, and had them in my kernel at one point, but they kept breaking because they hadn’t been merged yet. One of the comments in Pavel’s LJ indicates they have been merged, so I should pull a newer kernel (my above measurements were done on a post 2.6.24-rc1 kernel, BTW, just not new enough to have the SATA ALPM patches) and try again. Who knows, we might be able to get the x61s idle power utilization down to around 8 watts!

    Pavel: I’m sorry to hear about your extended battery; have you tried complaining to Lenovo about getting a warranty replacement?

  10. Joseph Fannin: The Network Manager already has a “Enable Networking” option which is the first thing on the right-click menu. If you uncheck that option, you’ve already said that you’re not interested in using networking, so there’s no reason for the Network Manager to be checking for the link status; it should just ifconfig down all of the network interfaces for you, automatically. Users should not have to su to root in order to get the best power savings!

  11. thanks benpi, makes sense :)
    the only other use I can see would be for silent pc fanatics, but they are usually able to underclock permanently from the bios.
    I do have another question tho, what will happen on future^h^h almost here cpus (k10) with split power planes for the cores/mem controller. if I understand correctly, the cores will wake up as needed, but would it be useful/practical enforcing affinities to keep work on a single core in a plane scenario for example? maybe the same ‘work faster/sleep sooner’ idea applies, but I’m not sure…

  12. I also have an X61s, and have tried the ‘echo 3 > sudo /sys/bus/pci/drivers/iwl4965/*/power_level’ method, but it doesn’t work. When I cat the power_level it says ‘6 (AC) OFF’ before and after I try the echo – with or without being plugged in.

    Running linux on my X61s is very painful (literally) as the right palmrest gets uncomfortably warm because the WiFi power is set to maximum. (I’ve compared the palmrest heat to Vista usege temperature, and it’s quite high. In Vista the palmrest barely gets warm)

    If you figure out how to get this working I’d appreciate it if you let us know.

    (I’m using Ubuntu 7.10 at the moment)

  13. Antioch, it works for me, but I suspect the reason for that is that I’m using a bleeding edge kernel. If there’s interest, I could make available a set of .deb packages for 2.6.24-rc2 plus my personal patches. I use it on Ubuntu 7.10, and the extent of the support would be, “if it breaks” please let me know, but you get to keep both pieces. It supports all of the hardware on the X61s. I haven’t gotten hotplug for the Ultrabay in the media slace working yet, but I’m not sure anyone has for the X61 yet….

  14. tytso, that sounds great – and I don’t use the ultrabay so the lack of support is not a problem for me.

    Out of curiosity, what personal patches have you applied?

    Anyways, let me know where you decide to post it.

    Thanks!

  15. Antioch, this isn’t the final location, but for now the kernel debs which I use can be found at: http://www.kernel.org/~tytso/tbek

    (Where TBEK stands for “Ted’s Bleeding Edge Kernel”.)

    Just as a reminder, it’s in a “if it breaks, you get to keep both pieces”, and “git repository conveniently available so you can do your own bisection” non-guarantee; see the debian changes file for the URL for the repository plus description of what I’ve pulled into it. :-)

    I am curious how it works for you, though; if you use it, please drop me a note on the blog or via e-mail.

  16. tytso : tried your kernel, gave me 1-1½ hours extra batterytime, but disabled wifi. Haven’t looked into enabling it though.

  17. FALK, I had that problem too. However, I spoke to Ted about it and here’s what he said:

    —-
    You need to make sure the firmware is installed in /lib/firmware.
    Ubuntu installs them in a kernel specific directory, so something like this:

    sudo cp /lib/firmware/2.6.22-14-generic/iwlwifi-*.ucode /lib/firmware

    should be sufficient. Then either reboot, or unload and reload the iwl4965 device driver:

    sudo rmmod iwl4965
    sudo modprobe iwl4965

    And of course, make sure that the RF kill switch is set correctly!
    —-

    Using the above method, I was able to enable WiFi. Iwconfig still says that power management for iwl4965 is disabled, however, the right palm rest is now noticeably cooler. I’ve looked in the kernel changelog and power management for iwl4965 was added, so I’m guessing iwconfig isn’t accurately reporting the status yet (I also can’t seem to find a way to change the specific power level setting yet). Also, the WiFi status light still doesn’t work – but I didn’t expect it to yet :)

  18. Antioch: thanks for info. And you’r right, the right palmrest is killing me. No problems in winxp, but it gets seriously hot in linux, even when disabled with kill switch.

  19. FALK: You need to have the wireless firmware installed in /lib/firmware. You can copy the iwl*.ucode files from one of the kernel-specific directories, such as /lib/firmware/2.6.22-14-generic/iwlwifi-*.ucode.

  20. FALK, Antioch. If you rmmod the wireless driver (i.e., iwl4965 or iwl3945, as appropriate), the right palmrest will be cooler. As I stated in my original blog post, someone seriously needs to be smacked upside the head. Even with the RF kill switch enabled and wlan0 ifconfig’ed down, with the device driver loaded the laptop is burning approximately a full watt more than if the wireless device driver is not loaded — and that’s what’s heating up the right palmrest.

  21. For those who are complaining about the palmrest of the X-series getting too warm or hot under Linux and not Windows, this is due to the secondary cooling fan (in the X61s series) not being enabled under Linux.

    Windows XP and Vista both have access to this fan and can keep the palm rest cool, but Linux does not. It can only communicate with the primary (CPU) cooling fan, but not the secondary cooling fan (almost directly under the fingerprint reader area).

  22. David,

    Note that many X61s simply don’t have the second fan. Only the systems with a WWAN built in apparently have the second fan at all, presumably because if you have both the WiFI and WWAN mini-pci cards install the second card is an absolute necessity. There are some web pages out there which show how it is possible to order a second fan and retrofit it into X61 laptops that don’t have the fan, but this is the first I’ve heard that you have to explicitly enable it from the OS.

  23. The thing is that windows can reach 8-9 watts consumptions without breaking any functionality. We can still attach pendrives and connect to wifi networks and use bluetooth, but when they’re not been used they probably go into D2 state (acpi D2) and have their context saved. I’m speculating that :-p

    Still, most of us here know how to rmmod/insmod and can easily deal with that, but we need userland services to allow normal users to have the same power consumptions we have. I mean, we need the network properties to ifconfig XXX down and echo 5 > /sys/…/power_level. As well as bluetooth-properties should have means to hciconfig hci0 down && rmmod hci_usb (or any other bt module).

    The wifi, shouldn’t be always in the high power, it should stay in the lowest power possible and when trying to find a network then we find the best power level according to strenght of the signal, or something.

    But we’re getting there :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>