Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_page.c
Show First 20 Lines • Show All 3,234 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
return (vm_severe_waiters + vm_min_waiters + vm_pageproc_waiters); | return (vm_severe_waiters + vm_min_waiters + vm_pageproc_waiters); | ||||
} | } | ||||
int | int | ||||
vm_wait_doms(const domainset_t *wdoms, int mflags) | vm_wait_doms(const domainset_t *wdoms, int mflags) | ||||
{ | { | ||||
int error; | int error; | ||||
alc: As an aside, this variable seems pointless. Each of the 3 cases could end in a return… | |||||
error = 0; | error = 0; | ||||
/* | /* | ||||
* We use racey wakeup synchronization to avoid expensive global | * We use racey wakeup synchronization to avoid expensive global | ||||
* locking for the pageproc when sleeping with a non-specific vm_wait. | * locking for the pageproc when sleeping with a non-specific vm_wait. | ||||
* To handle this, we only sleep for one tick in this instance. It | * To handle this, we only sleep for one tick in this instance. It | ||||
* is expected that most allocations for the pageproc will come from | * is expected that most allocations for the pageproc will come from | ||||
* kmem or vm_page_grab* which will use the more specific and | * kmem or vm_page_grab* which will use the more specific and | ||||
* race-free vm_wait_domain(). | * race-free vm_wait_domain(). | ||||
*/ | */ | ||||
if (curproc == pageproc) { | if (curproc == pageproc) { | ||||
mtx_lock(&vm_domainset_lock); | mtx_lock(&vm_domainset_lock); | ||||
vm_pageproc_waiters++; | vm_pageproc_waiters++; | ||||
error = msleep(&vm_pageproc_waiters, &vm_domainset_lock, | error = msleep(&vm_pageproc_waiters, &vm_domainset_lock, | ||||
PVM | PDROP | mflags, "pageprocwait", 1); | PVM | PDROP | mflags, "pageprocwait", 1); | ||||
} else { | } else { | ||||
/* | /* | ||||
* XXX Ideally we would wait only until the allocation could | * XXX Ideally we would wait only until the allocation could | ||||
* be satisfied. This condition can cause new allocators to | * be satisfied. This condition can cause new allocators to | ||||
* consume all freed pages while old allocators wait. | * consume all freed pages while old allocators wait. | ||||
*/ | */ | ||||
mtx_lock(&vm_domainset_lock); | mtx_lock(&vm_domainset_lock); | ||||
if (vm_page_count_min_set(wdoms)) { | if (vm_page_count_min_set(wdoms)) { | ||||
if (pageproc == NULL) | |||||
panic("vm_wait in early boot"); | |||||
vm_min_waiters++; | vm_min_waiters++; | ||||
error = msleep(&vm_min_domains, &vm_domainset_lock, | error = msleep(&vm_min_domains, &vm_domainset_lock, | ||||
PVM | PDROP | mflags, "vmwait", 0); | PVM | PDROP | mflags, "vmwait", 0); | ||||
} else | } else | ||||
mtx_unlock(&vm_domainset_lock); | mtx_unlock(&vm_domainset_lock); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
Show All 17 Lines | if (curproc == pageproc) { | ||||
mtx_lock(&vm_domainset_lock); | mtx_lock(&vm_domainset_lock); | ||||
if (vmd->vmd_free_count < vmd->vmd_pageout_free_min) { | if (vmd->vmd_free_count < vmd->vmd_pageout_free_min) { | ||||
vmd->vmd_pageout_pages_needed = 1; | vmd->vmd_pageout_pages_needed = 1; | ||||
msleep(&vmd->vmd_pageout_pages_needed, | msleep(&vmd->vmd_pageout_pages_needed, | ||||
&vm_domainset_lock, PDROP | PSWP, "VMWait", 0); | &vm_domainset_lock, PDROP | PSWP, "VMWait", 0); | ||||
} else | } else | ||||
mtx_unlock(&vm_domainset_lock); | mtx_unlock(&vm_domainset_lock); | ||||
} else { | } else { | ||||
if (pageproc == NULL) | |||||
panic("vm_wait in early boot"); | |||||
DOMAINSET_ZERO(&wdom); | DOMAINSET_ZERO(&wdom); | ||||
DOMAINSET_SET(vmd->vmd_domain, &wdom); | DOMAINSET_SET(vmd->vmd_domain, &wdom); | ||||
vm_wait_doms(&wdom, 0); | vm_wait_doms(&wdom, 0); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
vm_wait_flags(vm_object_t obj, int mflags) | vm_wait_flags(vm_object_t obj, int mflags) | ||||
▲ Show 20 Lines • Show All 2,285 Lines • Show Last 20 Lines |
As an aside, this variable seems pointless. Each of the 3 cases could end in a return statement.