1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1980, 1986, 1989, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * (c) UNIX System Laboratories, Inc. 5df8bae1dSRodney W. Grimes * All or some portions of this file are derived from material licensed 6df8bae1dSRodney W. Grimes * to the University of California by American Telephone and Telegraph 7df8bae1dSRodney W. Grimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8df8bae1dSRodney W. Grimes * the permission of UNIX System Laboratories, Inc. 9df8bae1dSRodney W. Grimes * 10df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 11df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 12df8bae1dSRodney W. Grimes * are met: 13df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 14df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 15df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 16df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 17df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 18df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 19df8bae1dSRodney W. Grimes * must display the following acknowledgement: 20df8bae1dSRodney W. Grimes * This product includes software developed by the University of 21df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 22df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 23df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 24df8bae1dSRodney W. Grimes * without specific prior written permission. 25df8bae1dSRodney W. Grimes * 26df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36df8bae1dSRodney W. Grimes * SUCH DAMAGE. 37df8bae1dSRodney W. Grimes * 3870b012caSJeffrey Hsu * @(#)param.c 8.3 (Berkeley) 8/20/94 39c3aac50fSPeter Wemm * $FreeBSD$ 40df8bae1dSRodney W. Grimes */ 41df8bae1dSRodney W. Grimes 424bd49128SPeter Wemm #include "opt_param.h" 43ee342e1bSPeter Wemm #include "opt_maxusers.h" 4450c73f36SGarrett Wollman 45df8bae1dSRodney W. Grimes #include <sys/param.h> 46ee342e1bSPeter Wemm #include <sys/systm.h> 47ee342e1bSPeter Wemm #include <sys/kernel.h> 48df8bae1dSRodney W. Grimes 49df8bae1dSRodney W. Grimes /* 50df8bae1dSRodney W. Grimes * System parameter formulae. 51df8bae1dSRodney W. Grimes */ 52df8bae1dSRodney W. Grimes 53df8bae1dSRodney W. Grimes #ifndef HZ 54df8bae1dSRodney W. Grimes #define HZ 100 55df8bae1dSRodney W. Grimes #endif 56ee342e1bSPeter Wemm #define NPROC (20 + 16 * maxusers) 57ee342e1bSPeter Wemm #ifndef NBUF 58ee342e1bSPeter Wemm #define NBUF 0 59ee342e1bSPeter Wemm #endif 605a00f364SDag-Erling Smørgrav #ifndef MAXFILES 61ee342e1bSPeter Wemm #define MAXFILES (maxproc * 2) 625a00f364SDag-Erling Smørgrav #endif 63dd0b2081SDavid Greenman 64ee342e1bSPeter Wemm int hz; 65ee342e1bSPeter Wemm int tick; 66ee342e1bSPeter Wemm int tickadj; /* can adjust 30ms in 60s */ 67ee342e1bSPeter Wemm int maxusers; /* base tunable */ 68ee342e1bSPeter Wemm int maxproc; /* maximum # of processes */ 69ee342e1bSPeter Wemm int maxprocperuid; /* max # of procs per user */ 70ee342e1bSPeter Wemm int maxfiles; /* sys. wide open files limit */ 71ee342e1bSPeter Wemm int maxfilesperproc; /* per-proc open files limit */ 72ee342e1bSPeter Wemm int ncallout; /* maximum # of timer events */ 73ee342e1bSPeter Wemm int nbuf; 74ee342e1bSPeter Wemm int nswbuf; 75df8bae1dSRodney W. Grimes 76df8bae1dSRodney W. Grimes /* 77df8bae1dSRodney W. Grimes * These have to be allocated somewhere; allocating 78df8bae1dSRodney W. Grimes * them here forces loader errors if this file is omitted 79df8bae1dSRodney W. Grimes * (if they've been externed everywhere else; hah!). 80df8bae1dSRodney W. Grimes */ 8128f8db14SBruce Evans struct buf *swbuf; 829722d88fSJason Evans 839722d88fSJason Evans /* 849722d88fSJason Evans * Total number of shared mutexes to protect all lockmgr locks. 859722d88fSJason Evans */ 869722d88fSJason Evans #ifndef LOCKMUTEX 879722d88fSJason Evans #define LOCKMUTEX 10 889722d88fSJason Evans #endif 899722d88fSJason Evans int lock_nmtx = LOCKMUTEX; 90ee342e1bSPeter Wemm 91ee342e1bSPeter Wemm /* 92ee342e1bSPeter Wemm * Boot time overrides 93ee342e1bSPeter Wemm */ 94ee342e1bSPeter Wemm void 95ee342e1bSPeter Wemm init_param(void) 96ee342e1bSPeter Wemm { 97ee342e1bSPeter Wemm 98ee342e1bSPeter Wemm /* Base parameters */ 99ee342e1bSPeter Wemm maxusers = MAXUSERS; 100ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.maxusers", &maxusers); 101ee342e1bSPeter Wemm hz = HZ; 102ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.hz", &hz); 103ee342e1bSPeter Wemm tick = 1000000 / hz; 104ee342e1bSPeter Wemm tickadj = howmany(30000, 60 * hz); /* can adjust 30ms in 60s */ 105ee342e1bSPeter Wemm 106ee342e1bSPeter Wemm /* The following can be overridden after boot via sysctl */ 107ee342e1bSPeter Wemm maxproc = NPROC; 108ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.maxproc", &maxproc); 109ee342e1bSPeter Wemm maxfiles = MAXFILES; 110ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles); 111ee342e1bSPeter Wemm maxprocperuid = maxproc - 1; 112ee342e1bSPeter Wemm maxfilesperproc = maxfiles; 113ee342e1bSPeter Wemm 114ee342e1bSPeter Wemm /* Cannot be changed after boot */ 115ee342e1bSPeter Wemm nbuf = NBUF; 116ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.nbuf", &nbuf); 117ee342e1bSPeter Wemm ncallout = 16 + maxproc + maxfiles; 118ee342e1bSPeter Wemm TUNABLE_INT_FETCH("kern.ncallout", &ncallout); 119ee342e1bSPeter Wemm } 120