Move the allocation of memory from vm_phys_alloc_queues_contig to vm_phys_alloc_contig, and rename the former to vm_phys_find_queues_contig.
In vm_phys_find_queues_contig, leave the fast allocation code here, but move the scanning-multiple-blocks allocation code to a new function, vm_phys_find_freelist_contig.
In vm_phys_alloc_freelist_contig, don't start walking a sequence of free blocks of a certain size except when it's the first in a sequence. Try to use the smaller free blocks that may precede that first free block as part of the allocation, if present and if alignment conditions allow.