summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 10:42:27 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 10:42:27 +0000
commit923e1f5864b0f3b5e9638738df7f46a2f09618b3 (patch)
tree3b7750e8494908d112026df9ac54b5acaad15c85 /sys/uvm
parentcaa500217d48dceb44aa45bade42ce5a04b12a8b (diff)
Do not try to release memory if all we need is balancing the page lists.
ok miod@
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_pdaemon.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/sys/uvm/uvm_pdaemon.c b/sys/uvm/uvm_pdaemon.c
index 31162c6691f..3b64f72b23a 100644
--- a/sys/uvm/uvm_pdaemon.c
+++ b/sys/uvm/uvm_pdaemon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pdaemon.c,v 1.127 2024/11/07 10:41:01 mpi Exp $ */
+/* $OpenBSD: uvm_pdaemon.c,v 1.128 2024/11/07 10:42:26 mpi Exp $ */
/* $NetBSD: uvm_pdaemon.c,v 1.23 2000/08/20 10:24:14 bjh21 Exp $ */
/*
@@ -104,6 +104,7 @@ extern unsigned long drmbackoff(long);
struct rwlock *uvmpd_trylockowner(struct vm_page *);
void uvmpd_scan(struct uvm_pmalloc *, int, int);
int uvmpd_scan_inactive(struct uvm_pmalloc *, int);
+void uvmpd_scan_active(struct uvm_pmalloc *, int, int);
void uvmpd_tune(void);
void uvmpd_drop(struct pglist *);
int uvmpd_dropswap(struct vm_page *);
@@ -259,15 +260,27 @@ uvm_pageout(void *arg)
uvmexp.inactarg - uvmexp.inactive - BUFPAGES_INACT;
uvm_unlock_pageq();
- /* Reclaim pages from the buffer cache if possible. */
size = 0;
if (pma != NULL)
size += pma->pm_size >> PAGE_SHIFT;
if (shortage > 0)
size += shortage;
- if (size == 0)
- size = 16; /* XXX */
+ if (size == 0) {
+ /*
+ * Since the inactive target just got updated
+ * above both `size' and `inactive_shortage' can
+ * be 0.
+ */
+ if (inactive_shortage) {
+ uvm_lock_pageq();
+ uvmpd_scan_active(NULL, 0, inactive_shortage);
+ uvm_unlock_pageq();
+ }
+ continue;
+ }
+
+ /* Reclaim pages from the buffer cache if possible. */
shortage -= bufbackoff(&constraint, size * 2);
#if NDRM > 0
shortage -= drmbackoff(size * 2);
@@ -897,8 +910,6 @@ void
uvmpd_scan(struct uvm_pmalloc *pma, int shortage, int inactive_shortage)
{
int swap_shortage, pages_freed;
- struct vm_page *p, *nextpg;
- struct rwlock *slock;
MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
@@ -941,6 +952,18 @@ uvmpd_scan(struct uvm_pmalloc *pma, int shortage, int inactive_shortage)
swap_shortage = shortage;
}
+ uvmpd_scan_active(pma, swap_shortage, inactive_shortage);
+}
+
+void
+uvmpd_scan_active(struct uvm_pmalloc *pma, int swap_shortage,
+ int inactive_shortage)
+{
+ struct vm_page *p, *nextpg;
+ struct rwlock *slock;
+
+ MUTEX_ASSERT_LOCKED(&uvm.pageqlock);
+
for (p = TAILQ_FIRST(&uvm.page_active);
p != NULL && (inactive_shortage > 0 || swap_shortage > 0);
p = nextpg) {