Currently the page daemon will invoke uma_reclaim() once every 10s under
memory pressure. This causes the entire bucket cache of each zone to be
drained. UMA also exports zone_drain() to accomplish the same thing for
The current policy of draining each zone can result in a thundering
herd effect in busy zones when multiple threads take a bucket cache
miss following a drain. It is also just too aggressive when
uma_reclaim() gets called regularly in the steady state of a workload.
The change adds a "request" parameter to uma_reclaim() to let the caller
indicate the desired level of reclamation. I've tried to use the
following terminology consistently:
- "reclaim" means to free some unspecified number of items from a cache,
- "drain" is to reclaim all items from a cache,
- "trim" reclaims items in excess of the working set size estimate.
The diff makes the following changes:
- Rename zone_drain() to uma_zreclaim(), to keep naming consistent.
- Add a "req" parameter to uma_reclaim() and uma_zreclaim(). Use that parameter to completely determine the behaviour of uma_reclaim(). Callers can trim the bucket cache, drain the bucket cache, or drain the bucket cache and per-CPU caches.