]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix memory deadlock when GELI partition is used for swap.
authorGleb Smirnoff <glebius@FreeBSD.org>
Tue, 28 Sep 2021 18:19:29 +0000 (11:19 -0700)
committerGleb Smirnoff <glebius@FreeBSD.org>
Tue, 28 Sep 2021 18:23:52 +0000 (11:23 -0700)
commit2dbc9a388eeb73a6b17eb6fd1349a2a7e95123cc
tree11d716cb511521eadabe485f83356de25770734f
parent183f8e1e575b526515e70400a22af243cd1a4a78
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
sys/geom/eli/g_eli.c
sys/geom/eli/g_eli.h
sys/geom/eli/g_eli_integrity.c
sys/geom/eli/g_eli_privacy.c