Changeset View
Changeset View
Standalone View
Standalone View
user/alc/PQ_LAUNDRY/sys/vm/vm_reserv.c
Show First 20 Lines • Show All 860 Lines • ▼ Show 20 Lines | while (paddr + VM_LEVEL_0_SIZE <= seg->end) { | ||||
vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT].pages = | vm_reserv_array[paddr >> VM_LEVEL_0_SHIFT].pages = | ||||
PHYS_TO_VM_PAGE(paddr); | PHYS_TO_VM_PAGE(paddr); | ||||
paddr += VM_LEVEL_0_SIZE; | paddr += VM_LEVEL_0_SIZE; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Returns true if the given page belongs to a reservation and that page is | |||||
* free. Otherwise, returns false. | |||||
*/ | |||||
bool | |||||
vm_reserv_is_page_free(vm_page_t m) | |||||
{ | |||||
vm_reserv_t rv; | |||||
mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); | |||||
rv = vm_reserv_from_page(m); | |||||
if (rv->object == NULL) | |||||
return (false); | |||||
return (popmap_is_clear(rv->popmap, m - rv->pages)); | |||||
} | |||||
/* | |||||
* If the given page belongs to a reservation, returns the level of that | |||||
* reservation. Otherwise, returns -1. | |||||
*/ | |||||
int | |||||
vm_reserv_level(vm_page_t m) | |||||
{ | |||||
vm_reserv_t rv; | |||||
rv = vm_reserv_from_page(m); | |||||
return (rv->object != NULL ? 0 : -1); | |||||
} | |||||
/* | |||||
* Returns a reservation level if the given page belongs to a fully-populated | * Returns a reservation level if the given page belongs to a fully-populated | ||||
* reservation and -1 otherwise. | * reservation and -1 otherwise. | ||||
*/ | */ | ||||
int | int | ||||
vm_reserv_level_iffullpop(vm_page_t m) | vm_reserv_level_iffullpop(vm_page_t m) | ||||
{ | { | ||||
vm_reserv_t rv; | vm_reserv_t rv; | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | if (rv->object == old_object) { | ||||
mtx_lock(&vm_page_queue_free_mtx); | mtx_lock(&vm_page_queue_free_mtx); | ||||
if (rv->object == old_object) { | if (rv->object == old_object) { | ||||
LIST_REMOVE(rv, objq); | LIST_REMOVE(rv, objq); | ||||
LIST_INSERT_HEAD(&new_object->rvq, rv, objq); | LIST_INSERT_HEAD(&new_object->rvq, rv, objq); | ||||
rv->object = new_object; | rv->object = new_object; | ||||
rv->pindex -= old_object_offset; | rv->pindex -= old_object_offset; | ||||
} | } | ||||
mtx_unlock(&vm_page_queue_free_mtx); | mtx_unlock(&vm_page_queue_free_mtx); | ||||
} | |||||
} | |||||
/* | |||||
* Returns the size (in bytes) of a reservation of the specified level. | |||||
*/ | |||||
int | |||||
vm_reserv_size(int level) | |||||
{ | |||||
switch (level) { | |||||
case 0: | |||||
return (VM_LEVEL_0_SIZE); | |||||
case -1: | |||||
return (PAGE_SIZE); | |||||
default: | |||||
return (0); | |||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Allocates the virtual and physical memory required by the reservation | * Allocates the virtual and physical memory required by the reservation | ||||
* management system's data structures, in particular, the reservation array. | * management system's data structures, in particular, the reservation array. | ||||
*/ | */ | ||||
vm_paddr_t | vm_paddr_t | ||||
Show All 30 Lines |