diff --git a/sys/conf/param.c b/sys/conf/param.c deleted file mode 100644 index 704e3f53aab2..000000000000 --- a/sys/conf/param.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 1980, 1986, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)param.c 8.3 (Berkeley) 8/20/94 - * $FreeBSD$ - */ - -#include "opt_param.h" - -#include - -/* - * System parameter formulae. - * - * This file is copied into each directory where we compile - * the kernel; it should be modified there to suit local taste - * if necessary. - * - * Compiled with -DMAXUSERS=xx - */ - -#ifndef HZ -#define HZ 100 -#endif -int hz = HZ; -int tick = 1000000 / HZ; -int tickadj = howmany(30000, 60 * HZ); /* can adjust 30ms in 60s */ -#define NPROC (20 + 16 * MAXUSERS) -#ifndef MAXFILES -#define MAXFILES (NPROC*2) -#endif -int maxproc = NPROC; /* maximum # of processes */ -int maxprocperuid = NPROC-1; /* max # of procs per user */ -int maxfiles = MAXFILES; /* sys. wide open files limit */ -int maxfilesperproc = MAXFILES; /* per-proc open files limit */ -int ncallout = 16 + NPROC + MAXFILES; /* maximum # of timer events */ - -/* - * These may be set to nonzero here or by patching. - * If they are nonzero at bootstrap time then they are - * initialized to values dependent on the memory size. - */ -#ifdef NBUF -int nbuf = NBUF; -#else -int nbuf = 0; -#endif -int nswbuf = 0; - -/* - * These have to be allocated somewhere; allocating - * them here forces loader errors if this file is omitted - * (if they've been externed everywhere else; hah!). - */ -struct buf *swbuf; - -/* - * Total number of shared mutexes to protect all lockmgr locks. - */ -#ifndef LOCKMUTEX -#define LOCKMUTEX 10 -#endif -int lock_nmtx = LOCKMUTEX; diff --git a/sys/kern/kern_mib.c b/sys/kern/kern_mib.c index 3fbb617d605f..157fa1a8dc83 100644 --- a/sys/kern/kern_mib.c +++ b/sys/kern/kern_mib.c @@ -96,6 +96,9 @@ SYSCTL_INT(_kern, KERN_MAXPROC, maxproc, CTLFLAG_RD, SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxprocperuid, CTLFLAG_RW, &maxprocperuid, 0, "Maximum processes allowed per userid"); +SYSCTL_INT(_kern, KERN_MAXPROCPERUID, maxusers, CTLFLAG_RD, + &maxusers, 0, "Hint for kernel tuning"); + SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD, 0, ARG_MAX, "Maximum bytes of argument to execve(2)"); diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c index 704e3f53aab2..272ca3c13a19 100644 --- a/sys/kern/subr_param.c +++ b/sys/kern/subr_param.c @@ -40,46 +40,38 @@ */ #include "opt_param.h" +#include "opt_maxusers.h" #include +#include +#include /* * System parameter formulae. - * - * This file is copied into each directory where we compile - * the kernel; it should be modified there to suit local taste - * if necessary. - * - * Compiled with -DMAXUSERS=xx */ #ifndef HZ #define HZ 100 #endif -int hz = HZ; -int tick = 1000000 / HZ; -int tickadj = howmany(30000, 60 * HZ); /* can adjust 30ms in 60s */ -#define NPROC (20 + 16 * MAXUSERS) +#define NPROC (20 + 16 * maxusers) +#ifndef NBUF +#define NBUF 0 +#endif #ifndef MAXFILES -#define MAXFILES (NPROC*2) +#define MAXFILES (maxproc * 2) #endif -int maxproc = NPROC; /* maximum # of processes */ -int maxprocperuid = NPROC-1; /* max # of procs per user */ -int maxfiles = MAXFILES; /* sys. wide open files limit */ -int maxfilesperproc = MAXFILES; /* per-proc open files limit */ -int ncallout = 16 + NPROC + MAXFILES; /* maximum # of timer events */ -/* - * These may be set to nonzero here or by patching. - * If they are nonzero at bootstrap time then they are - * initialized to values dependent on the memory size. - */ -#ifdef NBUF -int nbuf = NBUF; -#else -int nbuf = 0; -#endif -int nswbuf = 0; +int hz; +int tick; +int tickadj; /* can adjust 30ms in 60s */ +int maxusers; /* base tunable */ +int maxproc; /* maximum # of processes */ +int maxprocperuid; /* max # of procs per user */ +int maxfiles; /* sys. wide open files limit */ +int maxfilesperproc; /* per-proc open files limit */ +int ncallout; /* maximum # of timer events */ +int nbuf; +int nswbuf; /* * These have to be allocated somewhere; allocating @@ -95,3 +87,33 @@ struct buf *swbuf; #define LOCKMUTEX 10 #endif int lock_nmtx = LOCKMUTEX; + +/* + * Boot time overrides + */ +void +init_param(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); + ncallout = 16 + maxproc + maxfiles; + TUNABLE_INT_FETCH("kern.ncallout", &ncallout); +} diff --git a/sys/sys/systm.h b/sys/sys/systm.h index cdf984adf444..031e0ae4125c 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -71,6 +71,8 @@ extern struct vnode *rootvp; /* vnode equivalent to above */ extern int boothowto; /* reboot flags, from console subsystem */ extern int bootverbose; /* nonzero to print verbose messages */ +extern int maxusers; /* system tune hint */ + #ifdef INVARIANTS /* The option is always available */ #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) #else @@ -105,6 +107,7 @@ 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 tablefull __P((const char *)); int kvprintf __P((char const *, void (*)(int, void*), void *, int, _BSD_VA_LIST_)) __printflike(1, 0);