summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2011-07-08 00:11:00 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2011-07-08 00:11:00 +0000
commitf77015ec3b4670f5fb71a497676fb45b62986107 (patch)
tree406e10cdf6ce14c459d34a9e661cf37e51796ddf /sys
parent5c5174914b126b16e16b71af1fbbccebc9b73074 (diff)
some machines don't boot with the previous uvm reserve enforcement diff.
back it out.
Diffstat (limited to 'sys')
-rw-r--r--sys/uvm/uvm_extern.h3
-rw-r--r--sys/uvm/uvm_page.c40
-rw-r--r--sys/uvm/uvm_pmemrange.c38
3 files changed, 36 insertions, 45 deletions
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h
index 72a9125340d..201abdb923a 100644
--- a/sys/uvm/uvm_extern.h
+++ b/sys/uvm/uvm_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_extern.h,v 1.102 2011/07/07 20:52:50 oga Exp $ */
+/* $OpenBSD: uvm_extern.h,v 1.103 2011/07/08 00:10:59 tedu Exp $ */
/* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */
/*
@@ -222,7 +222,6 @@ typedef int vm_prot_t;
#define UVM_PLA_ZERO 0x0004 /* zero all pages before returning */
#define UVM_PLA_TRYCONTIG 0x0008 /* try to allocate contig physmem */
#define UVM_PLA_FAILOK 0x0010 /* caller can handle failure */
-#define UVM_PLA_USERESERVE 0x0020 /* ok to use reserve pages */
/*
* lockflags that control the locking behavior of various functions.
diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c
index 318a0e52734..6d44a95b6aa 100644
--- a/sys/uvm/uvm_page.c
+++ b/sys/uvm/uvm_page.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_page.c,v 1.113 2011/07/07 20:52:50 oga Exp $ */
+/* $OpenBSD: uvm_page.c,v 1.114 2011/07/08 00:10:59 tedu Exp $ */
/* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */
/*
@@ -76,6 +76,7 @@
#include <sys/sched.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
+#include <sys/mount.h>
#include <sys/proc.h>
#include <uvm/uvm.h>
@@ -919,19 +920,43 @@ uvm_pagealloc(struct uvm_object *obj, voff_t off, struct vm_anon *anon,
struct vm_page *pg;
struct pglist pgl;
int pmr_flags;
+ boolean_t use_reserve;
KASSERT(obj == NULL || anon == NULL);
KASSERT(off == trunc_page(off));
- /* XXX these functions should share flags */
+ /*
+ * check to see if we need to generate some free pages waking
+ * the pagedaemon.
+ */
+ if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freemin ||
+ ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg &&
+ (uvmexp.inactive + BUFPAGES_INACT) < uvmexp.inactarg))
+ wakeup(&uvm.pagedaemon);
+
+ /*
+ * fail if any of these conditions is true:
+ * [1] there really are no free pages, or
+ * [2] only kernel "reserved" pages remain and
+ * the page isn't being allocated to a kernel object.
+ * [3] only pagedaemon "reserved" pages remain and
+ * the requestor isn't the pagedaemon.
+ */
+
+ use_reserve = (flags & UVM_PGA_USERESERVE) ||
+ (obj && UVM_OBJ_IS_KERN_OBJECT(obj));
+ if ((uvmexp.free <= uvmexp.reserve_kernel && !use_reserve) ||
+ (uvmexp.free <= uvmexp.reserve_pagedaemon &&
+ !((curproc == uvm.pagedaemon_proc) ||
+ (curproc == syncerproc))))
+ goto fail;
+
pmr_flags = UVM_PLA_NOWAIT;
if (flags & UVM_PGA_ZERO)
pmr_flags |= UVM_PLA_ZERO;
- if (flags & UVM_PGA_USERESERVE)
- pmr_flags |= UVM_PLA_USERESERVE;
TAILQ_INIT(&pgl);
if (uvm_pmr_getpages(1, 0, 0, 1, 0, 1, pmr_flags, &pgl) != 0)
- return (NULL);
+ goto fail;
pg = TAILQ_FIRST(&pgl);
KASSERT(pg != NULL && TAILQ_NEXT(pg, pageq) == NULL);
@@ -942,7 +967,10 @@ uvm_pagealloc(struct uvm_object *obj, voff_t off, struct vm_anon *anon,
if (flags & UVM_PGA_ZERO)
atomic_clearbits_int(&pg->pg_flags, PG_CLEAN);
- return (pg);
+ return(pg);
+
+ fail:
+ return (NULL);
}
/*
diff --git a/sys/uvm/uvm_pmemrange.c b/sys/uvm/uvm_pmemrange.c
index 20b68bd8152..a58f4fe8835 100644
--- a/sys/uvm/uvm_pmemrange.c
+++ b/sys/uvm/uvm_pmemrange.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_pmemrange.c,v 1.28 2011/07/07 20:52:50 oga Exp $ */
+/* $OpenBSD: uvm_pmemrange.c,v 1.29 2011/07/08 00:10:59 tedu Exp $ */
/*
* Copyright (c) 2009, 2010 Ariane van der Steldt <ariane@stack.nl>
@@ -20,7 +20,6 @@
#include <sys/systm.h>
#include <uvm/uvm.h>
#include <sys/malloc.h>
-#include <sys/mount.h> /* for BUFPAGES defines */
#include <sys/proc.h> /* XXX for atomic */
#include <sys/kernel.h>
@@ -748,7 +747,6 @@ uvm_pmr_getpages(psize_t count, paddr_t start, paddr_t end, paddr_t align,
int memtype; /* Requested memtype. */
int memtype_init; /* Best memtype. */
int desperate; /* True if allocation failed. */
- int is_pdaemon;
#ifdef DIAGNOSTIC
struct vm_page *diag_prev; /* Used during validation. */
#endif /* DIAGNOSTIC */
@@ -764,26 +762,6 @@ uvm_pmr_getpages(psize_t count, paddr_t start, paddr_t end, paddr_t align,
(boundary == 0 || maxseg * boundary >= count) &&
TAILQ_EMPTY(result));
- is_pdaemon = ((curproc == uvm.pagedaemon_proc) ||
- (curproc == syncerproc));
-
- /*
- * All allocations by the pagedaemon automatically get access to
- * the kernel reserve of pages so swapping can catch up with memory
- * exhaustion
- */
- if (is_pdaemon)
- flags |= UVM_PLA_USERESERVE;
-
- /*
- * check to see if we need to generate some free pages waking
- * the pagedaemon.
- */
- if ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freemin ||
- ((uvmexp.free - BUFPAGES_DEFICIT) < uvmexp.freetarg &&
- (uvmexp.inactive + BUFPAGES_INACT) < uvmexp.inactarg))
- wakeup(&uvm.pagedaemon);
-
/*
* TRYCONTIG is a noop if you only want a single segment.
* Remove it if that's the case: otherwise it'll deny the fast
@@ -858,20 +836,6 @@ retry: /* Return point after sleeping. */
fcount = 0;
fnsegs = 0;
- /*
- * fail if any of these conditions are true:
- * [1] there really are no free pages, or
- * [2] only kernel "reserved" pages remain and
- * the we are not allowed to use them.
- * [3] only pagedaemon "reserved" pages remain and
- * the requestor isn't the pagedaemon.
- */
- if (((uvmexp.free < uvmexp.reserve_kernel + ptoa(count)) &&
- (flags & UVM_PLA_USERESERVE) == 0) ||
- ((uvmexp.free < uvmexp.reserve_pagedaemon + ptoa(count)) &&
- !is_pdaemon))
- goto fail;
-
retry_desperate:
/*
* If we just want any page(s), go for the really fast option.