diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 00:11:00 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2011-07-08 00:11:00 +0000 |
commit | f77015ec3b4670f5fb71a497676fb45b62986107 (patch) | |
tree | 406e10cdf6ce14c459d34a9e661cf37e51796ddf /sys/uvm/uvm_page.c | |
parent | 5c5174914b126b16e16b71af1fbbccebc9b73074 (diff) |
some machines don't boot with the previous uvm reserve enforcement diff.
back it out.
Diffstat (limited to 'sys/uvm/uvm_page.c')
-rw-r--r-- | sys/uvm/uvm_page.c | 40 |
1 files changed, 34 insertions, 6 deletions
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); } /* |