From 347194c172d683e5113490e06c7e18f04aced8c8 Mon Sep 17 00:00:00 2001 From: Mike Silbersack Date: Fri, 11 Jul 2003 00:01:03 +0000 Subject: [PATCH] Add init_param3() to subr_param. This function is called immediately after the kernel map has been sized, and is the optimal place for the autosizing of memory allocations which occur within the kernel map to occur. Suggested by: bde --- sys/kern/kern_malloc.c | 5 +++++ sys/kern/subr_param.c | 42 ++++++++++++++++-------------------------- sys/sys/systm.h | 1 + 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 2d8daa3103a..a90d628f77a 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -444,6 +444,11 @@ kmeminit(dummy) if (((vm_kmem_size / 2) / PAGE_SIZE) > cnt.v_page_count) vm_kmem_size = 2 * cnt.v_page_count * PAGE_SIZE; + /* + * Tune settings based on the kernel map's size at this time. + */ + init_param3(vm_kmem_size / PAGE_SIZE); + /* * In mbuf_init(), we set up submaps for mbufs and clusters, in which * case we rounddown() (nmbufs * MSIZE) and (nmbclusters * MCLBYTES), diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 427a94a9639..0482aa93542 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -135,23 +135,6 @@ void init_param2(long physpages) { - /* Kernel map size */ - int kmempages, kmemtunable; - kmempages = VM_KMEM_SIZE / PAGE_SIZE; -#if defined(VM_KMEM_SIZE_SCALE) - if ((physpages / VM_KMEM_SIZE_SCALE) > kmempages) - kmempages = (physpages / VM_KMEM_SIZE_SCALE); -#endif - -#if defined(VM_KMEM_SIZE_MAX) - if (kmempages * PAGE_SIZE >= VM_KMEM_SIZE_MAX) - kmempages = VM_KMEM_SIZE_MAX / PAGE_SIZE; -#endif - kmemtunable = 0; - TUNABLE_INT_FETCH("kern.vm.kmem.size", &kmemtunable); - if (kmemtunable != 0) - kmempages = kmemtunable / PAGE_SIZE; - kmempages = min(physpages, kmempages); /* Base parameters */ maxusers = MAXUSERS; TUNABLE_INT_FETCH("kern.maxusers", &maxusers); @@ -179,7 +162,23 @@ init_param2(long physpages) TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles); maxprocperuid = (maxproc * 9) / 10; maxfilesperproc = (maxfiles * 9) / 10; + + /* + * Cannot be changed after boot. + */ + nbuf = NBUF; + TUNABLE_INT_FETCH("kern.nbuf", &nbuf); + ncallout = 16 + maxproc + maxfiles; + TUNABLE_INT_FETCH("kern.ncallout", &ncallout); +} + +/* + * Boot time overrides that are scaled against the kernel map + */ +void +init_param3(long kmempages) +{ /* * Limit number of pipes to a reasonable fraction of kmap entries, * pageable pipe memory usage to 2.5% of the kernel map, and wired @@ -196,13 +195,4 @@ init_param2(long physpages) maxpipekva = 512 * 1024; if (maxpipekvawired < 512 * 1024) maxpipekvawired = 512 * 1024; - - /* - * Cannot be changed after boot. - */ - nbuf = NBUF; - TUNABLE_INT_FETCH("kern.nbuf", &nbuf); - - ncallout = 16 + maxproc + maxfiles; - TUNABLE_INT_FETCH("kern.ncallout", &ncallout); } diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 04d54cd15f4..0f7889f1602 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -147,6 +147,7 @@ void critical_enter(void); void critical_exit(void); void init_param1(void); void init_param2(long physpages); +void init_param3(long kmempages); void tablefull(const char *); int kvprintf(char const *, void (*)(int, void*), void *, int, __va_list) __printflike(1, 0);