The out-of-swap killer makes poor choices

Mark Millard marklmi at yahoo.com
Mon Mar 1 16:23:26 UTC 2021



On 2021-Mar-1, at 07:57, tech-lists <tech-lists at zyxst.net> wrote:

> 
> On Tue, Feb 23, 2021 at 01:49:49PM -0700, Alan Somers wrote:
> 
> [...lots...]
> 
> I've found that if I take a system already configured with swap, then
> add say 2* 16GB swapfiles as per the handbook, enable the swapfiles,
> that some things will use the swapfile and others not, even with plenty
> available in the swapfiles.
> 
> example: 12-stable amd64 system running poudriere.
> 
> it will use the swap configured by default (think it's 2GB) as a
> partition. In this example, all of swap is on ssd - the partition and
> both swapfiles. Compiling some things like rust or firefox will use all
> of the partition swap and some of the *swapfile* but not all of it[1]. It's
> almost like some processes have more of an affinity for swap as a
> partition than others, and others won't use swap as a swapfile at all.
> 
> In the end, because I don't know how to debug this kind of issue
> further, it was easier to blat the ssd and install 32GB of swap on
> reinstallation of the OS. Swapfiles arent used now, on this particular
> install. The 32GB swap partition is fine and works as expected.
> 
> Thought the above might be of use as I dunno, a data point. I wonder,
> though, why some programs have seemingly more affinity for swap-as-partition than swap-as-swapfile.
> 
> [1] by "not all of it" I mean fail with an OOM message before all of the
> swapfile is used

See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206048 for why
swapfiles are problematical and likely should be avoided. In
particular comments #7 and #8 that quote Konstantin Belousov on the
subject (or reference his material).

Part of the text says:

As result, swapfile swapping is more prone to the trivial and unavoidable
deadlocks where the pagedaemon thread, which produces free memory, needs
more free memory to make a progress.  Swap write on the raw partition over
simple partitioning scheme directly over HBA are usually safe, while e.g.
zfs over geli over umass is the worst construction.

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-hackers mailing list