Index: sys/vm/vm_page.c =================================================================== --- sys/vm/vm_page.c +++ sys/vm/vm_page.c @@ -2997,6 +2997,16 @@ (count < npages && req_class == VM_ALLOC_INTERRUPT)) return (false); + /* + * The caller will attempt an allocation after some runs have been + * reclaimed and added to the vm_phys buddy lists. To ensure that runs + * are not fragmented, round up the requested length to the next power + * of 2 and ensure that each run is self-aligned. + */ + npages = 1 << flsl(npages - 1); + if (alignment < ptoa(npages)) + alignment = ptoa(npages); + /* * Scan up to three times, relaxing the restrictions ("options") on * the reclamation of reservations and superpages each time.