Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_fault.c
Show First 20 Lines • Show All 1,107 Lines • ▼ Show 20 Lines | ||||||||||
/* | /* | |||||||||
* Allocate a page directly or via the object populate method. | * Allocate a page directly or via the object populate method. | |||||||||
*/ | */ | |||||||||
static int | static int | |||||||||
vm_fault_allocate(struct faultstate *fs) | vm_fault_allocate(struct faultstate *fs) | |||||||||
{ | { | |||||||||
struct domainset *dset; | struct domainset *dset; | |||||||||
int alloc_req; | ||||||||||
int rv; | int rv; | |||||||||
if ((fs->object->flags & OBJ_SIZEVNLOCK) != 0) { | if ((fs->object->flags & OBJ_SIZEVNLOCK) != 0) { | |||||||||
rv = vm_fault_lock_vnode(fs, true); | rv = vm_fault_lock_vnode(fs, true); | |||||||||
MPASS(rv == KERN_SUCCESS || rv == KERN_RESOURCE_SHORTAGE); | MPASS(rv == KERN_SUCCESS || rv == KERN_RESOURCE_SHORTAGE); | |||||||||
if (rv == KERN_RESOURCE_SHORTAGE) | if (rv == KERN_RESOURCE_SHORTAGE) | |||||||||
return (rv); | return (rv); | |||||||||
} | } | |||||||||
Show All 20 Lines | if (fs->object == fs->first_object && | |||||||||
default: | default: | |||||||||
panic("inconsistent return codes"); | panic("inconsistent return codes"); | |||||||||
} | } | |||||||||
} | } | |||||||||
/* | /* | |||||||||
* 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 | * If the process has a fatal signal pending, prioritize the allocation | |||||||||
* might be not observed there, and allocation can fail, causing | * with the expectation that the process will exit shortly and free some | |||||||||
* restart and new reading of the p_flag. | * pages. In particular, the signal may have been posted by the page | |||||||||
* daemon in an attempt to resolve an out-of-memory condition. | ||||||||||
* | ||||||||||
* The unlocked read of the p_flag is harmless. At worst, the P_KILLED | ||||||||||
* might be not observed here, and allocation fails, causing a restart | ||||||||||
alcUnsubmitted Done Inline Actions
alc: | ||||||||||
* and new reading of the p_flag. | ||||||||||
*/ | */ | |||||||||
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) ? | fs->m = vm_page_alloc(fs->object, fs->pindex, | |||||||||
VM_ALLOC_SYSTEM : VM_ALLOC_NORMAL; | P_KILLED(curproc) ? VM_ALLOC_SYSTEM : 0); | |||||||||
Done Inline Actions
alc: | ||||||||||
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); | ||||||||||
} | } | |||||||||
if (fs->m == NULL) { | if (fs->m == NULL) { | |||||||||
if (vm_fault_allocate_oom(fs)) | if (vm_fault_allocate_oom(fs)) | |||||||||
vm_waitpfault(dset, vm_pfault_oom_wait * hz); | vm_waitpfault(dset, vm_pfault_oom_wait * hz); | |||||||||
return (KERN_RESOURCE_SHORTAGE); | return (KERN_RESOURCE_SHORTAGE); | |||||||||
} | } | |||||||||
fs->oom_started = false; | fs->oom_started = false; | |||||||||
▲ Show 20 Lines • Show All 954 Lines • Show Last 20 Lines |