[systemd-devel] how to let systemd hibernate start/stop the swap area?

Lennart Poettering lennart at poettering.net
Mon Apr 3 08:26:44 UTC 2023


On Fr, 31.03.23 13:34, Christoph Anton Mitterer (calestyo at scientia.org) wrote:

> Hey.
>
> Just for better understanding:
>
> AFAIU, the main idea of having swap despite enough memory was the
> following:
>
> Unless when processes explicitly release memory (or get stopped), the
> kernel can mostly reclaim only cached memory,... but if swap is
> available it can also reclaim anonymous memory.
>
> So the idea is, that processes might have pages that are literally
> never used (except for initial loading), yet still kept in memory... so
> these permanently eat up physical memory when they cannot be swapped
> out.
>
> And the actual benefit that then comes (even when the memory is enough)
> in is that (more) physical memory can be used for caching.
>
> Right?
>

Yes, more or less. Except that the term "caching" might not be the
best word to use in this context. For example, running a memory mapped
ELF executable, where the pages that the codepaths take are paged in
as needed probably isn't usually called "cache management".

> All this of course at the potential cost, that if one has some
> misbehaving application, the system may still go into trashing.
> Or is the kernel smart enough to prevent this?

Things like systemd-oomd are supposed to detect misbehaving services
and apps and shut them down cleanly before they can misbehave too
much.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list