Reclaim memory from UMA if the page daemon is struggling.
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 memory. 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). Discussed with: jeff MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D22395
This commit is contained in:
parent
bf0d60af92
commit
8fc2550837
@ -1965,11 +1965,19 @@ vm_pageout_oom(int shortage)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal a free page shortage to subsystems that have registered an event
|
||||
* handler. Reclaim memory from UMA in the event of a severe shortage.
|
||||
* Return true if the free page count should be re-evaluated.
|
||||
*/
|
||||
static bool
|
||||
vm_pageout_lowmem(void)
|
||||
{
|
||||
static int lowmem_ticks = 0;
|
||||
int last;
|
||||
bool ret;
|
||||
|
||||
ret = false;
|
||||
|
||||
last = atomic_load_int(&lowmem_ticks);
|
||||
while ((u_int)(ticks - last) / hz >= lowmem_period) {
|
||||
@ -1984,15 +1992,27 @@ vm_pageout_lowmem(void)
|
||||
|
||||
/*
|
||||
* We do this explicitly after the caches have been
|
||||
* drained above. If we have a severe page shortage on
|
||||
* our hands, completely drain all UMA zones. Otherwise,
|
||||
* just prune the caches.
|
||||
* drained above.
|
||||
*/
|
||||
uma_reclaim(vm_page_count_min() ? UMA_RECLAIM_DRAIN_CPU :
|
||||
UMA_RECLAIM_TRIM);
|
||||
return (true);
|
||||
uma_reclaim(UMA_RECLAIM_TRIM);
|
||||
ret = true;
|
||||
}
|
||||
return (false);
|
||||
|
||||
/*
|
||||
* Kick off an asynchronous reclaim of cached memory if one of the
|
||||
* page daemons is failing to keep up with demand. Use the "severe"
|
||||
* threshold instead of "min" to ensure that we do not blow away the
|
||||
* caches if a subset of the NUMA domains are depleted by kernel memory
|
||||
* allocations; the domainset iterators automatically skip domains
|
||||
* below the "min" threshold on the first pass.
|
||||
*
|
||||
* UMA reclaim worker has its own rate-limiting mechanism, so don't
|
||||
* worry about kicking it too often.
|
||||
*/
|
||||
if (vm_page_count_severe())
|
||||
uma_reclaim_wakeup();
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user