HomeFreeBSD

Fix memory deadlock when GELI partition is used for swap.

Description

Fix memory deadlock when GELI partition is used for swap.

When we get low on memory, the VM system tries to free some by swapping
pages. However, if we are so low on free pages that GELI allocations block,
then the swapout operation cannot complete. This keeps the VM system from
being able to free enough memory so the allocation can complete.

To alleviate this, keep a UMA pool at the GELI layer which is used for data
buffer allocation in the fast path, and reserve some of that memory for swap
operations. If an IO operation is a swap, then use the reserved memory. If
the allocation still fails, return ENOMEM instead of blocking.

For non-swap allocations, change the default to using M_NOWAIT. In general,
this *should* be better, since it gives upper layers a signal of the memory
pressure and a chance to manage their failure strategy appropriately. However,
a user can set the kern.geom.eli.blocking_malloc sysctl/tunable to restore
the previous M_WAITOK strategy.

Submitted by: jtl
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D24400

Details

Provenance
glebiusAuthored on Sep 28 2021, 6:19 PM
Reviewer
imp
Differential Revision
D24400: Make encrypted swap more reliable
Parents
rG183f8e1e575b: Externalize nsw_cluster_max and initialize it early.
Branches
Unknown
Tags
Unknown