Changeset View
Changeset View
Standalone View
Standalone View
head/sys/vm/vm_reserv.c
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | |||||
* from existing or newly created reservations. All of the physical pages | * from existing or newly created reservations. All of the physical pages | ||||
* must be at or above the given physical address "low" and below the given | * must be at or above the given physical address "low" and below the given | ||||
* physical address "high". The given value "alignment" determines the | * physical address "high". The given value "alignment" determines the | ||||
* alignment of the first physical page in the set. If the given value | * alignment of the first physical page in the set. If the given value | ||||
* "boundary" is non-zero, then the set of physical pages cannot cross any | * "boundary" is non-zero, then the set of physical pages cannot cross any | ||||
* physical address boundary that is a multiple of that value. Both | * physical address boundary that is a multiple of that value. Both | ||||
* "alignment" and "boundary" must be a power of two. | * "alignment" and "boundary" must be a power of two. | ||||
* | * | ||||
* The page "mpred" must immediately precede the offset "pindex" within the | |||||
* specified object. | |||||
* | |||||
* The object and free page queue must be locked. | * The object and free page queue must be locked. | ||||
*/ | */ | ||||
vm_page_t | vm_page_t | ||||
vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, | vm_reserv_alloc_contig(vm_object_t object, vm_pindex_t pindex, u_long npages, | ||||
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary) | vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, | ||||
vm_page_t mpred) | |||||
{ | { | ||||
vm_paddr_t pa, size; | vm_paddr_t pa, size; | ||||
vm_page_t m, m_ret, mpred, msucc; | vm_page_t m, m_ret, msucc; | ||||
vm_pindex_t first, leftcap, rightcap; | vm_pindex_t first, leftcap, rightcap; | ||||
vm_reserv_t rv; | vm_reserv_t rv; | ||||
u_long allocpages, maxpages, minpages; | u_long allocpages, maxpages, minpages; | ||||
int i, index, n; | int i, index, n; | ||||
mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); | mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); | ||||
VM_OBJECT_ASSERT_WLOCKED(object); | VM_OBJECT_ASSERT_WLOCKED(object); | ||||
KASSERT(npages != 0, ("vm_reserv_alloc_contig: npages is 0")); | KASSERT(npages != 0, ("vm_reserv_alloc_contig: npages is 0")); | ||||
Show All 20 Lines | if ((pa & (alignment - 1)) != 0) | ||||
return (NULL); | return (NULL); | ||||
size = npages << PAGE_SHIFT; | size = npages << PAGE_SHIFT; | ||||
if (((pa ^ (pa + size - 1)) & ~(boundary - 1)) != 0) | if (((pa ^ (pa + size - 1)) & ~(boundary - 1)) != 0) | ||||
return (NULL); | return (NULL); | ||||
/* | /* | ||||
* Look for an existing reservation. | * Look for an existing reservation. | ||||
*/ | */ | ||||
mpred = vm_radix_lookup_le(&object->rtree, pindex); | |||||
if (mpred != NULL) { | if (mpred != NULL) { | ||||
KASSERT(mpred->object == object, | |||||
("vm_reserv_alloc_contig: object doesn't contain mpred")); | |||||
KASSERT(mpred->pindex < pindex, | KASSERT(mpred->pindex < pindex, | ||||
("vm_reserv_alloc_contig: pindex already allocated")); | ("vm_reserv_alloc_contig: mpred doesn't precede pindex")); | ||||
rv = vm_reserv_from_page(mpred); | rv = vm_reserv_from_page(mpred); | ||||
if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) | if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) | ||||
goto found; | goto found; | ||||
msucc = TAILQ_NEXT(mpred, listq); | msucc = TAILQ_NEXT(mpred, listq); | ||||
} else | } else | ||||
msucc = TAILQ_FIRST(&object->memq); | msucc = TAILQ_FIRST(&object->memq); | ||||
if (msucc != NULL) { | if (msucc != NULL) { | ||||
KASSERT(msucc->pindex > pindex, | KASSERT(msucc->pindex > pindex, | ||||
("vm_reserv_alloc_contig: pindex already allocated")); | ("vm_reserv_alloc_contig: msucc doesn't succeed pindex")); | ||||
rv = vm_reserv_from_page(msucc); | rv = vm_reserv_from_page(msucc); | ||||
if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) | if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) | ||||
goto found; | goto found; | ||||
} | } | ||||
/* | /* | ||||
* Could at least one reservation fit between the first index to the | * Could at least one reservation fit between the first index to the | ||||
* left that can be used ("leftcap") and the first index to the right | * left that can be used ("leftcap") and the first index to the right | ||||
▲ Show 20 Lines • Show All 647 Lines • Show Last 20 Lines |