From: mpi Date: Thu, 28 Apr 2022 09:58:11 +0000 (+0000) Subject: Update uvmexp.swpgonly only once in uvm_swap_get(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=979857e1bc594ab645908ae016b4f6467e5d8c8f;p=openbsd Update uvmexp.swpgonly only once in uvm_swap_get(). Prevent a small window where a check could be incorrect in case an error occurs in uvm_swap_io(). ok kettenis@, kn@ --- diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index bee6ac91f61..d49969cfe9c 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap.c,v 1.154 2022/03/17 10:15:13 mpi Exp $ */ +/* $OpenBSD: uvm_swap.c,v 1.155 2022/04/28 09:58:11 mpi Exp $ */ /* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */ /* @@ -1572,17 +1572,16 @@ uvm_swap_get(struct vm_page *page, int swslot, int flags) } 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); }