-/* $OpenBSD: uvm_pdaemon.c,v 1.88 2020/11/24 13:49:09 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.89 2021/03/01 09:13:33 mpi Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
if (p->pg_flags & PQ_ANON) {
anon = p->uanon;
KASSERT(anon != NULL);
+ if (rw_enter(anon->an_lock,
+ RW_WRITE|RW_NOSLEEP)) {
+ /* lock failed, skip this page */
+ continue;
+ }
if (p->pg_flags & PG_BUSY) {
+ rw_exit(anon->an_lock);
uvmexp.pdbusy++;
/* someone else owns page, skip it */
continue;
/* remove from object */
anon->an_page = NULL;
+ rw_exit(anon->an_lock);
}
continue;
}
* free target when all the current pageouts complete.
*/
if (free + uvmexp.paging > uvmexp.freetarg << 2) {
+ if (anon) {
+ rw_exit(anon->an_lock);
+ }
continue;
}
if ((p->pg_flags & PQ_SWAPBACKED) && uvm_swapisfull()) {
dirtyreacts++;
uvm_pageactivate(p);
+ if (anon) {
+ rw_exit(anon->an_lock);
+ }
continue;
}
&p->pg_flags,
PG_BUSY);
UVM_PAGE_OWN(p, NULL);
+ if (anon)
+ rw_exit(anon->an_lock);
continue;
}
swcpages = 0; /* cluster is empty */
*/
if (swap_backed) {
if (p) { /* if we just added a page to cluster */
+ if (anon)
+ rw_exit(anon->an_lock);
+
/* cluster not full yet? */
if (swcpages < swnpages)
continue;
/* relock p's object: page queues not lock yet, so
* no need for "try" */
+ /* !swap_backed case: already locked... */
+ if (swap_backed) {
+ if (anon)
+ rw_enter(anon->an_lock, RW_WRITE);
+ }
+
#ifdef DIAGNOSTIC
if (result == VM_PAGER_UNLOCK)
panic("pagedaemon: pageout returned "
anon->an_page = NULL;
p->uanon = NULL;
+ rw_exit(anon->an_lock);
uvm_anfree(anon); /* kills anon */
pmap_page_protect(p, PROT_NONE);
anon = NULL;
* the inactive queue can't be re-queued [note: not
* true for active queue]).
*/
+ if (anon)
+ rw_exit(anon->an_lock);
if (nextpg && (nextpg->pg_flags & PQ_INACTIVE) == 0) {
nextpg = TAILQ_FIRST(pglst); /* reload! */
if (p->pg_flags & PG_BUSY)
continue;
- if (p->pg_flags & PQ_ANON)
+ if (p->pg_flags & PQ_ANON) {
KASSERT(p->uanon != NULL);
- else
+ if (rw_enter(p->uanon->an_lock, RW_WRITE|RW_NOSLEEP))
+ continue;
+ } else
KASSERT(p->uobject != NULL);
/*
uvmexp.pddeact++;
inactive_shortage--;
}
+ if (p->pg_flags & PQ_ANON)
+ rw_exit(p->uanon->an_lock);
}
}