diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2022-04-28 09:58:12 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2022-04-28 09:58:12 +0000 |
commit | 387c9b5809c67b6ec60a260fe18cffdf940ee3b8 (patch) | |
tree | 9fe70a483e0443a435489b9ff4167fd78233c1c6 | |
parent | 97c4811b66ddf57ed2c2fc8bbe8023cf37b683ca (diff) |
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@
-rw-r--r-- | sys/uvm/uvm_swap.c | 15 |
1 files changed, 7 insertions, 8 deletions
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); } |