summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_pdaemon.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-04-10 15:26:19 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-04-10 15:26:19 +0000
commit63ce2e4e1c9f4c35136d95d1c25d093095e7949a (patch)
treec41b69628b11b1579199048e03177e5d60fe4a8d /sys/uvm/uvm_pdaemon.c
parent458c88955506fc62ab1e3f85fa5c85d056731f6b (diff)
Use uvmpd_dropswap() in the case of swap shortage.
ok kn@, kettenis@, miod@
Diffstat (limited to 'sys/uvm/uvm_pdaemon.c')
-rw-r--r--sys/uvm/uvm_pdaemon.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 3b9af7814b7..58a47c37fb0 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.110 2024/03/24 10:29:35 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.111 2024/04/10 15:26:18 mpi Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -107,7 +107,7 @@ void uvmpd_scan_inactive(struct uvm_pmalloc *,
struct uvm_constraint_range *, struct pglist *);
void uvmpd_tune(void);
void uvmpd_drop(struct pglist *);
-void uvmpd_dropswap(struct vm_page *);
+int uvmpd_dropswap(struct vm_page *);
/*
* uvm_wait: wait (sleep) for the page daemon to free some pages
@@ -382,23 +382,29 @@ uvmpd_trylockowner(struct vm_page *pg)
return slock;
}
-
/*
* uvmpd_dropswap: free any swap allocated to this page.
*
* => called with owner locked.
+ * => return 1 if a page had an associated slot.
*/
-void
+int
uvmpd_dropswap(struct vm_page *pg)
{
struct vm_anon *anon = pg->uanon;
+ int slot, result = 0;
if ((pg->pg_flags & PQ_ANON) && anon->an_swslot) {
uvm_swap_free(anon->an_swslot, 1);
anon->an_swslot = 0;
+ result = 1;
} else if (pg->pg_flags & PQ_AOBJ) {
- uao_dropswap(pg->uobject, pg->offset >> PAGE_SHIFT);
+ slot = uao_dropswap(pg->uobject, pg->offset >> PAGE_SHIFT);
+ if (slot)
+ result = 1;
}
+
+ return result;
}
/*
@@ -941,22 +947,10 @@ uvmpd_scan(struct uvm_pmalloc *pma, struct uvm_constraint_range *constraint)
* to this page so that other pages can be paged out.
*/
if (swap_shortage > 0) {
- if ((p->pg_flags & PQ_ANON) && p->uanon->an_swslot) {
- uvm_swap_free(p->uanon->an_swslot, 1);
- p->uanon->an_swslot = 0;
+ if (uvmpd_dropswap(p)) {
atomic_clearbits_int(&p->pg_flags, PG_CLEAN);
swap_shortage--;
}
- 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);
- atomic_clearbits_int(&p->pg_flags,
- PG_CLEAN);
- swap_shortage--;
- }
- }
}
/*