Allow maxusers to be specified as 0 in the kernel config, which will

cause the system to auto-size to between 32 and 512 depending on the
amount of memory.

MFC after:	1 week
This commit is contained in:
Matthew Dillon 2001-12-09 01:57:09 +00:00
parent c03b8e5e60
commit 66a11b9fb1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=87546
21 changed files with 74 additions and 39 deletions

View File

@ -556,7 +556,7 @@ alpha_init(pfn, ptb, bim, bip, biv)
kern_envp = bootinfo.envp;
/* Do basic tuning, hz etc */
init_param();
init_param1();
/*
* Initalize the (temporary) bootstrap console interface, so
@ -861,6 +861,7 @@ alpha_init(pfn, ptb, bim, bip, biv)
physmem -= (sz - nsz);
}
}
init_param2(physmem);
/*
* Initialize error message buffer (at end of core).

View File

@ -25,7 +25,7 @@ machine alpha
cpu EV4
cpu EV5
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints"

View File

@ -25,7 +25,7 @@ machine alpha
cpu EV4
cpu EV5
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints"

View File

@ -1692,7 +1692,7 @@ init386(first)
kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
/* Init basic tunables, hz etc */
init_param();
init_param1();
/*
* make gdt memory segments, the code segment goes up to end of the
@ -1869,6 +1869,7 @@ init386(first)
vm86_initialize();
getmemsize(first);
init_param2(physmem);
/* now running on new page tables, configured,and u/iom is accessible */

View File

@ -22,7 +22,7 @@ cpu I486_CPU
cpu I586_CPU
cpu I686_CPU
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints" #Default places to look for devices.

View File

@ -22,7 +22,7 @@ cpu I486_CPU
cpu I586_CPU
cpu I686_CPU
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints" #Default places to look for devices.

View File

@ -26,7 +26,7 @@ cpu I486_CPU
cpu I586_CPU
cpu I686_CPU
ident NEWCARD
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "NEWCARD.hints" #Default places to look for devices.

View File

@ -1692,7 +1692,7 @@ init386(first)
kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
/* Init basic tunables, hz etc */
init_param();
init_param1();
/*
* make gdt memory segments, the code segment goes up to end of the
@ -1869,6 +1869,7 @@ init386(first)
vm86_initialize();
getmemsize(first);
init_param2(physmem);
/* now running on new page tables, configured,and u/iom is accessible */

View File

@ -24,7 +24,7 @@
machine ia64
cpu ITANIUM
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints"

View File

@ -523,7 +523,7 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
fpswa_interface = (FPSWA_INTERFACE*)IA64_PHYS_TO_RR7(bootinfo.bi_fpswa);
/* Init basic tunables, including hz */
init_param();
init_param1();
p = getenv("kernelname");
if (p)
@ -623,6 +623,7 @@ ia64_init(u_int64_t arg1, u_int64_t arg2)
phys_avail[phys_avail_cnt] = 0;
Maxmem = physmem;
init_param2(physmem);
/*
* Initialize error message buffer (at end of core).

View File

@ -91,31 +91,17 @@ u_quad_t sgrowsiz; /* amount to grow stack */
struct buf *swbuf;
/*
* Boot time overrides
* Boot time overrides that are not scaled against main memory
*/
void
init_param(void)
init_param1(void)
{
/* Base parameters */
maxusers = MAXUSERS;
TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
hz = HZ;
TUNABLE_INT_FETCH("kern.hz", &hz);
tick = 1000000 / hz;
tickadj = howmany(30000, 60 * hz); /* can adjust 30ms in 60s */
/* The following can be overridden after boot via sysctl */
maxproc = NPROC;
TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
maxfiles = MAXFILES;
TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
maxprocperuid = maxproc - 1;
maxfilesperproc = maxfiles;
/* Cannot be changed after boot */
nbuf = NBUF;
TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
#ifdef VM_SWZONE_SIZE_MAX
maxswzone = VM_SWZONE_SIZE_MAX;
#endif
@ -124,8 +110,6 @@ init_param(void)
maxbcache = VM_BCACHE_SIZE_MAX;
#endif
TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache);
ncallout = 16 + maxproc + maxfiles;
TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
maxtsiz = MAXTSIZ;
TUNABLE_QUAD_FETCH("kern.maxtsiz", &maxtsiz);
@ -140,3 +124,41 @@ init_param(void)
sgrowsiz = SGROWSIZ;
TUNABLE_QUAD_FETCH("kern.sgrowsiz", &sgrowsiz);
}
/*
* Boot time overrides that are scaled against main memory
*/
void
init_param2(int physpages)
{
/* Base parameters */
if ((maxusers = MAXUSERS) == 0) {
maxusers = physpages / (1024 * 1024 / PAGE_SIZE);
if (maxusers < 32)
maxusers = 32;
if (maxusers > 512)
maxusers = 512;
}
TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
/*
* The following can be overridden after boot via sysctl. Note:
* unless overriden, these macros are ultimately based on maxusers.
*/
maxproc = NPROC;
TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
maxfiles = MAXFILES;
TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
maxprocperuid = maxproc - 1;
maxfilesperproc = maxfiles;
/*
* Cannot be changed after boot.
*/
nbuf = NBUF;
TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
ncallout = 16 + maxproc + maxfiles;
TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
}

View File

@ -23,7 +23,7 @@ cpu I486_CPU
cpu I586_CPU
cpu I686_CPU
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints" #Default places to look for devices.

View File

@ -1756,7 +1756,7 @@ init386(first)
kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
/* Init basic tunables, hz etc */
init_param();
init_param1();
/*
* make gdt memory segments, the code segment goes up to end of the
@ -1933,6 +1933,7 @@ init386(first)
vm86_initialize();
getmemsize(first);
init_param2(physmem);
/* now running on new page tables, configured,and u/iom is accessible */

View File

@ -1756,7 +1756,7 @@ init386(first)
kern_envp = (caddr_t)bootinfo.bi_envp + KERNBASE;
/* Init basic tunables, hz etc */
init_param();
init_param1();
/*
* make gdt memory segments, the code segment goes up to end of the
@ -1933,6 +1933,7 @@ init386(first)
vm86_initialize();
getmemsize(first);
init_param2(physmem);
/* now running on new page tables, configured,and u/iom is accessible */

View File

@ -436,7 +436,8 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
__asm ("mtsprg 0, %0" :: "r"(globalp));
/* Init basic tunables, hz etc */
init_param();
init_param1();
init_param2(physmem);
/* setup curproc so the mutexes work */

View File

@ -20,7 +20,7 @@
machine powerpc
cpu MPC750
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints"

View File

@ -436,7 +436,8 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, char *args)
__asm ("mtsprg 0, %0" :: "r"(globalp));
/* Init basic tunables, hz etc */
init_param();
init_param1();
init_param2(physmem);
/* setup curproc so the mutexes work */

View File

@ -24,7 +24,7 @@
machine sparc64
cpu SUN4U
ident GENERIC
maxusers 32
maxusers 0
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints" #Default places to look for devices.

View File

@ -249,10 +249,15 @@ sparc64_init(caddr_t mdp, ofw_vec_t *vec)
end = (vm_offset_t)_end;
}
/*
* XXX calculate physmem
*/
/*
* Initialize tunables.
*/
init_param();
init_param1();
init_param2(physmem);
#ifdef DDB
kdb_init();

View File

@ -121,7 +121,8 @@ void *phashinit __P((int count, struct malloc_type *type, u_long *nentries));
void cpu_boot __P((int));
void cpu_rootconf __P((void));
void init_param __P((void));
void init_param1 __P((void));
void init_param2 __P((int physpages));
void tablefull __P((const char *));
int kvprintf __P((char const *, void (*)(int, void*), void *, int,
_BSD_VA_LIST_)) __printflike(1, 0);

View File

@ -81,8 +81,7 @@ options(void)
}
if (maxusers == 0) {
printf("maxusers not specified; %d assumed\n", users.u_default);
maxusers = users.u_default;
/* printf("maxusers not specified; will auto-size\n"); */
} else if (maxusers < users.u_min) {
printf("minimum of %d maxusers assumed\n", users.u_min);
maxusers = users.u_min;