If the call to _pmap_allocpte() is not sleepable, it is possible that allocation of PML4 or PDP page is successful but either PDP or PD page is not. Restructured code _pmap_allocpte() leaves zero-referenced page in the paging structure.
Handle it by checking refcount of the page one level above failed alloc and free that page if its reference count is zero.
Reported and tested by: pho