> Date: Tue, 26 Apr 2022 14:09:36 +0200
> From: Martin Pieuchot
>
> Small diff to decrement the counter only if the I/O succeed. This
> prevent a false positive if a check is performed before an error is
> returned.
>
> ok?
yes that should be fine
ok kettenis@
> Index: uvm/uvm_swap.c
> ===
> RCS file: /cvs/src/sys/uvm/uvm_swap.c,v
> retrieving revision 1.154
> diff -u -p -r1.154 uvm_swap.c
> --- uvm/uvm_swap.c17 Mar 2022 10:15:13 - 1.154
> +++ uvm/uvm_swap.c26 Apr 2022 12:04:52 -
> @@ -1572,17 +1572,16 @@ uvm_swap_get(struct vm_page *page, int s
> }
>
> KERNEL_LOCK();
> - /* this page is (about to be) no longer only in swap. */
> - atomic_dec_int(&uvmexp.swpgonly);
> -
> result = uvm_swap_io(&page, swslot, 1, B_READ |
> ((flags & PGO_SYNCIO) ? 0 : B_ASYNC));
> + KERNEL_UNLOCK();
>
> - if (result != VM_PAGER_OK && result != VM_PAGER_PEND) {
> - /* oops, the read failed so it really is still only in swap. */
> - atomic_inc_int(&uvmexp.swpgonly);
> + if (result == VM_PAGER_OK || result == VM_PAGER_PEND) {
> + /*
> + * this page is no longer only in swap.
> + */
> + atomic_dec_int(&uvmexp.swpgonly);
> }
> - KERNEL_UNLOCK();
> return (result);
> }
>
>
>