xref: /freebsd/sys/kern/subr_param.c (revision 4bd4912865d61d45188daf139d777e1de7491a18)
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  *
38df8bae1dSRodney W. Grimes  *	@(#)param.c	8.2 (Berkeley) 1/21/94
394bd49128SPeter Wemm  * $Id: param.c,v 1.14 1996/01/04 20:28:02 wollman Exp $
40df8bae1dSRodney W. Grimes  */
41df8bae1dSRodney W. Grimes 
4250c73f36SGarrett Wollman #include "opt_sysvipc.h"
434bd49128SPeter Wemm #include "opt_param.h"
4450c73f36SGarrett Wollman 
45df8bae1dSRodney W. Grimes #include <sys/param.h>
46df8bae1dSRodney W. Grimes #include <sys/systm.h>
47df8bae1dSRodney W. Grimes #include <sys/socket.h>
48df8bae1dSRodney W. Grimes #include <sys/proc.h>
49df8bae1dSRodney W. Grimes #include <sys/vnode.h>
50df8bae1dSRodney W. Grimes #include <sys/file.h>
51df8bae1dSRodney W. Grimes #include <sys/callout.h>
52df8bae1dSRodney W. Grimes #include <sys/clist.h>
53df8bae1dSRodney W. Grimes #include <sys/mbuf.h>
54df8bae1dSRodney W. Grimes #include <sys/kernel.h>
55df8bae1dSRodney W. Grimes 
56df8bae1dSRodney W. Grimes #include <ufs/ufs/quota.h>
57df8bae1dSRodney W. Grimes 
58df8bae1dSRodney W. Grimes #ifdef SYSVSHM
59df8bae1dSRodney W. Grimes #include <machine/vmparam.h>
60df8bae1dSRodney W. Grimes #include <sys/shm.h>
61df8bae1dSRodney W. Grimes #endif
623d903220SDoug Rabson #ifdef SYSVSEM
6350c73f36SGarrett Wollman #include <sys/sem.h>
643d903220SDoug Rabson #endif
653d903220SDoug Rabson #ifdef SYSVMSG
6650c73f36SGarrett Wollman #include <sys/msg.h>
673d903220SDoug Rabson #endif
68df8bae1dSRodney W. Grimes 
69df8bae1dSRodney W. Grimes /*
70df8bae1dSRodney W. Grimes  * System parameter formulae.
71df8bae1dSRodney W. Grimes  *
72df8bae1dSRodney W. Grimes  * This file is copied into each directory where we compile
73df8bae1dSRodney W. Grimes  * the kernel; it should be modified there to suit local taste
74df8bae1dSRodney W. Grimes  * if necessary.
75df8bae1dSRodney W. Grimes  *
76ac7e6123SDavid Greenman  * Compiled with -DMAXUSERS=xx
77df8bae1dSRodney W. Grimes  */
78df8bae1dSRodney W. Grimes 
79df8bae1dSRodney W. Grimes #ifndef HZ
80df8bae1dSRodney W. Grimes #define	HZ 100
81df8bae1dSRodney W. Grimes #endif
82df8bae1dSRodney W. Grimes int	hz = HZ;
83df8bae1dSRodney W. Grimes int	tick = 1000000 / HZ;
84df8bae1dSRodney W. Grimes int	tickadj = 30000 / (60 * HZ);		/* can adjust 30ms in 60s */
85df8bae1dSRodney W. Grimes #define	NPROC (20 + 16 * MAXUSERS)
860d94caffSDavid Greenman int	maxproc = NPROC;			/* maximum # of processes */
87e6373c9eSGuido van Rooij int	maxprocperuid = NPROC-1;		/* maximum # of processes per user */
88ec2bb6adSDavid Greenman int	maxfiles = NPROC*2;			/* system wide open files limit */
89cddc961aSDavid Greenman int	maxfilesperproc = NPROC*2;		/* per-process open files limit */
900d94caffSDavid Greenman int	ncallout = 16 + NPROC;			/* maximum # of timer events */
91cddc961aSDavid Greenman 
92cddc961aSDavid Greenman /* maximum # of mbuf clusters */
93cddc961aSDavid Greenman #ifndef NMBCLUSTERS
94cddc961aSDavid Greenman int	nmbclusters = 512 + MAXUSERS * 16;
95cddc961aSDavid Greenman #else
96df8bae1dSRodney W. Grimes int	nmbclusters = NMBCLUSTERS;
97cddc961aSDavid Greenman #endif
98cddc961aSDavid Greenman 
99df8bae1dSRodney W. Grimes int	fscale = FSCALE;	/* kernel uses `FSCALE', user uses `fscale' */
100df8bae1dSRodney W. Grimes 
101df8bae1dSRodney W. Grimes /*
102df8bae1dSRodney W. Grimes  * Values in support of System V compatible shared memory.	XXX
103df8bae1dSRodney W. Grimes  */
104df8bae1dSRodney W. Grimes #ifdef SYSVSHM
1053ab1adc5SJoerg Wunsch #ifndef SHMMAX
106df8bae1dSRodney W. Grimes #define	SHMMAX	(SHMMAXPGS*NBPG)
1073ab1adc5SJoerg Wunsch #endif
1083ab1adc5SJoerg Wunsch #ifndef SHMMIN
109df8bae1dSRodney W. Grimes #define	SHMMIN	1
1103ab1adc5SJoerg Wunsch #endif
1113ab1adc5SJoerg Wunsch #ifndef SHMMNI
112df8bae1dSRodney W. Grimes #define	SHMMNI	32			/* <= SHMMMNI in shm.h */
1133ab1adc5SJoerg Wunsch #endif
1143ab1adc5SJoerg Wunsch #ifndef SHMSEG
115df8bae1dSRodney W. Grimes #define	SHMSEG	8
1163ab1adc5SJoerg Wunsch #endif
1173ab1adc5SJoerg Wunsch #ifndef SHMALL
118df8bae1dSRodney W. Grimes #define	SHMALL	(SHMMAXPGS/CLSIZE)
1193ab1adc5SJoerg Wunsch #endif
120df8bae1dSRodney W. Grimes 
121df8bae1dSRodney W. Grimes struct	shminfo shminfo = {
122df8bae1dSRodney W. Grimes 	SHMMAX,
123df8bae1dSRodney W. Grimes 	SHMMIN,
124df8bae1dSRodney W. Grimes 	SHMMNI,
125df8bae1dSRodney W. Grimes 	SHMSEG,
126df8bae1dSRodney W. Grimes 	SHMALL
127df8bae1dSRodney W. Grimes };
128df8bae1dSRodney W. Grimes #endif
129df8bae1dSRodney W. Grimes 
130df8bae1dSRodney W. Grimes /*
1313d903220SDoug Rabson  * Values in support of System V compatible semaphores.
1323d903220SDoug Rabson  */
1333d903220SDoug Rabson 
1343d903220SDoug Rabson #ifdef SYSVSEM
1353d903220SDoug Rabson 
1363d903220SDoug Rabson struct seminfo seminfo = {
1373d903220SDoug Rabson                 SEMMAP,         /* # of entries in semaphore map */
1383d903220SDoug Rabson                 SEMMNI,         /* # of semaphore identifiers */
1393d903220SDoug Rabson                 SEMMNS,         /* # of semaphores in system */
1403d903220SDoug Rabson                 SEMMNU,         /* # of undo structures in system */
1413d903220SDoug Rabson                 SEMMSL,         /* max # of semaphores per id */
1423d903220SDoug Rabson                 SEMOPM,         /* max # of operations per semop call */
1433d903220SDoug Rabson                 SEMUME,         /* max # of undo entries per process */
1443d903220SDoug Rabson                 SEMUSZ,         /* size in bytes of undo structure */
1453d903220SDoug Rabson                 SEMVMX,         /* semaphore maximum value */
1463d903220SDoug Rabson                 SEMAEM          /* adjust on exit max value */
1473d903220SDoug Rabson };
1483d903220SDoug Rabson #endif
1493d903220SDoug Rabson 
1503d903220SDoug Rabson /*
1513d903220SDoug Rabson  * Values in support of System V compatible messages.
1523d903220SDoug Rabson  */
1533d903220SDoug Rabson 
1543d903220SDoug Rabson #ifdef SYSVMSG
1553d903220SDoug Rabson 
1563d903220SDoug Rabson struct msginfo msginfo = {
1573d903220SDoug Rabson                 MSGMAX,         /* max chars in a message */
1583d903220SDoug Rabson                 MSGMNI,         /* # of message queue identifiers */
1593d903220SDoug Rabson                 MSGMNB,         /* max chars in a queue */
1603d903220SDoug Rabson                 MSGTQL,         /* max messages in system */
1613d903220SDoug Rabson                 MSGSSZ,         /* size of a message segment */
1623d903220SDoug Rabson                 		/* (must be small power of 2 greater than 4) */
1633d903220SDoug Rabson                 MSGSEG          /* number of message segments */
1643d903220SDoug Rabson };
1653d903220SDoug Rabson #endif
1663d903220SDoug Rabson 
1673d903220SDoug Rabson /*
16828f8db14SBruce Evans  * These may be set to nonzero here or by patching.
16928f8db14SBruce Evans  * If they are nonzero at bootstrap time then they are
17028f8db14SBruce Evans  * initialized to values dependent on the memory size.
171df8bae1dSRodney W. Grimes  */
17228f8db14SBruce Evans #ifdef	NBUF
17328f8db14SBruce Evans int	nbuf = NBUF;
17428f8db14SBruce Evans #else
17528f8db14SBruce Evans int	nbuf = 0;
17628f8db14SBruce Evans #endif
17728f8db14SBruce Evans int	nswbuf = 0;
178df8bae1dSRodney W. Grimes 
179df8bae1dSRodney W. Grimes /*
180df8bae1dSRodney W. Grimes  * These have to be allocated somewhere; allocating
181df8bae1dSRodney W. Grimes  * them here forces loader errors if this file is omitted
182df8bae1dSRodney W. Grimes  * (if they've been externed everywhere else; hah!).
183df8bae1dSRodney W. Grimes  */
18428f8db14SBruce Evans struct	buf *swbuf;
185df8bae1dSRodney W. Grimes 
186df8bae1dSRodney W. Grimes /*
187df8bae1dSRodney W. Grimes  * Proc/pgrp hashing.
188df8bae1dSRodney W. Grimes  * Here so that hash table sizes can depend on MAXUSERS/NPROC.
189df8bae1dSRodney W. Grimes  * Hash size must be a power of two.
190df8bae1dSRodney W. Grimes  * NOW omission of this file will cause loader errors!
191df8bae1dSRodney W. Grimes  */
192df8bae1dSRodney W. Grimes 
193df8bae1dSRodney W. Grimes #if NPROC > 1024
194df8bae1dSRodney W. Grimes #define	PIDHSZ		512
195df8bae1dSRodney W. Grimes #else
196df8bae1dSRodney W. Grimes #if NPROC > 512
197df8bae1dSRodney W. Grimes #define	PIDHSZ		256
198df8bae1dSRodney W. Grimes #else
199df8bae1dSRodney W. Grimes #if NPROC > 256
200df8bae1dSRodney W. Grimes #define	PIDHSZ		128
201df8bae1dSRodney W. Grimes #else
202df8bae1dSRodney W. Grimes #define	PIDHSZ		64
203df8bae1dSRodney W. Grimes #endif
204df8bae1dSRodney W. Grimes #endif
205df8bae1dSRodney W. Grimes #endif
206df8bae1dSRodney W. Grimes 
207df8bae1dSRodney W. Grimes struct	proc *pidhash[PIDHSZ];
208df8bae1dSRodney W. Grimes struct	pgrp *pgrphash[PIDHSZ];
209df8bae1dSRodney W. Grimes int	pidhashmask = PIDHSZ - 1;
210