summaryrefslogtreecommitdiffstats
path: root/sys/uvm/uvm_pmemrange.c
diff options
context:
space:
mode:
authorbeck <beck@openbsd.org>2019-05-09 20:36:44 +0000
committerbeck <beck@openbsd.org>2019-05-09 20:36:44 +0000
commitd4c6c9b57a2886f149c0c3fc366ab553f5c7721a (patch)
treea2900691486856d802afbe1fcee40c1f314fc924 /sys/uvm/uvm_pmemrange.c
parentUnlock adjfreq(2), adjtime(2), clock_settime(2), and settimeofday(2). (diff)
downloadwireguard-openbsd-d4c6c9b57a2886f149c0c3fc366ab553f5c7721a.tar.xz
wireguard-openbsd-d4c6c9b57a2886f149c0c3fc366ab553f5c7721a.zip
Ensure that pagedaemon wakeups as a result of failed UVM_PLA_NOWAIT
allocations will recover some memory from the dma_constraint range. The allocation still fails, the intent is to ensure that the pagedaemon will free some memory to possibly allow a subsequent allocation to succeed. This also adds a UVM_PLA_NOWAKE flag to allow special cases in the buffer cache to not wake up the pagedaemon until they want to. ok kettenis@
Diffstat (limited to 'sys/uvm/uvm_pmemrange.c')
-rw-r--r--sys/uvm/uvm_pmemrange.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c
index dcddfe35a14..cd92c319650 100644
--- a/sys/uvm/uvm_pmemrange.c
+++ b/sys/uvm/uvm_pmemrange.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pmemrange.c,v 1.53 2016/09/16 02:52:24 dlg Exp $ */
+/* $OpenBSD: uvm_pmemrange.c,v 1.54 2019/05/09 20:36:44 beck Exp $ */
/*
* Copyright (c) 2009, 2010 Ariane van der Steldt <ariane@stack.nl>
@@ -702,6 +702,13 @@ uvm_pmr_extract_range(struct uvm_pmemrange *pmr, struct vm_page *pg,
}
/*
+ * Indicate to the page daemon that a nowait call failed and it should
+ * recover at least some memory in the most restricted region (assumed
+ * to be dma_constraint).
+ */
+extern volatile int uvm_nowait_failed;
+
+/*
* Acquire a number of pages.
*
* count: the number of pages returned
@@ -1014,8 +1021,12 @@ fail:
flags & UVM_PLA_FAILOK) == 0)
goto retry;
KASSERT(flags & UVM_PLA_FAILOK);
- } else
- wakeup(&uvm.pagedaemon);
+ } else {
+ if (!(flags & UVM_PLA_NOWAKE)) {
+ uvm_nowait_failed = 1;
+ wakeup(&uvm.pagedaemon);
+ }
+ }
uvm_unlock_fpageq();
return ENOMEM;