Bug 14090 - pm-powersave not called when changing AC state
Summary: pm-powersave not called when changing AC state
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 5
Hardware: All Linux
Priority: Normal major
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL: https://bugs.freedesktop.org/show_bug...
Whiteboard: has_procedure MGA5-32-OK MGA5-64-OK a...
Keywords: validated_update
Depends on:
Blocks:
 
Reported: 2014-09-12 00:38 CEST by John L. ten Wolde
Modified: 2016-11-06 09:45 CET (History)
5 users (show)

See Also:
Source RPM: pm-utils
CVE:
Status comment:


Attachments
pm-powersave invocation workaround (88.65 KB, image/png)
2015-09-21 23:40 CEST, John L. ten Wolde
Details

Description John L. ten Wolde 2014-09-12 00:38:37 CEST
Description of problem:

Since installing MGA4 I noticed the hard drives on all my machines are being set to an aggressive APM level of 128 and an unknown but incredibly short spin-down interval causing excessive wear-and-tear as well as poor disk performance even when plugged onto AC power.

After some digging and experimentation I was able to verify that pm-power had never been and is never invoked.  Running it manually from terminal causes it to work as expected.

From more research, I gleaned that UPower's use of pm-utils is being deprecated (which is news to me, but shouldn't be to the folks here) and that to continue using pm-utils (for now) and pm-powersave and its child scripts specifically, UPower must be built with "--enable-deprecated". Otherwise an alternative to pm-utils must be provided.

Quoting from /usr/share/doc/upower/NEWS:

  Version 0.9.20
  ~~~~~~~~~~~~~~
  Released: 2013-03-18

  New Features:
   - Add a --enable-deprecated configure argument to remove pm-utils
     support (Richard Hughes)
   - Deprecate running the powersave scripts (Richard Hughes)
   - Require applications to define UPOWER_ENABLE_DEPRECATED to use
     deprecated functionality (Richard Hughes)

See also the 4th comment by Bastien Nocera in the provided URL

  https://bugs.freedesktop.org/show_bug.cgi?id=71713#c4


I don't recall this being and issue with MGA3 so we must have been using a UPower prior to 0.9.20 (and when did we switch to systemd again...?). Anyhow, I'm setting the severity of this bug to "major" as the short spin-down interval will reduce the lifespan of a user's hard drive.

Thanks to all the Mageia team for your continuing hard work, and apologies for saddling you with more. ;-)

Reproducible: 

Steps to Reproduce:
Comment 1 John L. ten Wolde 2014-09-12 01:08:30 CEST
There's always a typo: "pm-power" in my second paragraph above should of course read "pm-powersave".
Comment 2 David Walser 2014-09-12 13:21:51 CEST
We switched to systemd as of Mageia 2, but it took over pm stuff from pm-utils in Mageia 4.

CC: (none) => mageia

Manuel Hiebel 2014-11-07 19:41:40 CET

CC: (none) => tmb

Comment 3 Samuel Verschelde 2015-09-21 13:18:27 CEST
Mageia 4 changed to end-of-life (EOL) status on 2015-09-19. It is is no longer 
maintained, which means that it will not receive any further security or bug 
fix updates.

Package Maintainer: If you wish for this bug to remain open because you plan to 
fix it in a currently maintained version, simply change the 'version' to a later 
Mageia version.

Bug Reporter: Thank you for reporting this issue and we are sorry that we weren't 
able to fix it before Mageia 4's end of life. If you are able to reproduce it 
against a later version of Mageia, you are encouraged to click on "Version" and 
change it against that version of Mageia. If it's valid in several versions, 
select the highest and add MGAxTOO in whiteboard for each other valid release.
Example: it's valid in cauldron and Mageia 5, set to cauldron and add MGA5TOO.

Although we aim to fix as many bugs as possible during every release's lifetime, 
sometimes those efforts are overtaken by events. Often a more recent Mageia 
release includes newer upstream software that fixes bugs or makes them obsolete.

If you would like to help fixing bugs in the future, don't hesitate to join the
packager team via our mentoring program [1] or join the teams that fit you 
most [2].

[1] https://wiki.mageia.org/en/Becoming_a_Mageia_Packager
[2] http://www.mageia.org/contribute/
Comment 4 John L. ten Wolde 2015-09-21 23:40:41 CEST
Created attachment 7026 [details]
pm-powersave invocation workaround


Yes, in Mageia 5 the issue remains.

Apologies for never getting back with more info, but I found a simple workaround ages ago and completely forgot I reported this bug.

WORKAROUND: for each Power-State Tab in KDE System Settings > Power Management activate the Run Script check box; in the Script field add "pm-powersave"; and lastly set the Run Script drop down to "On Profile Load".

See also the my attached screen capture.
John L. ten Wolde 2015-09-21 23:40:55 CEST

Version: 4 => 5

Samuel Verschelde 2016-11-01 12:19:37 CET

Assignee: bugsquad => lists.jjorge

Comment 5 José Jorge 2016-11-02 11:08:07 CET
(In reply to John ten Wolde from comment #4)
> WORKAROUND: for each Power-State Tab in KDE System Settings > Power
> Management activate the Run Script check box; in the Script field add
> "pm-powersave"; and lastly set the Run Script drop down to "On Profile Load".

Thanks for your reply. I was also using this workaround for a while, now your information got to me. So I submitted a upower with deprecated config option to MGA5 testing.

Please test an report if this fixes to bug (of course you will have to disable the workaround).

Status: NEW => ASSIGNED

Comment 6 José Jorge 2016-11-02 16:51:18 CET
I could try this on a laptop, but it did not change the situation. But I have found what seems the real solution : a udev rule to trigger pm-powersave on power events.

The fix is commited in pm-utils-1.4.1-9.1.mga5. It worked for me, please test by yourself.
Comment 7 José Jorge 2016-11-02 17:04:57 CET
Suggested advisory:
========================

With systemd, the pm-powersave scripts were not launched anymore on laptops when ac-power starts and stops.

This updated pm-utils brings an udev rule to start powersave on battery, on stop it on AC.

========================

Updated packages in core/updates_testing:
========================
pm-utils-1.4.1-9.1.mga5.i586.rpm
pm-utils-devel-1.4.1-9.1.mga5.i586.rpm


Source RPMs: 
pm-utils-1.4.1-9.1.mga5.src.rpm


Sysadmins, please remove from updates testing upower related rpms :
- libupower-glib3-0.99.2-1.1.mga5.i586
- upower-0.99.2-1.1.mga5.i586
- lib64upower-glib-devel-0.99.2-1.1
- libupower-gir1.0-0.99.2-1.1

Assignee: lists.jjorge => qa-bugs
Source RPM: upower-0.9.23-1.1.mga4 => pm-utils

Comment 8 José Jorge 2016-11-02 17:06:58 CET
PROCEDURE  to test : use the command 

ls -l /var/log/pm*

to see at what time pm-powersave was launched. When you unplug the AC, this file should be changed, but it does not.
After installing the updated pm-utils, it will change.

CC: (none) => lists.jjorge

Comment 9 John L. ten Wolde 2016-11-04 00:30:01 CET
(In reply to José Jorge from comment #6)
> The fix is commited in pm-utils-1.4.1-9.1.mga5. It worked for me, please
> test by yourself.

Hi José.  OP here.  I just took your test package for a spin, and yes indeed it works for me too! Thank you!

You've also supported my personal experience that there's always a typo.  In your suggested advisory, last clause of the second paragraph, you wrote: "on stop it on AC".  I believe you meant: "and stop it on AC". ;-)

In any case, thank you again for looking into this matter and providing a more robust (and elegant) fix.  I've never been party to the finalization of a bug resolution before.  Should we mark this bug as resolved or wait for more confirmations?
Comment 10 John L. ten Wolde 2016-11-04 01:13:13 CET
@José: Sadly, I just just discovered something your fix doesn't address any better than my workaround.  When plugging in an external HDD, pm-powersave fails to fire automatically.

In the pre Mageia 4 days, at the time KDE's Plasma Notifier popped up (i.e. when the system detected a new device had been added) pm-powersave would set the new drive according to the active AC profile.  I'm not sure how it did it, but I'm sure that it did.  Over the last 2 years, even with my workaround, I've been hitting up pm-powersave via KRunner (ALT+F2) every time I plugged in an external HDD.

Here are the results of my test.  Note that I do my testing not by watching for changes to /var/log/pm, but as root using "hdparm -B /dev/sdx" where 'x' is whatever HDD I'm checking.

As expected, if I unplug the AC cord, your fix kicks in and pm-powersave fires (same as it did while logged into KDE with my workaround):

After first plugging it in, the external HDD starts at the default power save level:
# hdparm -B /dev/sdc

/dev/sdc:
 APM_level      = 128

After pulling the AC cord your script kicks the HDD down to aggressive power save:
# hdparm -B /dev/sdc

/dev/sdc:
 APM_level      = 1

Plugging the AC cord back in causes your script to kick the HDD up to full power:
# hdparm -B /dev/sdc

/dev/sdc:
 APM_level      = 254


Your fix is definitely a step forward, but if you could figure out what tripped pm-powersave to fire in the days prior to 2014 (without pulling out the AC cord), that would really be golden.

Thanks again for your efforts.
Comment 11 John L. ten Wolde 2016-11-04 01:32:37 CET
Grr!  I botched the last paragraph in Comment 10.  It should read:

Your fix is definitely a step forward, but if you could figure out what tripped pm-powersave to fire *upon device detection* in the days prior to 2014 (without pulling out the AC cord), that would really be golden.

Then again, maybe that counts as a whole separate bug... :-(
Comment 12 José Jorge 2016-11-04 19:17:40 CET
(In reply to John ten Wolde from comment #11)
Yes a trigger of pm-powersave (true or false?) when you plug an external drive is an unexpected behaviour, let's forget it.

About closing this bug, please indicate if you tested with 32 or 64 bits, then QA team will publish an advisory, and the bug will be closed when to update is pushed to core/updates.
Comment 13 John L. ten Wolde 2016-11-04 22:14:48 CET
(In reply to José Jorge from comment #12)
I wasn't saying that pm-powersave did trigger; I was suggesting that it *should* trigger.

Anyway, my tests were conducted on an x86_64 laptop.
Comment 14 José Jorge 2016-11-04 23:50:26 CET
Ok, tests are also good on another i586 laptop.

Whiteboard: (none) => has_procedure MGA5-32-OK MGA5-64-OK

Comment 15 Lewis Smith 2016-11-05 19:20:49 CET
Thanks to John & José for their tests. Validating, Advisory uploaded.

Keywords: (none) => validated_update
Whiteboard: has_procedure MGA5-32-OK MGA5-64-OK => has_procedure MGA5-32-OK MGA5-64-OK advisory
CC: (none) => lewyssmith, sysadmin-bugs

Comment 16 Mageia Robot 2016-11-06 09:45:27 CET
An update for this issue has been pushed to the Mageia Updates repository.

http://advisories.mageia.org/MGAA-2016-0135.html

Status: ASSIGNED => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.