Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_pageout.c
Show First 20 Lines • Show All 1,959 Lines • ▼ Show 20 Lines | if (bigproc != NULL) { | ||||
PROC_LOCK(bigproc); | PROC_LOCK(bigproc); | ||||
killproc(bigproc, "out of swap space"); | killproc(bigproc, "out of swap space"); | ||||
sched_nice(bigproc, PRIO_MIN); | sched_nice(bigproc, PRIO_MIN); | ||||
_PRELE(bigproc); | _PRELE(bigproc); | ||||
PROC_UNLOCK(bigproc); | PROC_UNLOCK(bigproc); | ||||
} | } | ||||
} | } | ||||
/* | |||||
* 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 | static bool | ||||
vm_pageout_lowmem(void) | vm_pageout_lowmem(void) | ||||
{ | { | ||||
static int lowmem_ticks = 0; | static int lowmem_ticks = 0; | ||||
int last; | int last; | ||||
bool ret; | |||||
ret = false; | |||||
last = atomic_load_int(&lowmem_ticks); | last = atomic_load_int(&lowmem_ticks); | ||||
while ((u_int)(ticks - last) / hz >= lowmem_period) { | while ((u_int)(ticks - last) / hz >= lowmem_period) { | ||||
if (atomic_fcmpset_int(&lowmem_ticks, &last, ticks) == 0) | if (atomic_fcmpset_int(&lowmem_ticks, &last, ticks) == 0) | ||||
continue; | continue; | ||||
/* | /* | ||||
* Decrease registered cache sizes. | * Decrease registered cache sizes. | ||||
*/ | */ | ||||
SDT_PROBE0(vm, , , vm__lowmem_scan); | SDT_PROBE0(vm, , , vm__lowmem_scan); | ||||
EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_PAGES); | EVENTHANDLER_INVOKE(vm_lowmem, VM_LOW_PAGES); | ||||
/* | /* | ||||
* We do this explicitly after the caches have been | * We do this explicitly after the caches have been | ||||
* drained above. If we have a severe page shortage on | * drained above. | ||||
* our hands, completely drain all UMA zones. Otherwise, | |||||
* just prune the caches. | |||||
*/ | */ | ||||
uma_reclaim(vm_page_count_min() ? UMA_RECLAIM_DRAIN_CPU : | uma_reclaim(UMA_RECLAIM_TRIM); | ||||
UMA_RECLAIM_TRIM); | ret = true; | ||||
return (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 | static void | ||||
vm_pageout_worker(void *arg) | vm_pageout_worker(void *arg) | ||||
{ | { | ||||
struct vm_domain *vmd; | struct vm_domain *vmd; | ||||
u_int ofree; | u_int ofree; | ||||
int addl_shortage, domain, shortage; | int addl_shortage, domain, shortage; | ||||
▲ Show 20 Lines • Show All 242 Lines • Show Last 20 Lines |