Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_object.c
Show First 20 Lines • Show All 1,391 Lines • ▼ Show 20 Lines | if (vm_page_tryxbusy(tm) == 0) { | ||||
if (advice == MADV_WILLNEED) { | if (advice == MADV_WILLNEED) { | ||||
/* | /* | ||||
* Reference the page before unlocking and | * Reference the page before unlocking and | ||||
* sleeping so that the page daemon is less | * sleeping so that the page daemon is less | ||||
* likely to reclaim it. | * likely to reclaim it. | ||||
*/ | */ | ||||
vm_page_aflag_set(tm, PGA_REFERENCED); | vm_page_aflag_set(tm, PGA_REFERENCED); | ||||
} | } | ||||
vm_page_busy_sleep(tm, "madvpo", false); | if (!vm_page_busy_sleep(tm, "madvpo", 0)) | ||||
VM_OBJECT_WUNLOCK(tobject); | |||||
goto relookup; | goto relookup; | ||||
} | } | ||||
vm_page_advise(tm, advice); | vm_page_advise(tm, advice); | ||||
vm_page_xunbusy(tm); | vm_page_xunbusy(tm); | ||||
vm_object_madvise_freespace(tobject, advice, tm->pindex, 1); | vm_object_madvise_freespace(tobject, advice, tm->pindex, 1); | ||||
next_pindex: | next_pindex: | ||||
if (tobject != object) | if (tobject != object) | ||||
VM_OBJECT_WUNLOCK(tobject); | VM_OBJECT_WUNLOCK(tobject); | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | for (; m != NULL && (idx = m->pindex - offidxstart) < size; | ||||
* We must wait for pending I/O to complete before we can | * We must wait for pending I/O to complete before we can | ||||
* rename the page. | * rename the page. | ||||
* | * | ||||
* We do not have to VM_PROT_NONE the page as mappings should | * We do not have to VM_PROT_NONE the page as mappings should | ||||
* not be changed by this operation. | * not be changed by this operation. | ||||
*/ | */ | ||||
if (vm_page_tryxbusy(m) == 0) { | if (vm_page_tryxbusy(m) == 0) { | ||||
VM_OBJECT_WUNLOCK(new_object); | VM_OBJECT_WUNLOCK(new_object); | ||||
vm_page_sleep_if_busy(m, "spltwt"); | if (vm_page_busy_sleep(m, "spltwt", 0)) | ||||
VM_OBJECT_WLOCK(orig_object); | |||||
VM_OBJECT_WLOCK(new_object); | VM_OBJECT_WLOCK(new_object); | ||||
goto retry; | goto retry; | ||||
} | } | ||||
/* | /* | ||||
* The page was left invalid. Likely placed there by | * The page was left invalid. Likely placed there by | ||||
* an incomplete fault. Just remove and ignore. | * an incomplete fault. Just remove and ignore. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | vm_object_collapse_scan_wait(vm_object_t object, vm_page_t p) | ||||
KASSERT(p == NULL || p->object == object || p->object == backing_object, | KASSERT(p == NULL || p->object == object || p->object == backing_object, | ||||
("invalid ownership %p %p %p", p, object, backing_object)); | ("invalid ownership %p %p %p", p, object, backing_object)); | ||||
/* The page is only NULL when rename fails. */ | /* The page is only NULL when rename fails. */ | ||||
if (p == NULL) { | if (p == NULL) { | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
VM_OBJECT_WUNLOCK(backing_object); | VM_OBJECT_WUNLOCK(backing_object); | ||||
vm_radix_wait(); | vm_radix_wait(); | ||||
} else { | VM_OBJECT_WLOCK(object); | ||||
if (p->object == object) | } else if (p->object == object) { | ||||
VM_OBJECT_WUNLOCK(backing_object); | VM_OBJECT_WUNLOCK(backing_object); | ||||
else | if (vm_page_busy_sleep(p, "vmocol", 0)) | ||||
VM_OBJECT_WLOCK(object); | |||||
} else { | |||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
vm_page_busy_sleep(p, "vmocol", false); | if (!vm_page_busy_sleep(p, "vmocol", 0)) | ||||
} | VM_OBJECT_WUNLOCK(backing_object); | ||||
VM_OBJECT_WLOCK(object); | VM_OBJECT_WLOCK(object); | ||||
} | |||||
VM_OBJECT_WLOCK(backing_object); | VM_OBJECT_WLOCK(backing_object); | ||||
return (TAILQ_FIRST(&backing_object->memq)); | return (TAILQ_FIRST(&backing_object->memq)); | ||||
} | } | ||||
static bool | static bool | ||||
vm_object_scan_all_shadowed(vm_object_t object) | vm_object_scan_all_shadowed(vm_object_t object) | ||||
{ | { | ||||
vm_object_t backing_object; | vm_object_t backing_object; | ||||
▲ Show 20 Lines • Show All 412 Lines • ▼ Show 20 Lines | for (; p != NULL && (p->pindex < end || end == 0); p = next) { | ||||
* If the page is wired for any reason besides the existence | * If the page is wired for any reason besides the existence | ||||
* of managed, wired mappings, then it cannot be freed. For | * of managed, wired mappings, then it cannot be freed. For | ||||
* example, fictitious pages, which represent device memory, | * example, fictitious pages, which represent device memory, | ||||
* are inherently wired and cannot be freed. They can, | * are inherently wired and cannot be freed. They can, | ||||
* however, be invalidated if the option OBJPR_CLEANONLY is | * however, be invalidated if the option OBJPR_CLEANONLY is | ||||
* not specified. | * not specified. | ||||
*/ | */ | ||||
if (vm_page_tryxbusy(p) == 0) { | if (vm_page_tryxbusy(p) == 0) { | ||||
vm_page_sleep_if_busy(p, "vmopar"); | if (vm_page_busy_sleep(p, "vmopar", 0)) | ||||
VM_OBJECT_WLOCK(object); | |||||
goto again; | goto again; | ||||
} | } | ||||
if (vm_page_wired(p)) { | if (vm_page_wired(p)) { | ||||
wired: | wired: | ||||
if ((options & OBJPR_NOTMAPPED) == 0 && | if ((options & OBJPR_NOTMAPPED) == 0 && | ||||
object->ref_count != 0) | object->ref_count != 0) | ||||
pmap_remove_all(p); | pmap_remove_all(p); | ||||
if ((options & OBJPR_CLEANONLY) == 0) { | if ((options & OBJPR_CLEANONLY) == 0) { | ||||
▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | while (pindex < end_pindex) { | ||||
if (vm_page_trysbusy(tm) == 0) { | if (vm_page_trysbusy(tm) == 0) { | ||||
for (tobject = object; locked_depth >= 1; | for (tobject = object; locked_depth >= 1; | ||||
locked_depth--) { | locked_depth--) { | ||||
t1object = tobject->backing_object; | t1object = tobject->backing_object; | ||||
if (tm->object != tobject) | if (tm->object != tobject) | ||||
VM_OBJECT_RUNLOCK(tobject); | VM_OBJECT_RUNLOCK(tobject); | ||||
tobject = t1object; | tobject = t1object; | ||||
} | } | ||||
vm_page_busy_sleep(tm, "unwbo", true); | tobject = tm->object; | ||||
if (!vm_page_busy_sleep(tm, "unwbo", | |||||
VM_ALLOC_IGN_SBUSY)) | |||||
VM_OBJECT_RUNLOCK(tobject); | |||||
goto again; | goto again; | ||||
} | } | ||||
vm_page_unwire(tm, queue); | vm_page_unwire(tm, queue); | ||||
vm_page_sunbusy(tm); | vm_page_sunbusy(tm); | ||||
next_page: | next_page: | ||||
pindex++; | pindex++; | ||||
} | } | ||||
/* Release the accumulated object locks. */ | /* Release the accumulated object locks. */ | ||||
▲ Show 20 Lines • Show All 438 Lines • Show Last 20 Lines |