vm_phys_alloc_queues_contig tries assembling consecutive small free blocks into a range big enough to satisfy a multipage request only in the case when the multipage request is for more pages than can be allocated from any free list. Change it so that it can try the same thing for smaller allocation requests that find all big-enough free lists empty.
Move the freeing of extra pages from vm_phys_alloc_queues_contig to vm_phys_alloc_contig. Move the assembly of several blocks to make a multipage allocation from vm_phys_alloc_queues to a new function, vm_phys_alloc_freelist_contig.