kernel - Fix several low memory+swap pageout/killproc issues
* Add significant slop to the PQAVERAGE() calculation in the
pageout daemon and increase the slop in the vm_paging_target()
test the pageout daemon makes to determine if it can stop early.
These adjustments fix a degenerate case when no swap is configured
and a large number of clean pages are present in the inactive queue
which could prevent the pageout daemon from cleaning a sufficient number
of pages and cause it to start killing processes even when plenty of
freeable memory exists.
* Impose a one-second delay when killing processes due to insufficient
memory + swap. This reduces the chance that multiple processes will
be killed even if the first one would have been sufficient by giving
the kernel more time to dipose of the process.
* Fix a bug in vm_page_alloc(). When v_free_count exactly matches
v_free_reserved it successfully passes the vm_page_count_target()
test but vm_page_alloc() will still fail. This results in a livelock
in vm_fault_object() and will livelock the pageout daemon vs a user
process stuck in vm_fault(), causing the machine to lock.
Fixed by adjusting the conditional test in vm_page_alloc().
Reported-by: luxh