Recent attempts to perform large sbuilds without mach-defpager resulted in occasional panics where privileged threads were unable to allocate memory pages even though memory was available. This was a known issue based on the FIXME within the existing code.
Current code locks vm_page_queue_free_lock before calling vm_page_alloc_pa(). That same lock is however acquired within the page balancing code so I've had to rearrange the locking slightly. The 2 calls to vm_page_alloc_pa from vm_resident.c don't rely on the lock until after the call has completed so I've transferred the responsibility to acquire the lock to vm_page_alloc_pa and documented it in the header. This change permits vm_page_alloc_pa to lock and unlock as needed whilst preserving the new semantics declared in the header. I hope that makes sense; it's simpler just to look at the code really. The patch to address this has been tested in this sbuild environment and I have verified that calls to vm_page_alloc_pa() have successfully been made that would previously have resulted in the panic. I haven't tested it on SMP but I did compile gnumach with MACH_LDEBUG set to 1 which should test that the locking doesn't self-deadlock. Mike.
