Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_swapout.c
Show First 20 Lines • Show All 758 Lines • ▼ Show 20 Lines | if ((p->p_flag & (P_SYSTEM | P_WEXIT)) != 0) { | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
continue; | continue; | ||||
} | } | ||||
_PHOLD_LITE(p); | _PHOLD_LITE(p); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
sx_sunlock(&allproc_lock); | sx_sunlock(&allproc_lock); | ||||
/* | /* | ||||
* Do not swapout a process that | * Do not swapout a process that is waiting for VM | ||||
* is waiting for VM data | * data structures as there is a possible deadlock. | ||||
* structures as there is a possible | * Test this first as this may block. | ||||
* deadlock. Test this first as | |||||
* this may block. | |||||
* | |||||
* Lock the map until swapout | |||||
* finishes, or a thread of this | |||||
* process may attempt to alter | |||||
* the map. | |||||
*/ | */ | ||||
vm = vmspace_acquire_ref(p); | vm = vmspace_acquire_ref(p); | ||||
if (vm == NULL) | if (vm == NULL) | ||||
goto nextproc2; | goto nextproc2; | ||||
if (!vm_map_trylock(&vm->vm_map)) | |||||
goto nextproc1; | |||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
if (p->p_lock != 1 || (p->p_flag & (P_STOPPED_SINGLE | | if (p->p_lock != 1 || (p->p_flag & (P_STOPPED_SINGLE | | ||||
P_TRACED | P_SYSTEM)) != 0) | P_TRACED | P_SYSTEM)) != 0) | ||||
goto nextproc; | goto nextproc; | ||||
/* | /* | ||||
* Only aiod changes vmspace. However, it will be | * Only aiod changes vmspace. However, it will be | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | case PRS_NORMAL: | ||||
*/ | */ | ||||
if ((action & VM_SWAP_NORMAL) != 0 || | if ((action & VM_SWAP_NORMAL) != 0 || | ||||
((action & VM_SWAP_IDLE) != 0 && | ((action & VM_SWAP_IDLE) != 0 && | ||||
minslptime > swap_idle_threshold2)) { | minslptime > swap_idle_threshold2)) { | ||||
_PRELE(p); | _PRELE(p); | ||||
if (swapout(p) == 0) | if (swapout(p) == 0) | ||||
didswap = true; | didswap = true; | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
vm_map_unlock(&vm->vm_map); | |||||
vmspace_free(vm); | vmspace_free(vm); | ||||
goto retry; | goto retry; | ||||
} | } | ||||
} | } | ||||
nextproc: | nextproc: | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
vm_map_unlock(&vm->vm_map); | |||||
nextproc1: | |||||
vmspace_free(vm); | vmspace_free(vm); | ||||
nextproc2: | nextproc2: | ||||
sx_slock(&allproc_lock); | sx_slock(&allproc_lock); | ||||
PRELE(p); | PRELE(p); | ||||
} | } | ||||
sx_sunlock(&allproc_lock); | sx_sunlock(&allproc_lock); | ||||
/* | /* | ||||
* If we swapped something out, and another process needed memory, | * If we swapped something out, and another process needed memory, | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |