diff options
author | 2011-06-23 21:50:26 +0000 | |
---|---|---|
committer | 2011-06-23 21:50:26 +0000 | |
commit | 23c8646307de4843d24909cf96fe99b91b14b52f (patch) | |
tree | e13863b62abe7b97df2ce2397e05fbdc65a0166f | |
parent | Make mbufs and dma_alloc be contig allocations. (diff) | |
download | wireguard-openbsd-23c8646307de4843d24909cf96fe99b91b14b52f.tar.xz wireguard-openbsd-23c8646307de4843d24909cf96fe99b91b14b52f.zip |
Move uvm_pglistalloc and uvm_pglistfree to uvm_page.c and garbage
college uvm_pglist.c
uvm_pglistalloc and free are just thin wrappers around pmemrange these
days and don't really need their own file.
ok ariane@
-rw-r--r-- | sys/conf/files | 3 | ||||
-rw-r--r-- | sys/uvm/uvm_page.c | 77 | ||||
-rw-r--r-- | sys/uvm/uvm_pglist.c | 136 |
3 files changed, 77 insertions, 139 deletions
diff --git a/sys/conf/files b/sys/conf/files index d34cfd060da..6f0192d4d7c 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,4 +1,4 @@ -# $OpenBSD: files,v 1.513 2011/06/23 17:06:07 matthew Exp $ +# $OpenBSD: files,v 1.514 2011/06/23 21:50:26 oga Exp $ # $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $ # @(#)files.newconf 7.5 (Berkeley) 5/10/93 @@ -1007,7 +1007,6 @@ file uvm/uvm_object.c file uvm/uvm_page.c file uvm/uvm_pager.c file uvm/uvm_pdaemon.c -file uvm/uvm_pglist.c file uvm/uvm_pmemrange.c file uvm/uvm_stat.c file uvm/uvm_swap.c diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 9f716e4d66f..bbde5286a1c 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.108 2011/05/30 22:25:24 oga Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.109 2011/06/23 21:50:26 oga Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -784,6 +784,81 @@ uvm_pagealloc_pg(struct vm_page *pg, struct uvm_object *obj, voff_t off, } /* + * uvm_pglistalloc: allocate a list of pages + * + * => allocated pages are placed at the tail of rlist. rlist is + * assumed to be properly initialized by caller. + * => returns 0 on success or errno on failure + * => doesn't take into account clean non-busy pages on inactive list + * that could be used(?) + * => params: + * size the size of the allocation, rounded to page size. + * low the low address of the allowed allocation range. + * high the high address of the allowed allocation range. + * alignment memory must be aligned to this power-of-two boundary. + * boundary no segment in the allocation may cross this + * power-of-two boundary (relative to zero). + * => flags: + * UVM_PLA_NOWAIT fail if allocation fails + * UVM_PLA_WAITOK wait for memory to become avail + * UVM_PLA_ZERO return zeroed memory + */ +int +uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, + paddr_t boundary, struct pglist *rlist, int nsegs, int flags) +{ + UVMHIST_FUNC("uvm_pglistalloc"); UVMHIST_CALLED(pghist); + + KASSERT((alignment & (alignment - 1)) == 0); + KASSERT((boundary & (boundary - 1)) == 0); + KASSERT(!(flags & UVM_PLA_WAITOK) ^ !(flags & UVM_PLA_NOWAIT)); + + if (size == 0) + return (EINVAL); + + if ((high & PAGE_MASK) != PAGE_MASK) { + printf("uvm_pglistalloc: Upper boundary 0x%lx " + "not on pagemask.\n", (unsigned long)high); + } + + /* + * Our allocations are always page granularity, so our alignment + * must be, too. + */ + if (alignment < PAGE_SIZE) + alignment = PAGE_SIZE; + + low = atop(roundup(low, alignment)); + /* + * high + 1 may result in overflow, in which case high becomes 0x0, + * which is the 'don't care' value. + * The only requirement in that case is that low is also 0x0, or the + * low<high assert will fail. + */ + high = atop(high + 1); + size = atop(round_page(size)); + alignment = atop(alignment); + if (boundary < PAGE_SIZE && boundary != 0) + boundary = PAGE_SIZE; + boundary = atop(boundary); + + return uvm_pmr_getpages(size, low, high, alignment, boundary, nsegs, + flags, rlist); +} + +/* + * uvm_pglistfree: free a list of pages + * + * => pages should already be unmapped + */ +void +uvm_pglistfree(struct pglist *list) +{ + UVMHIST_FUNC("uvm_pglistfree"); UVMHIST_CALLED(pghist); + uvm_pmr_freepageq(list); +} + +/* * interface used by the buffer cache to allocate a buffer at a time. * The pages are allocated wired in DMA accessible memory */ diff --git a/sys/uvm/uvm_pglist.c b/sys/uvm/uvm_pglist.c deleted file mode 100644 index 17fd8751bec..00000000000 --- a/sys/uvm/uvm_pglist.c +++ /dev/null @@ -1,136 +0,0 @@ -/* $OpenBSD: uvm_pglist.c,v 1.38 2010/06/27 03:03:49 thib Exp $ */ -/* $NetBSD: uvm_pglist.c,v 1.13 2001/02/18 21:19:08 chs Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * uvm_pglist.c: pglist functions - */ - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/malloc.h> -#include <sys/proc.h> - -#include <uvm/uvm.h> - -#ifdef VM_PAGE_ALLOC_MEMORY_STATS -#define STAT_INCR(v) (v)++ -#define STAT_DECR(v) do { \ - if ((v) == 0) \ - printf("%s:%d -- Already 0!\n", __FILE__, __LINE__); \ - else \ - (v)--; \ - } while (0) -u_long uvm_pglistalloc_npages; -#else -#define STAT_INCR(v) -#define STAT_DECR(v) -#endif - -/* - * uvm_pglistalloc: allocate a list of pages - * - * => allocated pages are placed at the tail of rlist. rlist is - * assumed to be properly initialized by caller. - * => returns 0 on success or errno on failure - * => XXX: implementation allocates only a single segment, also - * might be able to better advantage of vm_physeg[]. - * => doesn't take into account clean non-busy pages on inactive list - * that could be used(?) - * => params: - * size the size of the allocation, rounded to page size. - * low the low address of the allowed allocation range. - * high the high address of the allowed allocation range. - * alignment memory must be aligned to this power-of-two boundary. - * boundary no segment in the allocation may cross this - * power-of-two boundary (relative to zero). - * => flags: - * UVM_PLA_NOWAIT fail if allocation fails - * UVM_PLA_WAITOK wait for memory to become avail - * UVM_PLA_ZERO return zeroed memory - */ - -int -uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, - paddr_t boundary, struct pglist *rlist, int nsegs, int flags) -{ - UVMHIST_FUNC("uvm_pglistalloc"); UVMHIST_CALLED(pghist); - - KASSERT((alignment & (alignment - 1)) == 0); - KASSERT((boundary & (boundary - 1)) == 0); - KASSERT(!(flags & UVM_PLA_WAITOK) ^ !(flags & UVM_PLA_NOWAIT)); - - if (size == 0) - return (EINVAL); - - if ((high & PAGE_MASK) != PAGE_MASK) { - printf("uvm_pglistalloc: Upper boundary 0x%lx " - "not on pagemask.\n", (unsigned long)high); - } - - /* - * Our allocations are always page granularity, so our alignment - * must be, too. - */ - if (alignment < PAGE_SIZE) - alignment = PAGE_SIZE; - - low = atop(roundup(low, alignment)); - /* - * high + 1 may result in overflow, in which case high becomes 0x0, - * which is the 'don't care' value. - * The only requirement in that case is that low is also 0x0, or the - * low<high assert will fail. - */ - high = atop(high + 1); - size = atop(round_page(size)); - alignment = atop(alignment); - if (boundary < PAGE_SIZE && boundary != 0) - boundary = PAGE_SIZE; - boundary = atop(boundary); - - return uvm_pmr_getpages(size, low, high, alignment, boundary, nsegs, - flags, rlist); -} - -/* - * uvm_pglistfree: free a list of pages - * - * => pages should already be unmapped - */ - -void -uvm_pglistfree(struct pglist *list) -{ - UVMHIST_FUNC("uvm_pglistfree"); UVMHIST_CALLED(pghist); - uvm_pmr_freepageq(list); -} |