| 171 | } |
| 172 | |
| 173 | static vm_page_t |
| 174 | kmem_alloc_contig_pages(vm_object_t object, vm_pindex_t pindex, int domain, |
| 175 | int pflags, u_long npages, vm_paddr_t low, vm_paddr_t high, |
| 176 | u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr) |
| 177 | { |
| 178 | vm_page_t m; |
| 179 | int tries; |
| 180 | bool wait; |
| 181 | |
| 182 | VM_OBJECT_ASSERT_WLOCKED(object); |
| 183 | |
| 184 | wait = (pflags & VM_ALLOC_WAITOK) != 0; |
| 185 | pflags &= ~(VM_ALLOC_NOWAIT | VM_ALLOC_WAITOK | VM_ALLOC_WAITFAIL); |
| 186 | pflags |= VM_ALLOC_NOWAIT; |
| 187 | for (tries = wait ? 3 : 1;; tries--) { |
| 188 | m = vm_page_alloc_contig_domain(object, pindex, domain, pflags, |
| 189 | npages, low, high, alignment, boundary, memattr); |
| 190 | if (m != NULL || tries == 0) |
| 191 | break; |
| 192 | |
| 193 | VM_OBJECT_WUNLOCK(object); |
| 194 | if (!vm_page_reclaim_contig_domain(domain, pflags, npages, |
| 195 | low, high, alignment, boundary) && wait) |
| 196 | vm_wait_domain(domain); |
| 197 | VM_OBJECT_WLOCK(object); |
| 198 | } |
| 199 | return (m); |
| 200 | } |
| 201 | |
| 202 | /* |
| 203 | * Allocates a region from the kernel address map and physical pages |
no test coverage detected