-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let the swap unit remain survive shutdown #207
Conversation
7d1b54c
to
d69ff7b
Compare
The formatting's a little off, but whatever. I don't think this interferes with, like, hibernation? so I can't see any contra-indicators. Great to see this. |
Actually, can we writeback to files? What happens then? |
We (I really) started using more whitespace in formatting of unit files in upstream systemd. The original style was maximally compressed, but it turns out that (unsurprisingly) things a much more readable if the settings are groupped by purpose, and the same or similar order is used in multiple unit files. Thus I'm trying to have a block for Description, a block for important settings, and a block for Before/After/Requires/Wants deps, and the ordering and requirement deps are interleaved so that the settings referrering to the same unit are adjacent. Long story short, the whitespace change here is intentional.
I think this should be fine. If the writeback file needs to be destroyed, then the dependencies from the side of the device should cause the swap to be stopped, and the zram device destroyed. Hibernation is not really important. In hibernation, the contents of RAM are saved to storage, and if some of them are zram, this shouldn't really matter. A zram device survives hibernation. |
It reads weird to me because in my head My thinking is that the default Conflicts= is |
Dependency chains work both ways. If you say |
I'm concerned because I haven't been able to find a field thst would link dev-loop0.device to anything /var-shaped. I may be looking wrong of course.
|
To wit:
$ systemctl list-dependencies dev-loop0.device --all
dev-loop0.device
|
trixie systemd apparently has gained these udev properties that weren't in bookworm:
but still doesn't forward them to BindsTo=. |
Swap units have automatic dependencies of Before=swap.target,shutdown.target, Conflicts=shutdown.target. By adding DefaultDependencies=no, Before=swap.target, we effectively drop the conflict with shutdown.target and allow the swap device to survive until shutdown. There is no need to bring down the swap device. This wastes work, because any remaning pages need to be dropped or decompressed and moved to normal memory. Normally this is very quick, but the report says that it takes 15–20 seconds in their case. Closes systemd#191.
d69ff7b
to
222d359
Compare
The case of devices with writeback is fairly niche. So I think it's fine if we change behaviour only for the normal devices without writeback. |
OK, I tested this with a VM, and it doesn't seem to cause any adverse effects. |
That's a solid solution as well.
|
Swap units have automatic dependencies of Before=swap.target,shutdown.target, Conflicts=shutdown.target. By adding DefaultDependencies=no, Before=swap.target, we effective drop the negative dependency with shutdown.target and allow the swap device to survive shutdown.
There is no need to bring down the swap device during shutdown. This wastes work, because any remaning pages need to be dropped or decompressed and moved to normal memory. Normally this is very quick, but the report says that it takes 15–20 seconds in their case.
Closes #191.