> Stuart, Miod, I wonder if this also help for the off-by-one issue you
> are seeing. It might not.
It makes the aforementioned issue disappear on the affected machine.
> Comments, ok?
> diff --git sys/uvm/uvm_pdaemon.c sys/uvm/uvm_pdaemon.c
> index 284211d226c..a26a776df67 100644
> --- sys/uvm/uvm_pdaemon.c
> +++ sys/uvm/uvm_pdaemon.c
> @@ -917,9 +914,7 @@ uvmpd_scan(struct uvm_pmalloc *pma, struct
> uvm_constraint_range *constraint)
> */
> free = uvmexp.free - BUFPAGES_DEFICIT;
> swap_shortage = 0;
> - if (free < uvmexp.freetarg &&
> - uvmexp.swpginuse == uvmexp.swpages &&
> - !uvm_swapisfull() &&
> + if (free < uvmexp.freetarg && uvm_swapisfilled() && !uvm_swapisfull() &&
> pages_freed == 0) {
> swap_shortage = uvmexp.freetarg - free;
> }
It's unfortunate that you now invoke two uvm_swapisxxx() routines, which
will both acquire a mutex. Maybe a third uvm_swapisxxx routine could be
introduced to compute the swapisfilled && !swapisfull condition at once?