summaryrefslogtreecommitdiffstats
path: root/sys/uvm/uvm_pdaemon.c
diff options
context:
space:
mode:
authorart <art@openbsd.org>2007-04-13 18:57:49 +0000
committerart <art@openbsd.org>2007-04-13 18:57:49 +0000
commit65d6360cb5c0772769017c581ffa58e5b47fe546 (patch)
tree2a903d1e3ddc3a09bebc4b82a04c078670e5331d /sys/uvm/uvm_pdaemon.c
parentIf a removable device refuses to process PREVENT_ALLOW to lock the (diff)
downloadwireguard-openbsd-65d6360cb5c0772769017c581ffa58e5b47fe546.tar.xz
wireguard-openbsd-65d6360cb5c0772769017c581ffa58e5b47fe546.zip
While splitting flags and pqflags might have been a good idea in theory
to separate locking, on most modern machines this is not enough since operations on short types touch other short types that share the same word in memory. Merge pg_flags and pqflags again and now use atomic operations to change the flags. Also bump wire_count to an int and pg_version might go int as well, just for alignment. tested by many, many. ok miod@
Diffstat (limited to 'sys/uvm/uvm_pdaemon.c')
-rw-r--r--sys/uvm/uvm_pdaemon.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 0ca61319c31..4e6d7757214 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.31 2007/04/04 17:44:45 art Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.32 2007/04/13 18:57:49 art Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -473,7 +473,7 @@ uvmpd_scan_inactive(pglst)
*/
/* is page part of an anon or ownerless ? */
- if ((p->pqflags & PQ_ANON) || p->uobject == NULL) {
+ if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) {
anon = p->uanon;
KASSERT(anon != NULL);
if (!simple_lock_try(&anon->an_lock)) {
@@ -486,10 +486,11 @@ uvmpd_scan_inactive(pglst)
* name of "anon"!
*/
- if ((p->pqflags & PQ_ANON) == 0) {
+ if ((p->pg_flags & PQ_ANON) == 0) {
KASSERT(p->loan_count > 0);
p->loan_count--;
- p->pqflags |= PQ_ANON;
+ atomic_setbits_int(&p->pg_flags,
+ PQ_ANON);
/* anon now owns it */
}
if (p->pg_flags & PG_BUSY) {
@@ -522,7 +523,7 @@ uvmpd_scan_inactive(pglst)
*/
if (p->pg_flags & PG_CLEAN) {
- if (p->pqflags & PQ_SWAPBACKED) {
+ if (p->pg_flags & PQ_SWAPBACKED) {
/* this page now lives only in swap */
simple_lock(&uvm.swap_data_lock);
uvmexp.swpgonly++;
@@ -576,7 +577,7 @@ uvmpd_scan_inactive(pglst)
*/
KASSERT(uvmexp.swpgonly <= uvmexp.swpages);
- if ((p->pqflags & PQ_SWAPBACKED) &&
+ if ((p->pg_flags & PQ_SWAPBACKED) &&
uvmexp.swpgonly == uvmexp.swpages) {
dirtyreacts++;
uvm_pageactivate(p);
@@ -595,15 +596,15 @@ uvmpd_scan_inactive(pglst)
*/
KASSERT(uvmexp.swpginuse <= uvmexp.swpages);
- if ((p->pqflags & PQ_SWAPBACKED) &&
+ if ((p->pg_flags & PQ_SWAPBACKED) &&
uvmexp.swpginuse == uvmexp.swpages) {
- if ((p->pqflags & PQ_ANON) &&
+ if ((p->pg_flags & PQ_ANON) &&
p->uanon->an_swslot) {
uvm_swap_free(p->uanon->an_swslot, 1);
p->uanon->an_swslot = 0;
}
- if (p->pqflags & PQ_AOBJ) {
+ if (p->pg_flags & PQ_AOBJ) {
uao_dropswap(p->uobject,
p->offset >> PAGE_SHIFT);
}
@@ -618,8 +619,8 @@ uvmpd_scan_inactive(pglst)
* in I/O.
*/
- swap_backed = ((p->pqflags & PQ_SWAPBACKED) != 0);
- p->pg_flags |= PG_BUSY; /* now we own it */
+ swap_backed = ((p->pg_flags & PQ_SWAPBACKED) != 0);
+ atomic_setbits_int(&p->pg_flags, PG_BUSY);
UVM_PAGE_OWN(p, "scan_inactive");
pmap_page_protect(p, VM_PROT_READ);
uvmexp.pgswapout++;
@@ -656,7 +657,9 @@ uvmpd_scan_inactive(pglst)
TRUE);
if (swslot == 0) {
/* no swap? give up! */
- p->pg_flags &= ~PG_BUSY;
+ atomic_clearbits_int(
+ &p->pg_flags,
+ PG_BUSY);
UVM_PAGE_OWN(p, NULL);
if (anon)
simple_unlock(
@@ -784,7 +787,7 @@ uvmpd_scan_inactive(pglst)
uvm_lock_pageq();
uvmexp.pdpending++;
if (p) {
- if (p->pqflags & PQ_INACTIVE)
+ if (p->pg_flags & PQ_INACTIVE)
nextpg = TAILQ_NEXT(p, pageq);
else
nextpg = TAILQ_FIRST(pglst);
@@ -850,7 +853,7 @@ uvmpd_scan_inactive(pglst)
/* still holding object lock */
wakeup(p);
- p->pg_flags &= ~(PG_BUSY|PG_WANTED);
+ atomic_clearbits_int(&p->pg_flags, PG_BUSY|PG_WANTED);
UVM_PAGE_OWN(p, NULL);
/* released during I/O? */
@@ -903,7 +906,8 @@ uvmpd_scan_inactive(pglst)
/* pageout was a success... */
pmap_clear_reference(p);
pmap_clear_modify(p);
- p->pg_flags |= PG_CLEAN;
+ atomic_setbits_int(&p->pg_flags,
+ PG_CLEAN);
}
}
@@ -937,7 +941,7 @@ uvmpd_scan_inactive(pglst)
uvm_lock_pageq();
}
- if (nextpg && (nextpg->pqflags & PQ_INACTIVE) == 0) {
+ if (nextpg && (nextpg->pg_flags & PQ_INACTIVE) == 0) {
nextpg = TAILQ_FIRST(pglst); /* reload! */
}
}
@@ -1042,16 +1046,16 @@ uvmpd_scan()
* lock the page's owner.
*/
/* is page anon owned or ownerless? */
- if ((p->pqflags & PQ_ANON) || p->uobject == NULL) {
+ if ((p->pg_flags & PQ_ANON) || p->uobject == NULL) {
KASSERT(p->uanon != NULL);
if (!simple_lock_try(&p->uanon->an_lock))
continue;
/* take over the page? */
- if ((p->pqflags & PQ_ANON) == 0) {
+ if ((p->pg_flags & PQ_ANON) == 0) {
KASSERT(p->loan_count > 0);
p->loan_count--;
- p->pqflags |= PQ_ANON;
+ atomic_setbits_int(&p->pg_flags, PQ_ANON);
}
} else {
if (!simple_lock_try(&p->uobject->vmobjlock))
@@ -1063,7 +1067,7 @@ uvmpd_scan()
*/
if ((p->pg_flags & PG_BUSY) != 0) {
- if (p->pqflags & PQ_ANON)
+ if (p->pg_flags & PQ_ANON)
simple_unlock(&p->uanon->an_lock);
else
simple_unlock(&p->uobject->vmobjlock);
@@ -1076,18 +1080,19 @@ uvmpd_scan()
*/
if (swap_shortage > 0) {
- if ((p->pqflags & PQ_ANON) && p->uanon->an_swslot) {
+ if ((p->pg_flags & PQ_ANON) && p->uanon->an_swslot) {
uvm_swap_free(p->uanon->an_swslot, 1);
p->uanon->an_swslot = 0;
- p->pg_flags &= ~PG_CLEAN;
+ atomic_clearbits_int(&p->pg_flags, PG_CLEAN);
swap_shortage--;
}
- if (p->pqflags & PQ_AOBJ) {
+ if (p->pg_flags & PQ_AOBJ) {
int slot = uao_set_swslot(p->uobject,
p->offset >> PAGE_SHIFT, 0);
if (slot) {
uvm_swap_free(slot, 1);
- p->pg_flags &= ~PG_CLEAN;
+ atomic_clearbits_int(&p->pg_flags,
+ PG_CLEAN);
swap_shortage--;
}
}
@@ -1105,7 +1110,7 @@ uvmpd_scan()
uvmexp.pddeact++;
inactive_shortage--;
}
- if (p->pqflags & PQ_ANON)
+ if (p->pg_flags & PQ_ANON)
simple_unlock(&p->uanon->an_lock);
else
simple_unlock(&p->uobject->vmobjlock);