Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_fault.c
Show First 20 Lines • Show All 1,028 Lines • ▼ Show 20 Lines | if (fs->object != fs->first_object) { | ||||
fs->object = fs->first_object; | fs->object = fs->first_object; | ||||
fs->pindex = fs->first_pindex; | fs->pindex = fs->first_pindex; | ||||
} | } | ||||
MPASS(fs->first_m != NULL); | MPASS(fs->first_m != NULL); | ||||
MPASS(fs->m == NULL); | MPASS(fs->m == NULL); | ||||
fs->m = fs->first_m; | fs->m = fs->first_m; | ||||
fs->first_m = NULL; | fs->first_m = NULL; | ||||
/* | |||||
* Zero the page if necessary and mark it valid. | |||||
*/ | |||||
if ((fs->m->flags & PG_ZERO) == 0) { | |||||
pmap_zero_page(fs->m); | pmap_zero_page(fs->m); | ||||
} else { | |||||
VM_CNT_INC(v_ozfod); | |||||
} | |||||
VM_CNT_INC(v_zfod); | VM_CNT_INC(v_zfod); | ||||
vm_page_valid(fs->m); | vm_page_valid(fs->m); | ||||
} | } | ||||
/* | /* | ||||
* Allocate a page directly or via the object populate method. | * Allocate a page directly or via the object populate method. | ||||
*/ | */ | ||||
static int | static int | ||||
Show All 34 Lines | vm_fault_allocate(struct faultstate *fs) | ||||
} | } | ||||
/* | /* | ||||
* Allocate a new page for this object/offset pair. | * Allocate a new page for this object/offset pair. | ||||
* | * | ||||
* Unlocked read of the p_flag is harmless. At worst, the P_KILLED | * Unlocked read of the p_flag is harmless. At worst, the P_KILLED | ||||
* might be not observed there, and allocation can fail, causing | * might be not observed there, and allocation can fail, causing | ||||
* restart and new reading of the p_flag. | * restart and new reading of the p_flag. | ||||
* | |||||
* The caller must be careful to zero the page if its contents are not | |||||
* provided by a pager. | |||||
*/ | */ | ||||
dset = fs->object->domain.dr_policy; | dset = fs->object->domain.dr_policy; | ||||
if (dset == NULL) | if (dset == NULL) | ||||
dset = curthread->td_domain.dr_policy; | dset = curthread->td_domain.dr_policy; | ||||
if (!vm_page_count_severe_set(&dset->ds_mask) || P_KILLED(curproc)) { | if (!vm_page_count_severe_set(&dset->ds_mask) || P_KILLED(curproc)) { | ||||
#if VM_NRESERVLEVEL > 0 | #if VM_NRESERVLEVEL > 0 | ||||
vm_object_color(fs->object, atop(fs->vaddr) - fs->pindex); | vm_object_color(fs->object, atop(fs->vaddr) - fs->pindex); | ||||
#endif | #endif | ||||
alloc_req = P_KILLED(curproc) ? | alloc_req = P_KILLED(curproc) ? | ||||
VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL; | VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL; | ||||
if (fs->object->type != OBJT_VNODE && | |||||
fs->object->backing_object == NULL) | |||||
alloc_req |= VM_ALLOC_ZERO; | |||||
fs->m = vm_page_alloc(fs->object, fs->pindex, alloc_req); | fs->m = vm_page_alloc(fs->object, fs->pindex, alloc_req); | ||||
} | } | ||||
if (fs->m == NULL) { | if (fs->m == NULL) { | ||||
unlock_and_deallocate(fs); | unlock_and_deallocate(fs); | ||||
if (vm_pfault_oom_attempts < 0 || | if (vm_pfault_oom_attempts < 0 || | ||||
fs->oom < vm_pfault_oom_attempts) { | fs->oom < vm_pfault_oom_attempts) { | ||||
fs->oom++; | fs->oom++; | ||||
vm_waitpfault(dset, vm_pfault_oom_wait * hz); | vm_waitpfault(dset, vm_pfault_oom_wait * hz); | ||||
▲ Show 20 Lines • Show All 964 Lines • Show Last 20 Lines |