Module Name: src Committed By: ad Date: Sun Apr 25 15:54:14 UTC 2010
Modified Files: src/sys/uvm: uvm.h uvm_emap.c uvm_page.c Log Message: Reduce memory spent on bookkeeping for large values of MAXCPUS. To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/uvm/uvm.h cvs rdiff -u -r1.6 -r1.7 src/sys/uvm/uvm_emap.c cvs rdiff -u -r1.154 -r1.155 src/sys/uvm/uvm_page.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/uvm/uvm.h diff -u src/sys/uvm/uvm.h:1.57 src/sys/uvm/uvm.h:1.58 --- src/sys/uvm/uvm.h:1.57 Wed Oct 21 21:12:07 2009 +++ src/sys/uvm/uvm.h Sun Apr 25 15:54:14 2010 @@ -1,4 +1,30 @@ -/* $NetBSD: uvm.h,v 1.57 2009/10/21 21:12:07 rmind Exp $ */ +/* $NetBSD: uvm.h,v 1.58 2010/04/25 15:54:14 ad Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * 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. + */ /* * @@ -110,7 +136,7 @@ TAILQ_HEAD(, buf) aio_done; /* done async i/o reqs */ /* per-cpu data */ - struct uvm_cpu cpus[MAXCPUS]; + struct uvm_cpu *cpus[MAXCPUS]; }; /* Index: src/sys/uvm/uvm_emap.c diff -u src/sys/uvm/uvm_emap.c:1.6 src/sys/uvm/uvm_emap.c:1.7 --- src/sys/uvm/uvm_emap.c:1.6 Sat Nov 7 07:27:49 2009 +++ src/sys/uvm/uvm_emap.c Sun Apr 25 15:54:14 2010 @@ -1,7 +1,7 @@ -/* $NetBSD: uvm_emap.c,v 1.6 2009/11/07 07:27:49 cegger Exp $ */ +/* $NetBSD: uvm_emap.c,v 1.7 2010/04/25 15:54:14 ad Exp $ */ /*- - * Copyright (c) 2009 The NetBSD Foundation, Inc. + * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -46,11 +46,11 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_emap.c,v 1.6 2009/11/07 07:27:49 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_emap.c,v 1.7 2010/04/25 15:54:14 ad Exp $"); #include <sys/param.h> #include <sys/kernel.h> - +#include <sys/cpu.h> #include <sys/atomic.h> #include <sys/lwp.h> #include <sys/vmem.h> @@ -105,9 +105,11 @@ #endif /* Initial generation value is 1. */ uvm_emap_gen = 1; - for (i = 0; i < MAXCPUS; i++) { - ucpu = &uvm.cpus[i]; - ucpu->emap_gen = 1; + for (i = 0; i < maxcpus; i++) { + ucpu = uvm.cpus[i]; + if (ucpu != NULL) { + ucpu->emap_gen = 1; + } } } Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.154 src/sys/uvm/uvm_page.c:1.155 --- src/sys/uvm/uvm_page.c:1.154 Wed Feb 24 00:01:12 2010 +++ src/sys/uvm/uvm_page.c Sun Apr 25 15:54:14 2010 @@ -1,4 +1,30 @@ -/* $NetBSD: uvm_page.c,v 1.154 2010/02/24 00:01:12 jym Exp $ */ +/* $NetBSD: uvm_page.c,v 1.155 2010/04/25 15:54:14 ad Exp $ */ + +/* + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * 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. + */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -71,7 +97,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.154 2010/02/24 00:01:12 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.155 2010/04/25 15:54:14 ad Exp $"); #include "opt_ddb.h" #include "opt_uvmhist.h" @@ -105,11 +131,7 @@ /* * Some supported CPUs in a given architecture don't support all * of the things necessary to do idle page zero'ing efficiently. - * We therefore provide a way to disable it from machdep code here. - */ -/* - * XXX disabled until we can find a way to do this without causing - * problems for either CPU caches or DMA latency. + * We therefore provide a way to enable it from machdep code here. */ bool vm_page_zero_enable = false; @@ -339,6 +361,7 @@ void uvm_page_init(vaddr_t *kvm_startp, vaddr_t *kvm_endp) { + static struct uvm_cpu boot_cpu; psize_t freepages, pagecount, bucketcount, n; struct pgflbucket *bucketarray, *cpuarray; struct vm_page *pagearray; @@ -355,7 +378,8 @@ * structures). */ - curcpu()->ci_data.cpu_uvm = &uvm.cpus[0]; + uvm.cpus[0] = &boot_cpu; + curcpu()->ci_data.cpu_uvm = &boot_cpu; uvm_reclaim_init(); uvmpdpol_init(); mutex_init(&uvm_pageqlock, MUTEX_DRIVER, IPL_NONE); @@ -419,9 +443,9 @@ uvm.page_free[lcv].pgfl_buckets = (bucketarray + (lcv * uvmexp.ncolors)); uvm_page_init_buckets(&uvm.page_free[lcv]); - uvm.cpus[0].page_free[lcv].pgfl_buckets = + uvm.cpus[0]->page_free[lcv].pgfl_buckets = (cpuarray + (lcv * uvmexp.ncolors)); - uvm_page_init_buckets(&uvm.cpus[0].page_free[lcv]); + uvm_page_init_buckets(&uvm.cpus[0]->page_free[lcv]); } memset(pagearray, 0, pagecount * sizeof(struct vm_page)); @@ -481,7 +505,7 @@ * determine if we should zero pages in the idle loop. */ - uvm.cpus[0].page_idle_zero = vm_page_zero_enable; + uvm.cpus[0]->page_idle_zero = vm_page_zero_enable; /* * done! @@ -974,7 +998,8 @@ bucketcount = uvmexp.ncolors * VM_NFREELIST; bucketarray = malloc(bucketcount * sizeof(struct pgflbucket), M_VMPAGE, M_WAITOK); - ucpu = &uvm.cpus[cpu_index(ci)]; + ucpu = kmem_zalloc(sizeof(*ucpu), KM_SLEEP); + uvm.cpus[cpu_index(ci)] = ucpu; ci->ci_data.cpu_uvm = ucpu; for (lcv = 0; lcv < VM_NFREELIST; lcv++) { pgfl.pgfl_buckets = (bucketarray + (lcv * uvmexp.ncolors));