Comment 14 for bug 89269

Revision history for this message
Bart Samwel (bart-samwel) wrote : Re: [Bug 89269] Re: power.sh: wrong laptop_mode activation

Hi Andrea,

Andrea Ratto wrote:
>> Bart Samwel:
>> FWIW, in Debian I solved this by removing the acpi-support logic for laptop mode tools completely
>
> That is the quick way to fix it, exactly what I have on my laptop.
> Though I think that in the long run would be better to do it the other way around: remove enabling/disabling based on battery/ac power/lid from laptop_mode and let it just handle disks.
>
> Since you are the mantainer of laptop_mode what do you think? Would not
> it simplify the laptop_mode code and config file a lot (no more need of
> enabled/disabled/allowed to run and stuff like that)? Would not it all
> be more flexible and coherent (on some laptops one could activate disk
> powersaving with a button, for examble)? Would it take much work or is
> it just a matter of deleting code here and there?

It would take _loads_ of work. In fact, laptop mode tools originally
worked like that (it had a start/stop parameter and was called from
various other acpi scripts), but we moved away from that for various
reasons. Here's a short summary:

* Laptop mode tools has very complex enable/disable logic. We have:
enable while on battery; enable while on AC (if so configured); enable
when the lid is closed (if so configured), regardless of being on AC or
battery; *disable* data loss sensitive features when the battery is
below a certain level; *disable* data loss sensitive features when the
battery reports that it is "critical".

* I tried to support this using external scripts, but it turned out that
I had to replicate the entire logical structure in all calling scripts.
For instance, if the lid is closed, but the battery is critical, laptop
mode should not be enabled. And if the lid is opened, and the computer
is on battery, then laptop mode should not be disabled. Eventually, I
just moved the logic into the core of laptop_mode, and just supported an
"auto" parameter which evaluated all the logic and applied state changes
if the result of the calculation was different from the last time.
Ubuntu's package is based on the Debian package, but reinstates the
start/stop parameters.

* Laptop mode tools started to support many more things than laptop_mode
processing, and that complicated matters. It's not simply a matter of
starting and stopping anymore -- it's more like, depending on the AC
state, loads of settings are tweaked. There is a clear distinction in
the current code base between the activating of power saving features,
and the activating of *data loss sensitive* power saving features.

All in all, I think the laptop mode tools framework is much more robust
than the acpi-support framework. Ubuntu's current start/stop logic is
very limited. It doesn't disable laptop mode when the battery goes
critical, which can cause data loss if the battery suddenly runs out. It
doesn't allow enabling laptop mode on AC. It doesn't support enabling
laptop mode when the lid is closed.

There's one other thing to consider: laptop mode doesn't have anything
to do with ACPI, so I've always asked myself what all this is doing in
acpi-support? Laptop mode tools works on APM machines and PowerPC Macs
as well, and supports automatic activation on PowerPC Macs. Furthermore,
acpi-support normally doesn't have anything to do with power saving
either (its goal is to make laptops "just work", not to make them work
power-efficiently), so again, why is this in acpi-support?

Cheers,
Bart