> I wonder if the diff below makes a difference. It's hard to debug and it
> might be worth adding a counter for bad swap slots.
It did not help (but your diff is probably correct).
> Index: uvm/uvm_anon.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_anon.c,v
> retrieving revision 1.56
> diff -u -p -r1.56 uvm_anon.c
> --- uvm/uvm_anon.c 2 Sep 2023 08:24:40 -0000 1.56
> +++ uvm/uvm_anon.c 22 Oct 2023 21:27:42 -0000
> @@ -116,7 +116,7 @@ uvm_anfree_list(struct vm_anon *anon, st
> uvm_unlock_pageq(); /* free the daemon */
> }
> } else {
> - if (anon->an_swslot != 0) {
> + if (anon->an_swslot != 0 && anon->an_swslot != SWSLOT_BAD) {
> /* This page is no longer only in swap. */
> KASSERT(uvmexp.swpgonly > 0);
> atomic_dec_int(&uvmexp.swpgonly);