From 5f319369a0864fe1d0aa3c8e38a0a4959a4ac2d1 Mon Sep 17 00:00:00 2001 From: para Date: Sat, 4 Feb 2012 17:56:16 +0000 Subject: [PATCH] improve sizing of kmem_arena now that more allocations are made from it don't enforce limits if not required ok: riz@ --- sys/arch/amd64/include/param.h | 7 ++++--- sys/arch/arm/include/arm32/param.h | 6 +++--- sys/arch/hppa/include/param.h | 4 ++-- sys/arch/i386/include/param.h | 4 ++-- sys/arch/sparc64/include/param.h | 9 +++++---- sys/uvm/uvm_km.c | 23 ++++++++++++++--------- 6 files changed, 30 insertions(+), 23 deletions(-) diff --git a/sys/arch/amd64/include/param.h b/sys/arch/amd64/include/param.h index ce51ac1f2f74..d46adf8c62df 100644 --- a/sys/arch/amd64/include/param.h +++ b/sys/arch/amd64/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.16 2012/01/24 20:03:36 christos Exp $ */ +/* $NetBSD: param.h,v 1.17 2012/02/04 17:56:16 para Exp $ */ #ifdef __x86_64__ @@ -81,11 +81,12 @@ #endif /* - * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized * logical pages. + * No enforced maximum on amd64. */ #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((1 *1024 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 /* * XXXfvdl the PD* stuff is different from i386. diff --git a/sys/arch/arm/include/arm32/param.h b/sys/arch/arm/include/arm32/param.h index b149c86d665e..e93314d52ac9 100644 --- a/sys/arch/arm/include/arm32/param.h +++ b/sys/arch/arm/include/arm32/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.16 2011/01/14 02:06:24 rmind Exp $ */ +/* $NetBSD: param.h,v 1.17 2012/02/04 17:56:16 para Exp $ */ /* * Copyright (c) 1994,1995 Mark Brinicombe. @@ -64,8 +64,8 @@ * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized * logical pages. */ -#define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((7 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) /* Constants used to divide the USPACE area */ diff --git a/sys/arch/hppa/include/param.h b/sys/arch/hppa/include/param.h index a67a3179599c..ba71a661bc3c 100644 --- a/sys/arch/hppa/include/param.h +++ b/sys/arch/hppa/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.17 2012/01/24 20:03:36 christos Exp $ */ +/* $NetBSD: param.h,v 1.18 2012/02/04 17:56:16 para Exp $ */ /* $OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $ */ @@ -83,7 +83,7 @@ * Size of kernel malloc arena in logical pages */ #define NKMEMPAGES_MIN_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((16 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) /* * Mach derived conversion macros diff --git a/sys/arch/i386/include/param.h b/sys/arch/i386/include/param.h index b439382f082c..774bda16fc2b 100644 --- a/sys/arch/i386/include/param.h +++ b/sys/arch/i386/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.74 2012/01/24 20:03:37 christos Exp $ */ +/* $NetBSD: param.h,v 1.75 2012/02/04 17:56:16 para Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -129,7 +129,7 @@ * logical pages. */ #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_DEFAULT ((280 * 1024 * 1024) >> PAGE_SHIFT) /* * Mach derived conversion macros diff --git a/sys/arch/sparc64/include/param.h b/sys/arch/sparc64/include/param.h index fc411b2f4bfc..79bf4d895ee2 100644 --- a/sys/arch/sparc64/include/param.h +++ b/sys/arch/sparc64/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.47 2012/01/24 20:03:38 christos Exp $ */ +/* $NetBSD: param.h,v 1.48 2012/02/04 17:56:16 para Exp $ */ /* * Copyright (c) 1992, 1993 @@ -193,11 +193,12 @@ extern int nbpg, pgofset, pgshift; #define MSGBUFSIZE NBPG /* - * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized + * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized * logical pages. + * No enforced maximum on sparc64. */ -#define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT) -#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MIN_DEFAULT ((64 * 1024 * 1024) >> PAGE_SHIFT) +#define NKMEMPAGES_MAX_UNLIMITED 1 #ifdef _KERNEL #ifndef _LOCORE diff --git a/sys/uvm/uvm_km.c b/sys/uvm/uvm_km.c index 4e4bc230368b..e2efa1e9d37d 100644 --- a/sys/uvm/uvm_km.c +++ b/sys/uvm/uvm_km.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_km.c,v 1.118 2012/02/03 19:25:07 matt Exp $ */ +/* $NetBSD: uvm_km.c,v 1.119 2012/02/04 17:56:17 para Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -120,7 +120,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.118 2012/02/03 19:25:07 matt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_km.c,v 1.119 2012/02/04 17:56:17 para Exp $"); #include "opt_uvmhist.h" @@ -189,10 +189,16 @@ kmeminit_nkmempages(void) return; } - npages = physmem; +#if defined(PMAP_MAP_POOLPAGE) + npages = (physmem / 4); +#else + npages = (physmem / 3) * 2; +#endif /* defined(PMAP_MAP_POOLPAGE) */ +#ifndef NKMEMPAGES_MAX_UNLIMITED if (npages > NKMEMPAGES_MAX) npages = NKMEMPAGES_MAX; +#endif if (npages < NKMEMPAGES_MIN) npages = NKMEMPAGES_MIN; @@ -212,6 +218,7 @@ kmeminit_nkmempages(void) void uvm_km_bootstrap(vaddr_t start, vaddr_t end) { + bool kmem_arena_small; vaddr_t base = VM_MIN_KERNEL_ADDRESS; struct uvm_map_args args; int error; @@ -221,11 +228,8 @@ uvm_km_bootstrap(vaddr_t start, vaddr_t end) start, end, 0,0); kmeminit_nkmempages(); - kmemsize = nkmempages * PAGE_SIZE; - - /* kmemsize = MIN((((vsize_t)(end - start)) / 3), - ((((vsize_t)uvmexp.npages) * PAGE_SIZE) / 2)); - kmemsize = round_page(kmemsize); */ + kmemsize = (vsize_t)nkmempages * PAGE_SIZE; + kmem_arena_small = kmemsize < 64 * 1024 * 1024; UVMHIST_LOG(maphist, "kmemsize=%#"PRIxVSIZE, kmemsize, 0,0,0); @@ -301,7 +305,8 @@ uvm_km_bootstrap(vaddr_t start, vaddr_t end) kmem_va_arena = vmem_create("kva", 0, 0, PAGE_SIZE, vmem_alloc, vmem_free, kmem_arena, - 16 * PAGE_SIZE, VM_NOSLEEP | VM_BOOTSTRAP, IPL_VM); + (kmem_arena_small ? 4 : 16) * PAGE_SIZE, + VM_NOSLEEP | VM_BOOTSTRAP, IPL_VM); UVMHIST_LOG(maphist, "<- done", 0,0,0,0); }