From: Matthew Dillon Date: Wed, 2 Nov 2011 06:44:37 +0000 (-0700) Subject: kernel - reformulate the maxusers auto-sizing calculation X-Git-Tag: v3.0.0~752 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/50eff0851a615fa611e714b1f8cd19f19ea6816b kernel - reformulate the maxusers auto-sizing calculation * Reformulate the maxusers auto-sizing calculation, which is used as a basis for mbufs and mbuf cluster calculations. Base the values on limsize (basically the lower of KVM vs physical memory). * Remove artificial limits. * This basically effects x86-64 systems with > 4G of ram, greatly increasing the default maxusers value and related mbuf limits. --- diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index f30cc924af..f7a062f5f8 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -144,31 +145,43 @@ init_param1(void) void init_param2(int physpages) { + size_t limsize; + + /* + * Calculate manually becaus the VM page queues / system is not set up yet + */ + limsize = (size_t)physpages * PAGE_SIZE; + if (limsize > KvaSize) + limsize = KvaSize; + limsize /= 1024 * 1024; /* smaller of KVM or physmem in MB */ /* Base parameters */ maxusers = MAXUSERS; TUNABLE_INT_FETCH("kern.maxusers", &maxusers); if (maxusers == 0) { - maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE); + maxusers = limsize / 8; /* ~384 per 3G */ if (maxusers < 32) - maxusers = 32; - if (maxusers > 384) - maxusers = 384; + maxusers = 32; + /* no upper limit */ } /* * The following can be overridden after boot via sysctl. Note: * unless overriden, these macros are ultimately based on maxusers. + * + * Limit maxproc so that kmap entries cannot be exhausted by + * processes. */ maxproc = NPROC; TUNABLE_INT_FETCH("kern.maxproc", &maxproc); + if (maxproc < 32) + maxproc = 32; + if (maxproc > limsize * 21) + maxproc = limsize * 21; /* - * Limit maxproc so that kmap entries cannot be exhausted by - * processes. + * Maximum number of open files */ - if (maxproc > (physpages / 12)) - maxproc = physpages / 12; maxfiles = MAXFILES; TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles); if (maxfiles < 128)