Otherwise parallel _pmap_allocpte() for nearby va might also fail allocating page table page and free the page under us. The end result is that we could dereference unmapped pte when doing cleanup after sleep.
Instead, on allocation failure, first free everything, then sleep right before returning to caller. Due to recursive nature of _pmap_allocpte(), additional argument indicates is this the first call level, or deeper recursive call.
Reported by: pho