blino's website

Free software developer and more

Yesterday, Intel released the PowerTOP utility. It allows to monitor closely the power consumption and to diagnose what software is using the most power.

It requires (at least) a 2.6.21 kernel with /proc/timer_stat (enabled through CONFIG_TIMER_STATS, [commit]).

I've just made this tool available in Mandriva Cooker, in the powertop package. I'm afraid it will unearth some very bad habits from net_applet... (will try as soon as we have a 2.6.21 kernel ready for Cooker)

... or how to find a way to handle ACPI button events in a user-unfriendly desktop

So, we're switching to pm-utils + HAL + gnome-power-manager/kpowersave to do power management. It's great to finally have an unified power management framework, but I'm still not really statisfied with it.

Why? Because I'm not really a desktop-friend, I don't use neither KDE nor Gnome, and I don't use much applets. So, gnome-power-manager and kpowersave are not good options to me.

Furthermore, the ACPI button events are not passed from acpid to HAL, so that these desktop applications can receive. I have to drop the /etc/acpi/events files that used to catch them, or else the events will be handled inconsistently in many ways. So, now, when not in KDE/Gnome, nothing handles these ACPI events anymore, great...

A year ago, the idea of a PolicyManager daemon has been raised, but there has been no implementation for a long time.

It turned out in to PolicyKit and ConsoleKit which will soon be used in a better gnome-power-manager. Though, there is no full integration with power managers yet.

After a discussion between power management application maintainers, an org.freedesktop.Policy.Power interface has been introduced by Novell in kpowersave and powersave. Acquiring this D-Bus interface acts as a lock between power management programs that supports it, so that only one power management policy can get applied. They even patched gnome-power-manager to support this interface.

In Mandriva, to make the events handled when not in KDE/Gnome, I will create a small pm-has-power-policy helper using dbus-send:

dbus-send --system --dest=org.freedesktop.DBus --type=method_call
    --print-reply --reply-timeout=200 / org.freedesktop.DBus.NameHasOwner
 | grep -q 'boolean true'

Then, I have restored /etc/acpi/events helpers, that check if pm-has-power-policy returns false because calling the real actions (poweroff/suspend). Of course, I also have to create a /etc/dbus-1/system.d/policy-power.conf file, to allow user apps to acquire org.freedesktop.Policy.Power.

Finally, I got a simple solution, but the thing is, latest official kpowersave release does not event support poweroff/suspend/hibernate buttons /o\ Yet some more patches to bakport (from kpowersave SVN).

It looks like the better compromise to me as of today, even if the situation will probably evolve quite fast.

Well, what a ride...

There is no "official" backend right now, basically because there is no daemon that can be used by both Gnome and KDE apps. klaptop has its own powersaving handling, and we didn't use anything special on Gnome but the cpufreqd daemon.

An interesting thread on debian-devel: And their powermgmt project: But as usual, once an interesting solution is proposed, err...

What we need is:

  • automatic detection and load of power saving modules at boot
  • a set of tools to deal with suspend
  • a desktop agnostic frequency scaling daemon
  • a generic layer on top system tools
  • tools that use the same backend on both Gnome and KDE

Modules detection

The detection of power saving modules is currently done by the cpufreq service. It's not really nice since it really does the detection at each boot. Better move it to drakx/harddrake, so that it runs only when a new CPU is detected, and puts modules in modprobe.preload. That's planned.

Suspend tools

That's our suspend-scripts, they work, and we're adding more and more features to it thanks to contributors.

Frequency scaling daemon

Frequency scaling is better done in a daemon (for consistency between desktops, and systems not using any dekstop).

Then, we have this new powersave daemon, that looks quite Suse oriented. But it's not granular enough IMHO, it mixes frequency scaling and suspend. It will probably conflict with our suspend-scripts, but I haven't really looked at it yet.

cpufreqd looks like a good power saving daemon. It offers a dynamic mode, supports multiple profiles, and allow them to be chosen from a command line interface.

Generic layer

Now, a generic suspend backend is available in HAL, and we will add suspend-scripts support there (pmsuspend command, patch available on our Bugzilla).

But it doesn't offer anything to control the frequency scaling yet. See these monster trolls: And interesting point of view:

The previous effort was a power manager daemon, but it's now obsoleted by the new HAL layer: HAL also obsoletes pmscripts.

Desktop tools

So, gnome-power-manager looks like a good candidate for Gnome:

The HAL layer should be the way to go, but unfortunately, I'm not aware of any KDE daemon using this HAL interface to run actions...

kpowersave uses the HAL layer to get hardware information, that's good news and better than I expected. But it directly interacts with powersave when it's about doing suspend or applying scaling policy... So, it may be the default KDE applet, once it fully uses HAL to run actions (which should be quite doable, since HAL supports powersave on Suse).


Basically, we can have:

  • drakx/harddrake handling power saving modules detection
  • suspend-scripts as suspend tools
  • cpufreqd as a frequency scaling daemon
  • HAL as an abstraction layer for suspend
  • a Gnome applet fully using this layer (gnome-power-manager) and a KDE applet using it partially (kpowersave)

But we miss:

  • a generic layer to control frequency scaling
  • tools using this hypothetical layer

The Linux power management summit might help to get a solution.

blosxom Optimised for standards.
Olivier Blin (2005)