Re: how to let systemd hibernate start/stop the swap area?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mi, 29.03.23 13:53, Christoph Anton Mitterer (calestyo@xxxxxxxxxxxx) wrote:

> > > That's a bad idea btw. I'd advise you not to do that: on modern
> > > systems you want swap, since it makes anonymous memory reclaimable.
> > > I
> > > am not sure where you are getting this idea from that swap was
> > > bad.
>
> Well I haven't said it's bad, but I guess it depends on the use case
> any available RAM.

In almost all scenarios you want swap, regardless if little RAM or a
lot. For specialist cases where you run everything from memory, and
not even programs are backed by disk there might be exceptions. But
that#s almost never the case.

> If one has plenty of the latter (e.g. our servers at the university
> have all at least 64GB or more - and even my laptop has) what else than
> giving you a bit more extra on top does swap give you?

It allows the kernel to reclaim anonymous memory, because it can write
it to disk and then use it for other purposes. swap is not an "extra
on top", that's a complete misunderstanding how modern memory
management works. By avoiding swap you create artificial
(i.e. unnecessary) scarcity, and disallow the kernel to use RAM for
useful purposes because you block it with anonymous memory that might
never be used. You artificially amplify IO on the file-backed pages
hence, because those become the only ones that are reclaimable.

> If your memory is limited, like perhaps on IoT, and you rarely (say
> once a day when some extra cron jobs run) need more than physical
> memory is available, then sure... in that case it's good to have some
> relieve of memory pressure.

Nope. Not how this works.

> But if one generally uses more than one has, I feel it would be better
> to run into the oom killer soon.

oomd/PSI looks at memory allocation latencies to determine memory
pressure. Since you disallow anonymous memory to be paged out and thus
increase IO on file backed memory you increase the latencies
unnecessarily, thus making oomd trigger earlier.

> I've looked a bit around at any recommendations, but I couldn't really
> find much credible sources.

Read this for example:

https://chrisdown.name/2018/01/02/in-defence-of-swap.html

It's from 2018, i.e. 5 years ago, but most of it is still
accurate. It's from the facebook people, i.e. the folks who
maintain cgroups/psi/mm stuff, i.e. who really know these things.

If that's not credible enough for you, then I cant't help you.

> Uhm... sorry, I don't quite get hat:
>   systemd-analyze log-level debug
> doesn't seem to be a valid command?

It is. All systemd-based distros from the last 5y or so should have
that command.

> But that would also mean that when the swap was enabled manually (and
> not via the RequiredBy=systemd-hibernate.service) it wouldn't get
> stopped on umount.target?

You can add that manually if you like.

> So I guess that since you're anyway rather against running without swap
> you probably wouldn't accept a feature request that asks for some
> method to override that auto-detection (something like
> AdvertiseHibernate=(auto|always|never) )?

I fail to see the point of the concept these days. Systems where
hibernation should be used, should generally also benefit from swap.

Lennart

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux