| 2255 | } |
| 2256 | |
| 2257 | vm_page_t |
| 2258 | vm_page_alloc_contig_domain(vm_object_t object, vm_pindex_t pindex, int domain, |
| 2259 | int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, |
| 2260 | vm_paddr_t boundary, vm_memattr_t memattr) |
| 2261 | { |
| 2262 | struct vm_domain *vmd; |
| 2263 | vm_page_t m, m_ret, mpred; |
| 2264 | u_int busy_lock, flags, oflags; |
| 2265 | |
| 2266 | mpred = NULL; /* XXX: pacify gcc */ |
| 2267 | KASSERT((object != NULL) == ((req & VM_ALLOC_NOOBJ) == 0) && |
| 2268 | (object != NULL || (req & VM_ALLOC_SBUSY) == 0) && |
| 2269 | ((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) != |
| 2270 | (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)), |
| 2271 | ("vm_page_alloc_contig: inconsistent object(%p)/req(%x)", object, |
| 2272 | req)); |
| 2273 | KASSERT(object == NULL || (req & VM_ALLOC_WAITOK) == 0, |
| 2274 | ("Can't sleep and retry object insertion.")); |
| 2275 | if (object != NULL) { |
| 2276 | VM_OBJECT_ASSERT_WLOCKED(object); |
| 2277 | KASSERT((object->flags & OBJ_FICTITIOUS) == 0, |
| 2278 | ("vm_page_alloc_contig: object %p has fictitious pages", |
| 2279 | object)); |
| 2280 | } |
| 2281 | KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero")); |
| 2282 | |
| 2283 | if (object != NULL) { |
| 2284 | mpred = vm_radix_lookup_le(&object->rtree, pindex); |
| 2285 | KASSERT(mpred == NULL || mpred->pindex != pindex, |
| 2286 | ("vm_page_alloc_contig: pindex already allocated")); |
| 2287 | } |
| 2288 | |
| 2289 | /* |
| 2290 | * Can we allocate the pages without the number of free pages falling |
| 2291 | * below the lower bound for the allocation class? |
| 2292 | */ |
| 2293 | m_ret = NULL; |
| 2294 | again: |
| 2295 | #if VM_NRESERVLEVEL > 0 |
| 2296 | /* |
| 2297 | * Can we allocate the pages from a reservation? |
| 2298 | */ |
| 2299 | if (vm_object_reserv(object) && |
| 2300 | (m_ret = vm_reserv_alloc_contig(object, pindex, domain, req, |
| 2301 | mpred, npages, low, high, alignment, boundary)) != NULL) { |
| 2302 | goto found; |
| 2303 | } |
| 2304 | #endif |
| 2305 | vmd = VM_DOMAIN(domain); |
| 2306 | if (vm_domain_allocate(vmd, req, npages)) { |
| 2307 | /* |
| 2308 | * allocate them from the free page queues. |
| 2309 | */ |
| 2310 | vm_domain_free_lock(vmd); |
| 2311 | m_ret = vm_phys_alloc_contig(domain, npages, low, high, |
| 2312 | alignment, boundary); |
| 2313 | vm_domain_free_unlock(vmd); |
| 2314 | if (m_ret == NULL) { |
no test coverage detected