From 0e5179e4414cf490f3a4c6bf13b453bcfbf793b2 Mon Sep 17 00:00:00 2001 From: "Stephane E. Potvin" Date: Sat, 21 Apr 2007 01:14:48 +0000 Subject: [PATCH] Add support for specifying a minimal size for vm.kmem_size in the loader via vm.kmem_size_min. Useful when using ZFS to make sure that vm.kmem size will be at least 256mb (for example) without forcing a particular value via vm.kmem_size. Approved by: njl (mentor) Reviewed by: alc --- sys/amd64/include/vmparam.h | 3 ++- sys/i386/include/vmparam.h | 3 ++- sys/ia64/include/vmparam.h | 3 ++- sys/kern/kern_malloc.c | 12 ++++++++++++ sys/sparc64/include/vmparam.h | 3 ++- sys/sun4v/include/vmparam.h | 3 ++- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 954cebc3d8b..47e111cc547 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -122,7 +122,8 @@ /* * How many physical pages per KVA page allocated. - * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), + * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h index 53c3f4548ea..042470ecf6b 100644 --- a/sys/i386/include/vmparam.h +++ b/sys/i386/include/vmparam.h @@ -117,7 +117,8 @@ /* * How many physical pages per KVA page allocated. - * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), + * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE diff --git a/sys/ia64/include/vmparam.h b/sys/ia64/include/vmparam.h index 06ae7c361a3..8beeb2ae05c 100644 --- a/sys/ia64/include/vmparam.h +++ b/sys/ia64/include/vmparam.h @@ -155,7 +155,8 @@ /* * How many physical pages per KVA page allocated. - * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), + * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index b05d13aa81f..19fbf30390f 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -178,6 +178,10 @@ u_int vm_kmem_size; SYSCTL_UINT(_vm, OID_AUTO, kmem_size, CTLFLAG_RD, &vm_kmem_size, 0, "Size of kernel memory"); +u_int vm_kmem_size_min; +SYSCTL_UINT(_vm, OID_AUTO, kmem_size_min, CTLFLAG_RD, &vm_kmem_size_min, 0, + "Minimum size of kernel memory"); + u_int vm_kmem_size_max; SYSCTL_UINT(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RD, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); @@ -557,6 +561,14 @@ kmeminit(void *dummy) (mem_size / vm_kmem_size_scale) > (vm_kmem_size / PAGE_SIZE)) vm_kmem_size = (mem_size / vm_kmem_size_scale) * PAGE_SIZE; +#if defined(VM_KMEM_SIZE_MIN) + vm_kmem_size_min = VM_KMEM_SIZE_MIN; +#endif + TUNABLE_INT_FETCH("vm.kmem_size_min", &vm_kmem_size_min); + if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) { + vm_kmem_size = vm_kmem_size_min; + } + #if defined(VM_KMEM_SIZE_MAX) vm_kmem_size_max = VM_KMEM_SIZE_MAX; #endif diff --git a/sys/sparc64/include/vmparam.h b/sys/sparc64/include/vmparam.h index de4112b13d7..99a9527a33a 100644 --- a/sys/sparc64/include/vmparam.h +++ b/sys/sparc64/include/vmparam.h @@ -163,7 +163,8 @@ /* * How many physical pages per KVA page allocated. - * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), + * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE diff --git a/sys/sun4v/include/vmparam.h b/sys/sun4v/include/vmparam.h index 1ee39bc2b26..3b87beace82 100644 --- a/sys/sun4v/include/vmparam.h +++ b/sys/sun4v/include/vmparam.h @@ -163,7 +163,8 @@ /* * How many physical pages per KVA page allocated. - * min(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), VM_KMEM_SIZE_MAX) + * min(max(max(VM_KMEM_SIZE, Physical memory/VM_KMEM_SIZE_SCALE), + * VM_KMEM_SIZE_MIN), VM_KMEM_SIZE_MAX) * is the total KVA space allocated for kmem_map. */ #ifndef VM_KMEM_SIZE_SCALE