power-management-in-Ubuntu

Please check the status of this specification in Launchpad before editing it. If it is Approved, contact the Assignee or another knowledgeable person before making changes.

Summary

The Ubuntu Mobile Distribution will run on battery-powered devices. This makes power management critical. This specification lists the things that need to be addressed.

Rationale

Currently, Ubuntu is popular on laptops. With the increasing interest in mobile computing with the advent of Nokia´s internet tablets, Microsoft-Intel UMPCs and Intel´s MID initiative, battery life is becoming increasingly important. To be successful on these mobile platforms, significant work needs to be addressed toward increasing battery life. This work spans the whole stack from kernel to user-space.

Use Cases

  • Jane wants to be able to watch a couple of DVD movies on a cross-Atlantic flight
  • Robert wants to be able to attend one full day of a conference taking notes on his laptop without having to carry a power supply and searching for power sockets.

Scope

Hardy

  • Tickless on x64
  • Use cpuidle infrastructure to idle processors

  • Develop a library that allows timer wake ups to be synchronized for non-real time apps. Get KDE and Gnome communities to use these libraries e.g. gtimeout_at_secs in glib, deferred timers in kernel,
  • Fix drivers to automatically put hardware to increasing levels of power save states based on multiple timeouts
  • Fix bus drivers to automatically put buses into power save modes when no devices on the bus are active e.g. pci, usb, pcmcia
  • Improve Linux driver model to allow control power control of individual devices to allow userspace to override the default policy of the driver
  • Profile userspace for unexpected block I/O accesses while idling. This wakes up the block devices and ATA buses from power saving modes, but PowerTOP doesn't track I/O. Tools : sysctl vm.block_dump=1 (then dmesg will show every block access), blktrace, systemtap.
  • Profile userspace with powertop from Intel (www.linuxpowertop.org) that lists offending processes that poll or set frequent timers and get them fixed

  • Includes patches from powertop website that fix application issues
  • Fix packages in the default install which can cause excessive battery usage: accessing the harddrive, polling for WLAN AP, keeps HW awake, etc.

Design

Implementation

  • We get the following for free with 2.6.24:
    • Tickless on x64
    • cpuidle
    • Force-enable HPET patches are merged and on by default for documented chipsets (even when hidden by BIOS), present but off for some undocumented chipsets
    • SATA ALPM (AHCI link power management) and AN (asynchronous notifications)
    • Intel HDA audio powersaving rework
    • USB autosuspend for a few devices, like HID
    • USB URB statistics exported to userland (Sarah Sharp patches), exploited in powertop >= 1.9

  • Need to check KDE libs for deferred timer implementation

Outstanding Issues

  • laptop-mode (should enable patented laptop-drive-killing mode by default).
  • take care of these patches by Intel too!!! #patches-by-intel <- yes, all of those should be checked that we either ship recent enough upstream version or add a patch

  • evaluate the best frequency scaling method (which userspace governor is best presently, is the recently reworked in kernel cpuidle/ondemand better than an userland daemon, ...)
  • Start a whitelist for USB devices that support autosuspend (for already supported in kernel, grep supports_autosuspend in kernel sources)
  • AHCI link level PM to be pulled in - will lose hotswap support on desktop and server.
  • detect and disable hardware when not needed (ie. NetworkManager could be made to kill wireless radio when running on ethernet, we may disable Wake-on-Lan by default, ensure xorg 7.3 detects and disable TV-out or CRT outputs when no external monitor is plugged, etc.)

  • ensure other (non-CPU) hardware power saving modes are really activated when on battery (like AC97's /sys/module/snd_ac97_codec/parameters/power_save and HDA codec, hard drives APM and spindown timeouts, SATA ALPM, wireless powersaving mode, USB autosuspend, fglrx, ...)
  • Pulse audio (better-than-esd(tm) "drop-in" replacement with extensions). Allows multi-application access at a high-level than direct ALSA
  • Ensure HPET (High Precision Event Timer) is enabled on platforms that support it.
  • NetworkManager general issues:

    • NetworkManager has aggressive scanning.

    • NetworkManager keeps eth0 up even when no cable is plugged in. Needs syncing with kernel about up/down states for the interface.

    • If NIC disappears, should accept that rather than going AWOL.
    • Switch to NM 0.7 as 0.6 (Ubuntu is shipping) has been dropped by upstream.
    • Scan on event (screen unlock, icon-click) rather than on timer (which is too slow for user-experience and too fast for good power saving).
  • MID: Nokia routes all network connection through a connection tracker. So they can disable network interface and when an application tries to access the network, they can start a new connection quickly. It needs to be reimplemented in open source.
    • Netfilter connection tracking (better than LD_PRELOAD grabbing of connect()).

    • Investigate dummy network interface used with PPP bring up.

Notes for benchmarking

  • Remounting an ext3 filesystem as ext2 will attribute the block I/O requests directly to a process rather than to kjournald.

References and See also

BoF agenda and discussion

FAQs

  • Enable "usbcore.autosuspend=1" by default? Done! Drivers need to enable it - whitelisting could fix it.
  • Some important aspects (mostly: available and supported hardware power saving features) has been somehow tested, but may need a larger scale testing before we can confidently choose to use or not use them by default in a released Ubuntu version. So it'd make sense to have this soon enabled during Gutsy+1 testing phase. On the other hand, some of those features had just been merged in 2.6.24-rc1, therefore may not be released soon enough (if we wait for 2.6.24 official release). Some power saving related decisions to be made ASAP:
    • Enable Alsa's AC97 and HDA codec power saving features on by default?
    • Enable laptop mode by default when running on battery? (ie. are the suspend/resume problems been fixed as of now (let alone the "hdparm -B" thinggy) ? or would more exposure help to finally fix them ?).
    • Enable "hpet=force" by default? Would enable hpet for supported but undocumented hpet timers, ie. on ICH4, VT8235/8237, nVidia chipsets. 2.6.24 upstream only enables it officially documented (ICH5 upwards) platforms, but it would be also supported on eg. the mentioned chipsets in 2.6.24.
    • Enable Intel's "ondemand" kernel scaling governor by default? Done (Why is the CPU still attributed to the setter---powernowd.sh).

    • Disable "aggressive scanning when not associated on pre-mac80211 wireless drivers"? (as per Intel's lesswatts recommendation)?

    • Running Ubuntu desktop is down to ~40 wake ups per second, which is acceptable for the moment.
      • This really depends on the hardware and drivers (and setup, launched softwares, ...), and could still be much more than 40 for many users.
      • Uhci_hcd still causes 100 wakeups per second on many computers, effectively disabling deeper sleep states
      • Vertical refresh causes eg. 60 wakeups per second on many chipsets, also effectively disabling deeper sleep states. Intel is going to be fixed, but should be made sure it makes to hardy (drm kernel driver). ATI drm driver has a vblank branch but it's not merged yet, should be considered for hardy. Nouveau?
    • kernel's round_jiffies and gnome's g_timeout_add_seconds() already round to next plain second (so gnome and kernel grouped timers are already in sync)


CategorySpec CategoryLaptop

power-management-in-Ubuntu (last edited 2008-08-06 16:22:27 by localhost)