Date: Sat, 8 Dec 2001 17:54:06 -0700 From: Nate Williams <nate@yogotech.com> To: Matthew Dillon <dillon@apollo.backplane.com> Cc: Kirk McKusick <mckusick@mckusick.com>, Robert Watson <rwatson@FreeBSD.ORG>, arch@FreeBSD.ORG Subject: Re: Patch for auto-default value for maxusers Message-ID: <15378.46638.217290.407771@caddis.yogotech.com> In-Reply-To: <200112082340.fB8NeI329704@apollo.backplane.com> References: <200112071957.fB7Jvef29774@beastie.mckusick.com> <200112082256.fB8MuwL19001@apollo.backplane.com> <200112082340.fB8NeI329704@apollo.backplane.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> This patch is against -stable.
Minor nit...
>
> Index: usr.sbin/config/mkoptions.c
> ===================================================================
> RCS file: /home/ncvs/src/usr.sbin/config/mkoptions.c,v
> retrieving revision 1.17.2.2
> diff -u -r1.17.2.2 mkoptions.c
> --- usr.sbin/config/mkoptions.c 2000/11/21 20:03:38 1.17.2.2
> +++ usr.sbin/config/mkoptions.c 2001/12/08 23:26:16
> @@ -93,8 +93,8 @@
> } else
> up = &users[machine - 1];
> if (maxusers == 0) {
> - printf("maxusers not specified; %d assumed\n", up->u_default);
> - maxusers = up->u_default;
> + /* printf("maxusers not specified; will auto-size\n"); */
> + maxusers = 0;
Isn't this line kind of redundant, since we already know that maxusers == 0?
> } else if (maxusers < up->u_min) {
> printf("minimum of %d maxusers assumed\n", up->u_min);
> maxusers = up->u_min;
> Index: sys/alpha/alpha/machdep.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/alpha/alpha/machdep.c,v
> retrieving revision 1.68.2.14
> diff -u -r1.68.2.14 machdep.c
> --- sys/alpha/alpha/machdep.c 2001/10/04 13:09:36 1.68.2.14
> +++ sys/alpha/alpha/machdep.c 2001/12/08 23:12:38
> @@ -329,13 +329,14 @@
> */
>
> if (nbuf == 0) {
> - int factor = 4 * BKVASIZE / PAGE_SIZE;
> + int factor = 4 * BKVASIZE / 1024;
> + int kbytes = physmem * (PAGE_SIZE / 1024);
>
> nbuf = 50;
> - if (physmem > 1024)
> - nbuf += min((physmem - 1024) / factor, 16384 / factor);
> - if (physmem > 16384)
> - nbuf += (physmem - 16384) * 2 / (factor * 5);
> + if (kbytes > 4096)
> + nbuf += min((kbytes - 4096) / factor, 65536 / factor);
> + if (kbytes > 65536)
> + nbuf += (kbytes - 65536) * 2 / (factor * 5);
> if (maxbcache && nbuf > maxbcache / BKVASIZE)
> nbuf = maxbcache / BKVASIZE;
> }
> @@ -698,7 +699,7 @@
> kern_envp = bootinfo.envp;
>
> /* Do basic tuning, hz etc */
> - init_param();
> + init_param1();
>
> /*
> * Initalize the (temporary) bootstrap console interface, so
> @@ -1004,6 +1005,7 @@
> physmem -= (sz - nsz);
> }
> }
> + init_param2(physmem);
>
> /*
> * Initialize error message buffer (at end of core).
> Index: sys/i386/i386/machdep.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/i386/i386/machdep.c,v
> retrieving revision 1.385.2.20
> diff -u -r1.385.2.20 machdep.c
> --- sys/i386/i386/machdep.c 2001/10/02 23:34:22 1.385.2.20
> +++ sys/i386/i386/machdep.c 2001/12/08 23:11:09
> @@ -331,13 +331,14 @@
> * factor represents the 1/4 x ram conversion.
> */
> if (nbuf == 0) {
> - int factor = 4 * BKVASIZE / PAGE_SIZE;
> + int factor = 4 * BKVASIZE / 1024;
> + int kbytes = physmem * (PAGE_SIZE / 1024);
>
> nbuf = 50;
> - if (physmem > 1024)
> - nbuf += min((physmem - 1024) / factor, 16384 / factor);
> - if (physmem > 16384)
> - nbuf += (physmem - 16384) * 2 / (factor * 5);
> + if (kbytes > 4096)
> + nbuf += min((kbytes - 4096) / factor, 65536 / factor);
> + if (kbytes > 65536)
> + nbuf += (kbytes - 65536) * 2 / (factor * 5);
> if (maxbcache && nbuf > maxbcache / BKVASIZE)
> nbuf = maxbcache / BKVASIZE;
> }
> @@ -1829,7 +1830,7 @@
> 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
> @@ -1963,6 +1964,7 @@
>
> vm86_initialize();
> getmemsize(first);
> + init_param2(physmem);
>
> /* now running on new page tables, configured,and u/iom is accessible */
>
> Index: sys/kern/subr_param.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/kern/subr_param.c,v
> retrieving revision 1.42.2.3
> diff -u -r1.42.2.3 subr_param.c
> --- sys/kern/subr_param.c 2001/11/03 01:41:08 1.42.2.3
> +++ sys/kern/subr_param.c 2001/12/08 23:28:49
> @@ -98,33 +98,16 @@
> 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 */
> - nsfbufs = NSFBUFS;
> - TUNABLE_INT_FETCH("kern.ipc.nsfbufs", &nsfbufs);
> - nbuf = NBUF;
> - TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
> #ifdef VM_SWZONE_SIZE_MAX
> maxswzone = VM_SWZONE_SIZE_MAX;
> #endif
> @@ -133,8 +116,6 @@
> 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);
> @@ -149,3 +130,45 @@
> 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. Unless overriden, NSFBUFS is based
> + * on maxusers and NBUF is typically 0 (auto-sized later).
> + */
> + nsfbufs = NSFBUFS;
> + TUNABLE_INT_FETCH("kern.ipc.nsfbufs", &nsfbufs);
> + nbuf = NBUF;
> + TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
> +
> + ncallout = 16 + maxproc + maxfiles;
> + TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
> +}
> +
> Index: sys/pc98/i386/machdep.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/pc98/i386/machdep.c,v
> retrieving revision 1.151.2.23
> diff -u -r1.151.2.23 machdep.c
> --- sys/pc98/i386/machdep.c 2001/10/08 03:29:43 1.151.2.23
> +++ sys/pc98/i386/machdep.c 2001/12/08 23:13:11
> @@ -344,13 +344,14 @@
> * factor represents the 1/4 x ram conversion.
> */
> if (nbuf == 0) {
> - int factor = 4 * BKVASIZE / PAGE_SIZE;
> + int factor = 4 * BKVASIZE / 1024;
> + int kbytes = physmem * (PAGE_SIZE / 1024);
>
> nbuf = 50;
> - if (physmem > 1024)
> - nbuf += min((physmem - 1024) / factor, 16384 / factor);
> - if (physmem > 16384)
> - nbuf += (physmem - 16384) * 2 / (factor * 5);
> + if (kbytes > 4096)
> + nbuf += min((kbytes - 4096) / factor, 65536 / factor);
> + if (kbytes > 65536)
> + nbuf += (kbytes - 65536) * 2 / (factor * 5);
> if (maxbcache && nbuf > maxbcache / BKVASIZE)
> nbuf = maxbcache / BKVASIZE;
> }
> @@ -1880,7 +1881,7 @@
> 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
> @@ -2014,6 +2015,7 @@
>
> vm86_initialize();
> getmemsize(first);
> + init_param2(physmem);
>
> /* now running on new page tables, configured,and u/iom is accessible */
>
> Index: sys/sys/systm.h
> ===================================================================
> RCS file: /home/ncvs/src/sys/sys/systm.h,v
> retrieving revision 1.111.2.11
> diff -u -r1.111.2.11 systm.h
> --- sys/sys/systm.h 2001/12/04 05:57:40 1.111.2.11
> +++ sys/sys/systm.h 2001/12/08 23:13:35
> @@ -126,7 +126,8 @@
>
> 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 addlog __P((const char *, ...)) __printflike(1, 2);
> int kvprintf __P((char const *, void (*)(int, void*), void *, int,
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-arch" in the body of the message
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?15378.46638.217290.407771>
