Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_page.c
Show First 20 Lines • Show All 991 Lines • ▼ Show 20 Lines | |||||
static vm_page_t | static vm_page_t | ||||
vm_page_find_contig_domain(int domain, int req, u_long npages, vm_paddr_t low, | vm_page_find_contig_domain(int domain, int req, u_long npages, vm_paddr_t low, | ||||
vm_paddr_t high, u_long alignment, vm_paddr_t boundary) | vm_paddr_t high, u_long alignment, vm_paddr_t boundary) | ||||
{ | { | ||||
struct vm_domain *vmd; | struct vm_domain *vmd; | ||||
vm_page_t m_ret; | vm_page_t m_ret; | ||||
vmd = VM_DOMAIN(domain); | vmd = VM_DOMAIN(domain); | ||||
#if VM_NRESERVLEVEL > 0 | |||||
again: | |||||
#endif | |||||
if (!vm_domain_allocate(vmd, req, npages)) | if (!vm_domain_allocate(vmd, req, npages)) | ||||
return (NULL); | return (NULL); | ||||
/* | /* | ||||
* Try to allocate the pages from the free page queues. | * Try to allocate the pages from the free page queues. | ||||
*/ | */ | ||||
vm_domain_free_lock(vmd); | vm_domain_free_lock(vmd); | ||||
m_ret = vm_phys_alloc_contig(domain, npages, low, high, | m_ret = vm_phys_alloc_contig(domain, npages, low, high, | ||||
alignment, boundary); | alignment, boundary); | ||||
vm_domain_free_unlock(vmd); | vm_domain_free_unlock(vmd); | ||||
if (m_ret != NULL) | if (m_ret != NULL) | ||||
return (m_ret); | return (m_ret); | ||||
vm_domain_freecnt_inc(vmd, npages); | |||||
#if VM_NRESERVLEVEL > 0 | #if VM_NRESERVLEVEL > 0 | ||||
alc: This has to move. If "reclaim" succeeds, you don't want to do this. | |||||
/* | /* | ||||
* Try to break a reservation to replenish free page queues | * Try to break a reservation to allocate the pages. | ||||
* in a way that allows the allocation to succeed. | |||||
*/ | */ | ||||
if ((req & VM_ALLOC_NORECLAIM) == 0 && | if ((req & VM_ALLOC_NORECLAIM) == 0) { | ||||
vm_reserv_reclaim_contig(domain, npages, low, | m_ret = vm_reserv_reclaim_contig(domain, npages, low, | ||||
high, alignment, boundary)) | high, alignment, boundary); | ||||
goto again; | if (m_ret != NULL) | ||||
return (m_ret); | |||||
alcUnsubmitted Done Inline ActionsThe indentation looks wrong. alc: The indentation looks wrong. | |||||
} | |||||
#endif | #endif | ||||
return (m_ret); | vm_domain_freecnt_inc(vmd, npages); | ||||
return (NULL); | |||||
} | } | ||||
vm_page_t | vm_page_t | ||||
vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, | vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, | ||||
int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, | int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, | ||||
vm_paddr_t boundary, vm_memattr_t memattr) | vm_paddr_t boundary, vm_memattr_t memattr) | ||||
{ | { | ||||
vm_page_t m, m_ret, mpred; | vm_page_t m, m_ret, mpred; | ||||
u_int busy_lock, flags, oflags; | u_int busy_lock, flags, oflags; | ||||
#define VPAC_FLAGS (VPA_FLAGS | VM_ALLOC_NORECLAIM) | #define VPAC_FLAGS (VPA_FLAGS | VM_ALLOC_NORECLAIM) | ||||
KASSERT((req & ~VPAC_FLAGS) == 0, | KASSERT((req & ~VPAC_FLAGS) == 0, | ||||
("invalid request %#x", req)); | ("invalid request %#x", req)); | ||||
KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) != | KASSERT(((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) != | ||||
(VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)), | (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)), | ||||
("invalid request %#x", req)); | ("invalid request %#x", req)); | ||||
KASSERT((req & (VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM)) != | KASSERT((req & (VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM)) != | ||||
(VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM), | (VM_ALLOC_WAITOK | VM_ALLOC_NORECLAIM), | ||||
("invalid request %#x", req)); | ("invalid request %#x", req)); | ||||
alcUnsubmitted Not Done Inline ActionsAs an aside, I find this KASSERT confusing because we disallow VM_ALLOC_WAITOK in the very first KASSERT. alc: As an aside, I find this KASSERT confusing because we disallow VM_ALLOC_WAITOK in the very… | |||||
VM_OBJECT_ASSERT_WLOCKED(object); | VM_OBJECT_ASSERT_WLOCKED(object); | ||||
KASSERT((object->flags & OBJ_FICTITIOUS) == 0, | KASSERT((object->flags & OBJ_FICTITIOUS) == 0, | ||||
("vm_page_alloc_contig: object %p has fictitious pages", | ("vm_page_alloc_contig: object %p has fictitious pages", | ||||
object)); | object)); | ||||
KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero")); | KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero")); | ||||
mpred = vm_radix_lookup_le(&object->rtree, pindex); | mpred = vm_radix_lookup_le(&object->rtree, pindex); | ||||
KASSERT(mpred == NULL || mpred->pindex != pindex, | KASSERT(mpred == NULL || mpred->pindex != pindex, | ||||
("vm_page_alloc_contig: pindex already allocated")); | ("vm_page_alloc_contig: pindex already allocated")); | ||||
/* | /* | ||||
* Can we allocate the pages without the number of free pages falling | * Can we allocate the pages without the number of free pages falling | ||||
* below the lower bound for the allocation class? | * below the lower bound for the allocation class? | ||||
*/ | */ | ||||
for (;;) { | for (;;) { | ||||
alcUnsubmitted Not Done Inline ActionsAs an aside, I don't see the point of this loop because because we disallow VM_ALLOC_WAITOK in the very first KASSERT. Kostik? Mark? alc: As an aside, I don't see the point of this loop because because we disallow VM_ALLOC_WAITOK in… | |||||
#if VM_NRESERVLEVEL > 0 | #if VM_NRESERVLEVEL > 0 | ||||
/* | /* | ||||
* Can we allocate the pages from a reservation? | * Can we allocate the pages from a reservation? | ||||
*/ | */ | ||||
if (vm_object_reserv(object) && | if (vm_object_reserv(object) && | ||||
(m_ret = vm_reserv_alloc_contig(object, pindex, domain, req, | (m_ret = vm_reserv_alloc_contig(object, pindex, domain, req, | ||||
mpred, npages, low, high, alignment, boundary)) != NULL) { | mpred, npages, low, high, alignment, boundary)) != NULL) { | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 957 Lines • Show Last 20 Lines |
This has to move. If "reclaim" succeeds, you don't want to do this.