View previous topic :: View next topic |
Author |
Message |
fpemud Guru
Joined: 15 Feb 2012 Posts: 349
|
Posted: Fri Aug 10, 2018 2:59 pm Post subject: is "echo mem > /sys/power/state" good practice? |
|
|
I know that all userspace processes just freeze/thaw in "echo mem > /sys/power/state" scenario, they even don't know what happened.
But in for example "systemctl suspend" scenario, process can get notification, can inhibit the suspend process. It is more complex or more "graceful". Many system service or application is using these features, like NetworkManager.
I want to know are all these "graceful" behaviors really necessary? Not because linux programs are not "robust" enough?
If they are, then "echo mem > /sys/power/state" would definitely break the system and should not be used. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Fri Aug 10, 2018 3:46 pm Post subject: |
|
|
Depends.
If the "graceful" suspend occurs, there's a higher chance of recovery IF something happens between when the suspend takes place and the resume.
If you guarantee that nothing bad happens like a piece of hardware gets pulled like a disk or a power supply, or if the hardware gets placed into some unscrupulous person's hands (hint: do you want your security keys suspended in memory?), then the quick memory suspend is fine...it was designed to be minimal safe suspend. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Aug 10, 2018 5:42 pm Post subject: |
|
|
I accidentally suspended using that one-liner while mpv was streaming a video and it came back fine, that's a pretty good indication of how unnecessary all the other layers are.
Paranoid security and syncing removable devices are valid use cases for doing anything fancier, but anything else is just broken software. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Sat Aug 11, 2018 1:57 am Post subject: |
|
|
I'm not entirely sure it's simply security paranoia, if you have to leave your laptop somewhere or forget it's suspended, someone can instantly unsuspend it and see exactly what you were doing at the time of suspend, no password needed. At least with the infrastructure it will blank the screen and ask for a password before allowing access once more.
Or if you forget about your computer while it's suspended and your battery runs out... if everything was synced and cleaned up before you suspend with the infrastructure, you could be back and running with less data loss.
It's totally up to you on the risk you want to take. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
fpemud Guru
Joined: 15 Feb 2012 Posts: 349
|
Posted: Sat Aug 11, 2018 9:58 am Post subject: |
|
|
Quote: | I'm not entirely sure it's simply security paranoia |
It is a good point I didn't know about.
So at least there's a chance for the system admin to choose between simplicity and security.
Quote: | For some platforms, it is possible that the hardware state changes during suspend/hibernation, in which case it will be necessary to update the rfkill core with the current state is at resume time. |
The above is from rfkill.txt in linux kernel documentation I read today.
This behavior is what I think is "not robust", and is one of the reasons why NetworkManager needs to interact with systemd to receive the suspend/resume event.
Kernel drivers know suspend/resume happened, why doesn't the kernel update the rfkill state and notify userspace the state change as if the hardware state changes when resume happens?
Quote: | syncing removable devices |
This action should also be taken by the kernel and be transparent to userspace. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9679 Location: almost Mile High in the USA
|
Posted: Sat Aug 11, 2018 2:19 pm Post subject: |
|
|
Technically running sync is not necessary as before and after suspend, the state of memory and disk theoretically should match - so even if you don't sync, it should be fine (as long as you don't lose power or otherwise disturb state.)
However there's also the notion of what's in userspace versus what's on disk, and kernel does not necessarily know what's consistent or not. So for those sensitive (or stupid?) applications, getting an alert could let it flush state to disk as well.
However once again, there's no need for this unless you have inadvertent state loss during suspend. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
|