diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-04-20 00:30:19 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-04-20 00:30:19 +0000 |
commit | 7720807a1d9f91f5c0f47d6b1be219d913aef6ac (patch) | |
tree | d3c35c0fc9830b368b96d5356751a972cd2ad0d8 /sys | |
parent | 170f6c5d952842275deb05d0ec25ff27f3e4c339 (diff) |
add the UVM_PLA_ZERO flag for uvm_pglistalloc to make it return zeroed
pages.
"go for it" miod@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/uvm/uvm_extern.h | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_pglist.c | 21 |
2 files changed, 18 insertions, 6 deletions
diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index 95cd3fa3fe2..5ff1e2ddad2 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.75 2009/04/14 16:01:04 oga Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.76 2009/04/20 00:30:18 oga Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -225,6 +225,7 @@ typedef int vm_prot_t; */ #define UVM_PLA_WAITOK 0x0001 /* may sleep */ #define UVM_PLA_NOWAIT 0x0002 /* can't sleep (need one of the two) */ +#define UVM_PLA_ZERO 0x0004 /* zero all pages before returning */ /* * lockflags that control the locking behavior of various functions. diff --git a/sys/uvm/uvm_pglist.c b/sys/uvm/uvm_pglist.c index b1b4286a243..2e695b7c6ad 100644 --- a/sys/uvm/uvm_pglist.c +++ b/sys/uvm/uvm_pglist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pglist.c,v 1.26 2009/04/14 16:01:04 oga Exp $ */ +/* $OpenBSD: uvm_pglist.c,v 1.27 2009/04/20 00:30:18 oga Exp $ */ /* $NetBSD: uvm_pglist.c,v 1.13 2001/02/18 21:19:08 chs Exp $ */ /*- @@ -129,7 +129,6 @@ uvm_pglistalloc_simple(psize_t size, paddr_t low, paddr_t high, uvmexp.free--; if (pg->pg_flags & PG_ZERO) uvmexp.zeropages--; - pg->pg_flags = PG_CLEAN; pg->uobject = NULL; pg->uanon = NULL; pg->pg_version++; @@ -225,8 +224,10 @@ uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, * no need to be smart. */ if ((nsegs >= size / PAGE_SIZE) && (alignment == PAGE_SIZE) && - (boundary == 0)) - return (uvm_pglistalloc_simple(size, low, high, rlist)); + (boundary == 0)) { + error = uvm_pglistalloc_simple(size, low, high, rlist); + goto done; + } if (boundary != 0 && boundary < size) return (EINVAL); @@ -339,7 +340,6 @@ found: uvmexp.free--; if (m->pg_flags & PG_ZERO) uvmexp.zeropages--; - m->pg_flags = PG_CLEAN; m->uobject = NULL; m->uanon = NULL; m->pg_version++; @@ -363,6 +363,17 @@ out: uvm_unlock_fpageq(); +done: + /* No locking needed here, pages are not on any queue. */ + if (error == 0) { + TAILQ_FOREACH(m, rlist, pageq) { + if (flags & UVM_PLA_ZERO && + (m->pg_flags & PG_ZERO) == 0) + uvm_pagezero(m); + m->pg_flags = PG_CLEAN; + } + } + return (error); } |