Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_swapout.c
Show First 20 Lines • Show All 278 Lines • ▼ Show 20 Lines | vm_swapout_map_deactivate_pages(vm_map_t map, long desired) | ||||
bigobj = NULL; | bigobj = NULL; | ||||
nothingwired = TRUE; | nothingwired = TRUE; | ||||
/* | /* | ||||
* first, search out the biggest object, and try to free pages from | * first, search out the biggest object, and try to free pages from | ||||
* that. | * that. | ||||
*/ | */ | ||||
tmpe = map->header.next; | VM_MAP_ENTRY_FOREACH(tmpe, map) { | ||||
while (tmpe != &map->header) { | |||||
if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { | if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { | ||||
obj = tmpe->object.vm_object; | obj = tmpe->object.vm_object; | ||||
if (obj != NULL && VM_OBJECT_TRYRLOCK(obj)) { | if (obj != NULL && VM_OBJECT_TRYRLOCK(obj)) { | ||||
if (obj->shadow_count <= 1 && | if (obj->shadow_count <= 1 && | ||||
(bigobj == NULL || | (bigobj == NULL || | ||||
bigobj->resident_page_count < | bigobj->resident_page_count < | ||||
obj->resident_page_count)) { | obj->resident_page_count)) { | ||||
if (bigobj != NULL) | if (bigobj != NULL) | ||||
VM_OBJECT_RUNLOCK(bigobj); | VM_OBJECT_RUNLOCK(bigobj); | ||||
bigobj = obj; | bigobj = obj; | ||||
} else | } else | ||||
VM_OBJECT_RUNLOCK(obj); | VM_OBJECT_RUNLOCK(obj); | ||||
} | } | ||||
} | } | ||||
if (tmpe->wired_count > 0) | if (tmpe->wired_count > 0) | ||||
nothingwired = FALSE; | nothingwired = FALSE; | ||||
tmpe = tmpe->next; | |||||
} | } | ||||
if (bigobj != NULL) { | if (bigobj != NULL) { | ||||
vm_swapout_object_deactivate_pages(map->pmap, bigobj, desired); | vm_swapout_object_deactivate_pages(map->pmap, bigobj, desired); | ||||
VM_OBJECT_RUNLOCK(bigobj); | VM_OBJECT_RUNLOCK(bigobj); | ||||
} | } | ||||
/* | /* | ||||
* Next, hunt around for other pages to deactivate. We actually | * Next, hunt around for other pages to deactivate. We actually | ||||
* do this search sort of wrong -- .text first is not the best idea. | * do this search sort of wrong -- .text first is not the best idea. | ||||
*/ | */ | ||||
tmpe = map->header.next; | VM_MAP_ENTRY_FOREACH(tmpe, map) { | ||||
while (tmpe != &map->header) { | |||||
if (pmap_resident_count(vm_map_pmap(map)) <= desired) | if (pmap_resident_count(vm_map_pmap(map)) <= desired) | ||||
break; | break; | ||||
if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { | if ((tmpe->eflags & MAP_ENTRY_IS_SUB_MAP) == 0) { | ||||
obj = tmpe->object.vm_object; | obj = tmpe->object.vm_object; | ||||
if (obj != NULL) { | if (obj != NULL) { | ||||
VM_OBJECT_RLOCK(obj); | VM_OBJECT_RLOCK(obj); | ||||
vm_swapout_object_deactivate_pages(map->pmap, | vm_swapout_object_deactivate_pages(map->pmap, | ||||
obj, desired); | obj, desired); | ||||
VM_OBJECT_RUNLOCK(obj); | VM_OBJECT_RUNLOCK(obj); | ||||
} | } | ||||
} | } | ||||
tmpe = tmpe->next; | |||||
} | } | ||||
/* | /* | ||||
* Remove all mappings if a process is swapped out, this will free page | * Remove all mappings if a process is swapped out, this will free page | ||||
* table pages. | * table pages. | ||||
*/ | */ | ||||
if (desired == 0 && nothingwired) { | if (desired == 0 && nothingwired) { | ||||
pmap_remove(vm_map_pmap(map), vm_map_min(map), | pmap_remove(vm_map_pmap(map), vm_map_min(map), | ||||
▲ Show 20 Lines • Show All 630 Lines • Show Last 20 Lines |