Instead of calling vm_page_free_toq() for each vm_page, create and call a function, vm_page_free_spglist(), that frees a list of vm_pages.
I used vm_page_reclaim_run() as a reference when to lock mutex and call vm_page_free_phys().
This reduces the number of locks and also duration of lock.