HomeFreeBSD

Avoid memory allocations in the ARC eviction thread

Description

Avoid memory allocations in the ARC eviction thread

When the eviction thread goes to shrink an ARC state, it allocates a set
of marker buffers used to hold its place in the state's sublists.

This can be problematic in low memory conditions, since

  1. the allocation can be substantial, as we allocate NCPU markers;
  2. on at least FreeBSD, page reclamation can block in arc_wait_for_eviction()

In particular, in stress tests it's possible to hit a deadlock on
FreeBSD when the number of free pages is very low, wherein the system is
waiting for the page daemon to reclaim memory, the page daemon is
waiting for the ARC eviction thread to finish, and the ARC eviction
thread is blocked waiting for more memory.

Try to reduce the likelihood of such deadlocks by pre-allocating markers
for the eviction thread at ARC initialization time. When evicting
buffers from an ARC state, check to see if the current thread is the ARC
eviction thread, and use the pre-allocated markers for that purpose
rather than dynamically allocating them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #12985

Details

Provenance
markjAuthored on Jan 21 2022, 6:28 PM
GitHub <noreply@github.com>Committed on Jan 21 2022, 6:28 PM
Parents
rGbc40713a8f2e: libspl: ASSERT*: !! for sizeof
Branches
Unknown
Tags
Unknown