summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 10:41:02 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 10:41:02 +0000
commitcaa500217d48dceb44aa45bade42ce5a04b12a8b (patch)
treec843bfeff78ec2274ba9d9b3bd76093a01ad6209 /sys/uvm
parenta636e52f9ba3df8b94877d7fc4c2d2ee6c95c015 (diff)
Optimize active & inactive list traversals when looking only for low pages.
- In the inactive list, if we are not OOM, do not bother releasing high pages. - In the active list, if we couldn't release enough low pages and are not out- of-swap, deactivate only low pages. ok miod@
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_pdaemon.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 6aedc5faa53..31162c6691f 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.126 2024/11/07 10:39:15 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.127 2024/11/07 10:41:01 mpi Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -514,6 +514,16 @@ uvmpd_scan_inactive(struct uvm_pmalloc *pma, int shortage)
uvmexp.pdscans++;
nextpg = TAILQ_NEXT(p, pageq);
+ /*
+ * If we are not short on memory and only interested
+ * in releasing pages from a given memory range do not
+ * bother with other pages.
+ */
+ if (uvmexp.paging >= (shortage - freed) &&
+ !uvmpd_pma_done(pma) &&
+ !uvmpd_match_constraint(p, &pma->pm_constraint))
+ continue;
+
anon = p->uanon;
uobj = p->uobject;
@@ -940,9 +950,15 @@ uvmpd_scan(struct uvm_pmalloc *pma, int shortage, int inactive_shortage)
}
/*
- * skip this page if it doesn't match the constraint.
+ * If we couldn't release enough pages from a given memory
+ * range try to deactivate them first...
+ *
+ * ...unless we are low on swap slots, in such case we are
+ * probably OOM and want to release swap resources as quickly
+ * as possible.
*/
- if (!uvmpd_pma_done(pma) &&
+ if (inactive_shortage > 0 && swap_shortage == 0 &&
+ !uvmpd_pma_done(pma) &&
!uvmpd_match_constraint(p, &pma->pm_constraint))
continue;