[systemd-devel] Making /run respect Container Memory Limits
Lennart Poettering
lennart at poettering.net
Mon Sep 30 10:17:40 UTC 2024
On Mo, 23.09.24 14:22, Demi Marie Obenour (demi at invisiblethingslab.com) wrote:
> > Adding swap *will* fix the issue for you btw to a large degree.
> >
> > By not having swap you make it impossible for tmpfs and anonymous
> > memory to be paged out. You basically *create* an artificial OOM
> > situation if any loads shows up, because you artifically minimize the
> > amount of reclaimable pages: in most cases only mapped ELF binaries
> > become reclaimable this way, so they will be constantly thrashed and
> > everything goes to shit.
> >
> > If you disable swap on a big server you are just misunderstanding how
> > memory management works on Linux, and its pretty much your own
> > fault. This might sound harsh, but it is how it is.
>
> Does this mean that if something can't afford its working set to be
> paged out for latency reasons, it _also_ can't afford its own code to be
> paged out, and therefore should call mlockall() or otherwise explicitly
> mlock() the code and data it is operating on, rather than expecting that
> swap be disabled?
Sure, if you want to make sure that your memory is never paged out,
then mlockal() or something similar is the way to go. But of course
you need ot know what you are doing, and verify that locking your code
into memory won't cause memory pressure on other processes where you'd
rather not have it.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list