-/* $OpenBSD: uvm_anon.c,v 1.51 2021/01/19 13:21:36 mpi Exp $ */
+/* $OpenBSD: uvm_anon.c,v 1.52 2021/03/04 09:00:03 mpi Exp $ */
/* $NetBSD: uvm_anon.c,v 1.10 2000/11/25 06:27:59 chs Exp $ */
/*
}
} else {
if (anon->an_swslot != 0) {
- /* this page is no longer only in swap. */
+ /* This page is no longer only in swap. */
KASSERT(uvmexp.swpgonly > 0);
- uvmexp.swpgonly--;
+ atomic_dec_int(&uvmexp.swpgonly);
}
}
anon->an_lock = NULL;
-/* $OpenBSD: uvm_aobj.c,v 1.90 2021/01/11 18:51:09 mpi Exp $ */
+/* $OpenBSD: uvm_aobj.c,v 1.91 2021/03/04 09:00:03 mpi Exp $ */
/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
/*
* this page is no longer
* only in swap.
*/
- uvmexp.swpgonly--;
+ atomic_dec_int(&uvmexp.swpgonly);
}
next = LIST_NEXT(elt, list);
if (slot) {
uvm_swap_free(slot, 1);
/* this page is no longer only in swap. */
- uvmexp.swpgonly--;
+ atomic_dec_int(&uvmexp.swpgonly);
}
}
free(aobj->u_swslots, M_UVMAOBJ, aobj->u_pages * sizeof(int));
*/
if (swpgonlydelta > 0) {
KASSERT(uvmexp.swpgonly >= swpgonlydelta);
- uvmexp.swpgonly -= swpgonlydelta;
+ atomic_add_int(&uvmexp.swpgonly, -swpgonlydelta);
}
}
-/* $OpenBSD: uvm_km.c,v 1.139 2020/12/15 22:14:42 mpi Exp $ */
+/* $OpenBSD: uvm_km.c,v 1.140 2021/03/04 09:00:03 mpi Exp $ */
/* $NetBSD: uvm_km.c,v 1.42 2001/01/14 02:10:01 thorpej Exp $ */
/*
struct vm_page *pp;
voff_t curoff;
int slot;
+ int swpgonlydelta = 0;
KASSERT(uobj->pgops == &aobj_pager);
uvm_pagefree(pp);
uvm_unlock_pageq();
} else if (slot != 0) {
- uvmexp.swpgonly--;
+ swpgonlydelta++;
}
}
+
+ if (swpgonlydelta > 0) {
+ KASSERT(uvmexp.swpgonly >= swpgonlydelta);
+ atomic_add_int(&uvmexp.swpgonly, -swpgonlydelta);
+ }
}
-/* $OpenBSD: uvm_pdaemon.c,v 1.89 2021/03/01 09:13:33 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.90 2021/03/04 09:00:03 mpi Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
if (p->pg_flags & PG_CLEAN) {
if (p->pg_flags & PQ_SWAPBACKED) {
/* this page now lives only in swap */
- uvmexp.swpgonly++;
+ atomic_inc_int(&uvmexp.swpgonly);
}
/* zap all mappings with pmap_page_protect... */
if (p->pg_flags & PG_CLEAN) {
if (p->pg_flags & PQ_SWAPBACKED) {
/* this page now lives only in swap */
- uvmexp.swpgonly++;
+ atomic_inc_int(&uvmexp.swpgonly);
}
/* zap all mappings with pmap_page_protect... */
-/* $OpenBSD: uvm_swap.c,v 1.148 2020/12/14 13:29:18 mpi Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.149 2021/03/04 09:00:03 mpi Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
KERNEL_LOCK();
/* this page is (about to be) no longer only in swap. */
- uvmexp.swpgonly--;
+ atomic_dec_int(&uvmexp.swpgonly);
result = uvm_swap_io(&page, swslot, 1, B_READ |
((flags & PGO_SYNCIO) ? 0 : B_ASYNC));
if (result != VM_PAGER_OK && result != VM_PAGER_PEND) {
/* oops, the read failed so it really is still only in swap. */
- uvmexp.swpgonly++;
+ atomic_inc_int(&uvmexp.swpgonly);
}
KERNEL_UNLOCK();
return (result);
-/* $OpenBSD: uvmexp.h,v 1.8 2020/12/28 14:01:23 mpi Exp $ */
+/* $OpenBSD: uvmexp.h,v 1.9 2021/03/04 09:00:03 mpi Exp $ */
#ifndef _UVM_UVMEXP_
#define _UVM_UVMEXP_
* other than the vm system.
*
* Locks used to protect struct members in this file:
+ * a atomic operations
* I immutable after creation
* K kernel lock
* F uvm_lock_fpageq
int nswapdev; /* number of configured swap devices in system */
int swpages; /* [K] number of PAGE_SIZE'ed swap pages */
int swpginuse; /* number of swap pages in use */
- int swpgonly; /* [K] number of swap pages in use, not also in RAM */
+ int swpgonly; /* [a] number of swap pages in use, not also in RAM */
int nswget; /* number of swap pages moved from disk to RAM */
int nanon; /* XXX number total of anon's in system */
int unused05; /* formerly nanonneeded */