vm_reserv_reclaim_contig breaks a reservation with enough free space to satisfy an allocation request and returns the free space to the buddy allocator. Change the function to allocate the request memory from the reservation before breaking it, and returning that memory to the caller. That avoids a second call to the buddy allocator and guarantees successful allocation after breaking the reservation, where that success is not currently guaranteed.
The indentation looks wrong.
As an aside, I find this KASSERT confusing because we disallow VM_ALLOC_WAITOK in the very first KASSERT.
As 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?
This could all be performed after the reservation is unlocked.
This can be done before marking the pages as allocated.