summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-08-18 08:18:50 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-08-18 08:18:50 +0000
commitcd3632b65fdc242149e1a8dedbb89c23e1ae3434 (patch)
tree4f9b651463e8e91b26743e67bf15efa23cbf5df5 /sys/uvm
parent334085ca2f0201fd43bbdded1374f033485d527d (diff)
Do not cache pages belonging to memory ranges with a `use' count.
Such pages belong to the DMA or ISA memory ranges and caching them accelerate their exhaustion. On amd64, at least, the kernel relies on having low pages available at any time and cannot recover from their exhaustion. Should prevent livelocks reported by jsg@ and tb@ on amd64. ok deraadt@
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_pmemrange.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c
index 04abd46fe77..0830fd49875 100644
--- a/sys/uvm/uvm_pmemrange.c
+++ b/sys/uvm/uvm_pmemrange.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pmemrange.c,v 1.66 2024/05/01 12:54:27 mpi Exp $ */
+/* $OpenBSD: uvm_pmemrange.c,v 1.67 2024/08/18 08:18:49 mpi Exp $ */
/*
* Copyright (c) 2024 Martin Pieuchot <mpi@openbsd.org>
@@ -2303,8 +2303,19 @@ uvm_pmr_cache_put(struct vm_page *pg)
{
struct uvm_pmr_cache *upc = &curcpu()->ci_uvm;
struct uvm_pmr_cache_item *upci;
+ struct uvm_pmemrange *pmr;
int s;
+ /*
+ * Always give back low pages to the allocator to not accelerate
+ * their exhaustion.
+ */
+ pmr = uvm_pmemrange_find(atop(VM_PAGE_TO_PHYS(pg)));
+ if (pmr->use > 0) {
+ uvm_pmr_freepages(pg, 1);
+ return;
+ }
+
s = splvm();
upci = &upc->upc_magz[upc->upc_actv];
if (upci->upci_npages >= UVM_PMR_CACHEMAGSZ) {