FS#32465 - [laptop-mode-tools] laptop-mode not correctly restarted by systemd after suspend

Attached to Project: Community Packages
Opened by Nicola Mori (snack) - Sunday, 04 November 2012, 19:58 GMT
Last edited by Lukas Jirkovsky (6xx) - Tuesday, 01 January 2013, 10:25 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Lukas Jirkovsky (6xx)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 4
Private No

Details

Description:
After recovery from suspend-to-ram the APM level of HDD is not correctly restored. Manually restarting laptop-mode fixes the problem. For example, starting with APM_level=254, suspending and then resuming gives:

$ sudo hdparm -B /dev/sda

/dev/sda:
APM_level = 128
$ sudo systemctl restart laptop-mode
$ sudo hdparm -B /dev/sda

/dev/sda:
APM_level = 254

I never noticed such a behavior with sysvinit.

Additional info:
* package version(s)
laptop-mode-tools 1.62-2
systemd 195-2

* config and/or log files etc.
journalctl is polluted by messages like:
Nov 04 20:55:13 elric laptop-mode[9881]: Warning: Configuration file /etc/laptop-mode/conf.d/board-specific/* is not readable, skipping.

I don't know if it is relevant or not. It is also briefly reported in this forum thread:
https://bbs.archlinux.org/viewtopic.php?id=152126

Steps to reproduce:
* Check APM level using hdparm -B
* Suspend-to-ram
* Recover from suspend
* Check APM level using hdparm -B
* Restart laptop-mode: sudo systemctl restart laptop-mode
* Check APM level using hdparm -B
This task depends upon

Closed by  Lukas Jirkovsky (6xx)
Tuesday, 01 January 2013, 10:25 GMT
Reason for closing:  Duplicate
Additional comments about closing:  see  FS#33262 
Comment by Kevin Sarendranath (k.sarend) - Monday, 05 November 2012, 07:03 GMT
I believe that there is something wrong with the way laptop-mode links with systemd.
It doesn't run correctly on startup but issuing the systemctl restart through bash, once logged in, correctly starts it.
Checking the tunables through powertop upon start up shows this.
Comment by Lukas Jirkovsky (6xx) - Monday, 05 November 2012, 08:51 GMT
Have you tried the steps described in  FS#32395  ?
Comment by Nicola Mori (snack) - Monday, 05 November 2012, 09:22 GMT
@6xx: I have no laptop-mode-tools.service file in my system:

$ ll /etc/systemd/system/multi-user.target.wants/laptop-mode.service
lrwxrwxrwx 1 root root 43 4 nov 12.16 /etc/systemd/system/multi-user.target.wants/laptop-mode.service -> /usr/lib/systemd/system/laptop-mode.service
$ ll /usr/lib/systemd/system/laptop-mode.service
-rw-r--r-- 1 root root 298 3 nov 10.21 /usr/lib/systemd/system/laptop-mode.service

I ebnabled the service through sudo systemctl enable laptop-mode.service, and eventually restart it with sudo systemctl restart laptop-mode.service. No laptop-mode-tools in any place.
Comment by Kevin Sarendranath (k.sarend) - Monday, 05 November 2012, 14:42 GMT
The symlinks for laptop-mode.service exists but for some reason systemd will not run it correctly on startup.
Issuing the restart resolves this but it is temporary and has to be done each time logged in.
Comment by Martin Hertz (mhertz) - Tuesday, 13 November 2012, 04:03 GMT
I also have problems with v1.62 and needed to revert to v1.61-2. My issue is that many times laptop-mode thinks i'm on ac, even though i'm not, and I have to restart it multiple times for it to get it, and when it does detect it correctly, it often fails to set the brightness i've defined in lcd-brightness.conf...
Comment by Martin Hertz (mhertz) - Thursday, 15 November 2012, 03:23 GMT
I'm in touch with the author, so maybe we can get these issues resolved hopefully...
Comment by Nicola Mori (snack) - Thursday, 15 November 2012, 23:27 GMT
I can confirm that setting 'StandardOutput' and 'StandardError' from 'tty' to 'syslog' in LMT's service-file (as Martin Hertz wrote in his previous comment which has been then modified) fix the problem. But why the comment has been changed? Is it unsafe or unwise to modify the service file settings?
Comment by Martin Hertz (mhertz) - Friday, 16 November 2012, 23:30 GMT
Sorry, I edited my post because I got the error again even with syslog defined, but it defenetelly seems to happen much, much rarer with syslog defined...

I'm in touch with the author, and am going through the motions of generating a fail-log to send to him and i'll report back afterwards...

Here's what he stated about the tty-to-syslog thing:

There are some issues the way systemd provides access to the input/output descriptors. If not specifying the tty in the systemd service, LMT fails to append messages to standard output and standard error. This was a PITA to root cause when I was adding the systemd support.

That is why the upstream systemd service specifies stdout and stderr as tty. Unless someone can explain their purpose and provide a better option, this will remain as it is.
Changing it from tty to anything else break logging for LMT.
Comment by Nicola Mori (snack) - Saturday, 17 November 2012, 11:33 GMT
Wonderful, this means that after being ~ forced to switch from sysvinit to systemd now I'm left with a semi-broken system (apart from LMT, I am no more able to mount ntfs partitions as unprivileged user using udisks, after switching to systemd). I understand that systemd is the future, but maybe it's still not enough mature...
Comment by Martin Hertz (mhertz) - Sunday, 18 November 2012, 15:23 GMT
Sorry, I didn't wanna bother with this anymore, and just replaced LMT with my own powersave script! I hope you eventually gets your issue with LMT fixed!
Comment by Nicola Mori (snack) - Wednesday, 21 November 2012, 09:21 GMT
This morning I noticed that laptop-mode didn't start correctly even in one system with the old sysvinit setup. By cehcking hdparm -B I noticed that it had the default value 128 while laptop-mode should have set it to 254. Restarting with rc.d restart fixed the problem.
So it seems that it is not only a systemd issue...
Comment by Lukas Jirkovsky (6xx) - Sunday, 30 December 2012, 10:12 GMT
Sorry guys I didn't get to this issue earlier, I didn't have any system using systemd and I had too much work to spend time by moving to systemd. But now I had installed systemd so I could take a look at it.

The problem is that the pm-utils are no longer used to suspend, instead some systemd crap is used that wreaks havoc in the power saving settings. You can test it with pm-suspend - laptop-mode should work correctly after wake up. It should be possible to write some kind of script that makes everything sane even when systemd is used, but I don't know systemd well enough to create a good and high-quality (is it even possible to have a high-quality hack?) script for that.
Comment by Lukas Jirkovsky (6xx) - Sunday, 30 December 2012, 10:46 GMT
Now I see it was already discussed and solved in the forums: https://bbs.archlinux.org/viewtopic.php?id=150121
Comment by Nicola Mori (snack) - Sunday, 30 December 2012, 11:06 GMT
Lukas, will you fix the laptop-mode-tools package with the fix proposed in the forums? I recently bought an SSD for my laptop so I can't test it and provide feedback, sorry.
Comment by Lukas Jirkovsky (6xx) - Tuesday, 01 January 2013, 10:11 GMT
Not likely. This is a problem somewhere else (it happens without laptop-mode too, I just checked) plus none the solutions in the mentioned thread is suitable for inclusion in a package.

So far it looks that the problem occurs only if the system is suspended using "systemctl suspend", pm-suspend doesn't exhibit the issue. I'm going to report that as a systemd bug and close this one.

Loading...