Index: sys/vm/vm_glue.c =================================================================== --- sys/vm/vm_glue.c +++ sys/vm/vm_glue.c @@ -623,8 +623,9 @@ m = vm_page_grab(obj, pindex + n, VM_ALLOC_NOCREAT | VM_ALLOC_WIRED); if (m == NULL) { - m = vm_page_alloc_domain(obj, pindex + n, domain, - req_class | VM_ALLOC_WIRED); + m = n > 0 ? ma[n - 1] : vm_page_mpred(obj, pindex); + m = vm_page_alloc_domain_after(obj, pindex + n, domain, + req_class | VM_ALLOC_WIRED, m); } if (m == NULL) break; Index: sys/vm/vm_page.h =================================================================== --- sys/vm/vm_page.h +++ sys/vm/vm_page.h @@ -606,8 +606,8 @@ void vm_page_activate (vm_page_t); void vm_page_advise(vm_page_t m, int advice); +vm_page_t vm_page_mpred(vm_object_t, vm_pindex_t); vm_page_t vm_page_alloc(vm_object_t, vm_pindex_t, int); -vm_page_t vm_page_alloc_domain(vm_object_t, vm_pindex_t, int, int); vm_page_t vm_page_alloc_after(vm_object_t, vm_pindex_t, int, vm_page_t); vm_page_t vm_page_alloc_domain_after(vm_object_t, vm_pindex_t, int, int, vm_page_t); Index: sys/vm/vm_page.c =================================================================== --- sys/vm/vm_page.c +++ sys/vm/vm_page.c @@ -2013,6 +2013,18 @@ return (0); } +/* + * vm_page_mpred: + * + * Return the greatest page of the object with index <= pindex, + * or NULL, if there is none. Assumes object lock is held. + */ +vm_page_t +vm_page_mpred(vm_object_t object, vm_pindex_t pindex) +{ + return (vm_radix_lookup_le(&object->rtree, pindex)); +} + /* * vm_page_alloc: * @@ -2040,16 +2052,7 @@ { return (vm_page_alloc_after(object, pindex, req, - vm_radix_lookup_le(&object->rtree, pindex))); -} - -vm_page_t -vm_page_alloc_domain(vm_object_t object, vm_pindex_t pindex, int domain, - int req) -{ - - return (vm_page_alloc_domain_after(object, pindex, domain, req, - vm_radix_lookup_le(&object->rtree, pindex))); + vm_page_mpred(object, pindex))); } /* @@ -2390,7 +2393,7 @@ object)); KASSERT(npages > 0, ("vm_page_alloc_contig: npages is zero")); - mpred = vm_radix_lookup_le(&object->rtree, pindex); + mpred = vm_page_mpred(object, pindex); KASSERT(mpred == NULL || mpred->pindex != pindex, ("vm_page_alloc_contig: pindex already allocated")); for (;;) { @@ -5094,7 +5097,7 @@ pflags = vm_page_grab_pflags(allocflags); i = 0; retrylookup: - m = vm_radix_lookup_le(&object->rtree, pindex + i); + m = vm_page_mpred(object, pindex + i); if (m == NULL || m->pindex != pindex + i) { mpred = m; m = NULL;