Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_pageout.c
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | |||||
#define VM_LAUNDER_RATE 10 | #define VM_LAUNDER_RATE 10 | ||||
#define VM_INACT_SCAN_RATE 10 | #define VM_INACT_SCAN_RATE 10 | ||||
static int vm_pageout_oom_seq = 12; | static int vm_pageout_oom_seq = 12; | ||||
static int vm_pageout_update_period; | static int vm_pageout_update_period; | ||||
static int disable_swap_pageouts; | static int disable_swap_pageouts; | ||||
static int lowmem_period = 10; | static int lowmem_period = 10; | ||||
static time_t lowmem_uptime; | |||||
static int swapdev_enabled; | static int swapdev_enabled; | ||||
static int vm_panic_on_oom = 0; | static int vm_panic_on_oom = 0; | ||||
SYSCTL_INT(_vm, OID_AUTO, panic_on_oom, | SYSCTL_INT(_vm, OID_AUTO, panic_on_oom, | ||||
CTLFLAG_RWTUN, &vm_panic_on_oom, 0, | CTLFLAG_RWTUN, &vm_panic_on_oom, 0, | ||||
"panic on out of memory instead of killing the largest process"); | "panic on out of memory instead of killing the largest process"); | ||||
▲ Show 20 Lines • Show All 1,688 Lines • ▼ Show 20 Lines | if (bigproc != NULL) { | ||||
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); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
vm_pageout_lowmem(struct vm_domain *vmd) | vm_pageout_lowmem(void) | ||||
{ | { | ||||
static int lowmem_ticks = 0; | |||||
int last; | |||||
if (vmd == VM_DOMAIN(0) && | last = atomic_load_int(&lowmem_ticks); | ||||
time_uptime - lowmem_uptime >= lowmem_period) { | while ((u_int)(ticks - last) / hz >= lowmem_period) { | ||||
if (atomic_fcmpset_int(&lowmem_ticks, &last, ticks) == 0) | |||||
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. | * drained above. | ||||
*/ | */ | ||||
uma_reclaim(); | uma_reclaim(); | ||||
lowmem_uptime = time_uptime; | |||||
} | } | ||||
} | } | ||||
static void | static void | ||||
vm_pageout_worker(void *arg) | vm_pageout_worker(void *arg) | ||||
{ | { | ||||
struct vm_domain *vmd; | struct vm_domain *vmd; | ||||
int addl_shortage, domain, shortage; | int addl_shortage, domain, shortage; | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | if (vm_paging_needed(vmd, vmd->vmd_free_count)) { | ||||
"psleep", hz / VM_INACT_SCAN_RATE) == 0) | "psleep", hz / VM_INACT_SCAN_RATE) == 0) | ||||
VM_CNT_INC(v_pdwakeups); | VM_CNT_INC(v_pdwakeups); | ||||
} | } | ||||
/* Prevent spurious wakeups by ensuring that wanted is set. */ | /* Prevent spurious wakeups by ensuring that wanted is set. */ | ||||
atomic_store_int(&vmd->vmd_pageout_wanted, 1); | atomic_store_int(&vmd->vmd_pageout_wanted, 1); | ||||
/* | /* | ||||
* If the free page count is below its target, ask subsystems to | |||||
* release pages. | |||||
*/ | |||||
if (pidctrl_error(&vmd->vmd_pid, vmd->vmd_free_count) > 0) | |||||
vm_pageout_lowmem(); | |||||
/* | |||||
* Use the controller to calculate how many pages to free in | * Use the controller to calculate how many pages to free in | ||||
* this interval, and scan the inactive queue. | * this interval, and scan the inactive queue. | ||||
*/ | */ | ||||
shortage = pidctrl_daemon(&vmd->vmd_pid, vmd->vmd_free_count); | shortage = pidctrl_daemon(&vmd->vmd_pid, vmd->vmd_free_count); | ||||
if (shortage > 0) { | if (shortage > 0) | ||||
vm_pageout_lowmem(vmd); | |||||
target_met = vm_pageout_scan_inactive(vmd, shortage, | target_met = vm_pageout_scan_inactive(vmd, shortage, | ||||
&addl_shortage); | &addl_shortage); | ||||
} else | else | ||||
addl_shortage = 0; | addl_shortage = 0; | ||||
/* | /* | ||||
* Scan the active queue. A positive value for shortage | * Scan the active queue. A positive value for shortage | ||||
* indicates that we must aggressively deactivate pages to avoid | * indicates that we must aggressively deactivate pages to avoid | ||||
* a shortfall. | * a shortfall. | ||||
*/ | */ | ||||
shortage = vm_pageout_active_target(vmd) + addl_shortage; | shortage = vm_pageout_active_target(vmd) + addl_shortage; | ||||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |