Page MenuHomeFreeBSD

Reclaim memory from UMA if the page daemon is struggling.

Authored by markj on Fri, Nov 15, 11:46 PM.



Use the UMA reclaim thread to asynchronously drain all caches if
there is a severe shortage in a domain. Otherwise we only trigger UMA
reclamation every 10s even when the system has completely run out of

Stop entirely draining the caches when one domain falls below its min
threshold. In some workloads it is "normal" for one NUMA domain to end
up being nearly depleted by kernel memory allocations, for example for
the ZFS ARC. The domainset iterators skip domains below the
vmd_min_free theshold on the first iteration, so we should allow that
mechanism to limit further depletion of the domain's free pages before
taking the extreme step of calling uma_reclaim(UMA_RECLAIM_DRAIN_CPU).

In my testing this allowed the system to stay quite responsive in
scenarios where I created artificial memory pressure. Previously it
would stutter and stall quite badly.

I do not claim this to be a final solution; now that UMA caches can
estimate their own WSS we can trim them proactively and more frequently.
However, this change allows us to quickly put pressure on both the
caches and the UMA bucket sizes, and I think that's a step in the right

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj created this revision.Fri, Nov 15, 11:46 PM
kib added inline comments.Sat, Nov 16, 10:20 AM
2013 ↗(On Diff #64411)

Why not do the wakeup in the loop above ?

markj added inline comments.Sat, Nov 16, 5:42 PM
2013 ↗(On Diff #64411)

The loop only runs once every lowmem_period seconds, 10s by default.

jeff added a comment.Sat, Nov 16, 11:35 PM

I am ok with this but I would definitely like to see a UMA daemon thread that handles timeouts and wss trimming proactively and regularly. Reviewing the mechanism it seems that we might need to work a little bit to limit the cost of more frequent processing but doing it regularly should make it less impactful when it does run.

This revision was not accepted when it landed; it landed in state Needs Review.Fri, Nov 22, 4:31 PM
This revision was automatically updated to reflect the committed changes.