xref: /freebsd/sys/kern/subr_param.c (revision df8bae1de4b67ccf57f4afebd4e2bf258c38910d)
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
39df8bae1dSRodney W. Grimes  */
40df8bae1dSRodney W. Grimes 
41df8bae1dSRodney W. Grimes #include <sys/param.h>
42df8bae1dSRodney W. Grimes #include <sys/systm.h>
43df8bae1dSRodney W. Grimes #include <sys/socket.h>
44df8bae1dSRodney W. Grimes #include <sys/proc.h>
45df8bae1dSRodney W. Grimes #include <sys/vnode.h>
46df8bae1dSRodney W. Grimes #include <sys/file.h>
47df8bae1dSRodney W. Grimes #include <sys/callout.h>
48df8bae1dSRodney W. Grimes #include <sys/clist.h>
49df8bae1dSRodney W. Grimes #include <sys/mbuf.h>
50df8bae1dSRodney W. Grimes #include <sys/kernel.h>
51df8bae1dSRodney W. Grimes 
52df8bae1dSRodney W. Grimes #include <ufs/ufs/quota.h>
53df8bae1dSRodney W. Grimes 
54df8bae1dSRodney W. Grimes #ifdef SYSVSHM
55df8bae1dSRodney W. Grimes #include <machine/vmparam.h>
56df8bae1dSRodney W. Grimes #include <sys/shm.h>
57df8bae1dSRodney W. Grimes #endif
58df8bae1dSRodney W. Grimes 
59df8bae1dSRodney W. Grimes /*
60df8bae1dSRodney W. Grimes  * System parameter formulae.
61df8bae1dSRodney W. Grimes  *
62df8bae1dSRodney W. Grimes  * This file is copied into each directory where we compile
63df8bae1dSRodney W. Grimes  * the kernel; it should be modified there to suit local taste
64df8bae1dSRodney W. Grimes  * if necessary.
65df8bae1dSRodney W. Grimes  *
66df8bae1dSRodney W. Grimes  * Compiled with -DHZ=xx -DTIMEZONE=x -DDST=x -DMAXUSERS=xx
67df8bae1dSRodney W. Grimes  */
68df8bae1dSRodney W. Grimes 
69df8bae1dSRodney W. Grimes #ifndef HZ
70df8bae1dSRodney W. Grimes #define	HZ 100
71df8bae1dSRodney W. Grimes #endif
72df8bae1dSRodney W. Grimes int	hz = HZ;
73df8bae1dSRodney W. Grimes int	tick = 1000000 / HZ;
74df8bae1dSRodney W. Grimes int	tickadj = 30000 / (60 * HZ);		/* can adjust 30ms in 60s */
75df8bae1dSRodney W. Grimes struct	timezone tz = { TIMEZONE, DST };
76df8bae1dSRodney W. Grimes #define	NPROC (20 + 16 * MAXUSERS)
77df8bae1dSRodney W. Grimes int	maxproc = NPROC;
78df8bae1dSRodney W. Grimes #define	NTEXT (80 + NPROC / 8)			/* actually the object cache */
79df8bae1dSRodney W. Grimes #define	NVNODE (NPROC + NTEXT + 100)
80df8bae1dSRodney W. Grimes int	desiredvnodes = NVNODE;
81df8bae1dSRodney W. Grimes int	maxfiles = 3 * (NPROC + MAXUSERS) + 80;
82df8bae1dSRodney W. Grimes int	ncallout = 16 + NPROC;
83df8bae1dSRodney W. Grimes int	nclist = 60 + 12 * MAXUSERS;
84df8bae1dSRodney W. Grimes int	nmbclusters = NMBCLUSTERS;
85df8bae1dSRodney W. Grimes int	fscale = FSCALE;	/* kernel uses `FSCALE', user uses `fscale' */
86df8bae1dSRodney W. Grimes 
87df8bae1dSRodney W. Grimes /*
88df8bae1dSRodney W. Grimes  * Values in support of System V compatible shared memory.	XXX
89df8bae1dSRodney W. Grimes  */
90df8bae1dSRodney W. Grimes #ifdef SYSVSHM
91df8bae1dSRodney W. Grimes #define	SHMMAX	(SHMMAXPGS*NBPG)
92df8bae1dSRodney W. Grimes #define	SHMMIN	1
93df8bae1dSRodney W. Grimes #define	SHMMNI	32			/* <= SHMMMNI in shm.h */
94df8bae1dSRodney W. Grimes #define	SHMSEG	8
95df8bae1dSRodney W. Grimes #define	SHMALL	(SHMMAXPGS/CLSIZE)
96df8bae1dSRodney W. Grimes 
97df8bae1dSRodney W. Grimes struct	shminfo shminfo = {
98df8bae1dSRodney W. Grimes 	SHMMAX,
99df8bae1dSRodney W. Grimes 	SHMMIN,
100df8bae1dSRodney W. Grimes 	SHMMNI,
101df8bae1dSRodney W. Grimes 	SHMSEG,
102df8bae1dSRodney W. Grimes 	SHMALL
103df8bae1dSRodney W. Grimes };
104df8bae1dSRodney W. Grimes #endif
105df8bae1dSRodney W. Grimes 
106df8bae1dSRodney W. Grimes /*
107df8bae1dSRodney W. Grimes  * These are initialized at bootstrap time
108df8bae1dSRodney W. Grimes  * to values dependent on memory size
109df8bae1dSRodney W. Grimes  */
110df8bae1dSRodney W. Grimes int	nbuf, nswbuf;
111df8bae1dSRodney W. Grimes 
112df8bae1dSRodney W. Grimes /*
113df8bae1dSRodney W. Grimes  * These have to be allocated somewhere; allocating
114df8bae1dSRodney W. Grimes  * them here forces loader errors if this file is omitted
115df8bae1dSRodney W. Grimes  * (if they've been externed everywhere else; hah!).
116df8bae1dSRodney W. Grimes  */
117df8bae1dSRodney W. Grimes struct 	callout *callout;
118df8bae1dSRodney W. Grimes struct	cblock *cfree;
119df8bae1dSRodney W. Grimes struct	buf *buf, *swbuf;
120df8bae1dSRodney W. Grimes char	*buffers;
121df8bae1dSRodney W. Grimes 
122df8bae1dSRodney W. Grimes /*
123df8bae1dSRodney W. Grimes  * Proc/pgrp hashing.
124df8bae1dSRodney W. Grimes  * Here so that hash table sizes can depend on MAXUSERS/NPROC.
125df8bae1dSRodney W. Grimes  * Hash size must be a power of two.
126df8bae1dSRodney W. Grimes  * NOW omission of this file will cause loader errors!
127df8bae1dSRodney W. Grimes  */
128df8bae1dSRodney W. Grimes 
129df8bae1dSRodney W. Grimes #if NPROC > 1024
130df8bae1dSRodney W. Grimes #define	PIDHSZ		512
131df8bae1dSRodney W. Grimes #else
132df8bae1dSRodney W. Grimes #if NPROC > 512
133df8bae1dSRodney W. Grimes #define	PIDHSZ		256
134df8bae1dSRodney W. Grimes #else
135df8bae1dSRodney W. Grimes #if NPROC > 256
136df8bae1dSRodney W. Grimes #define	PIDHSZ		128
137df8bae1dSRodney W. Grimes #else
138df8bae1dSRodney W. Grimes #define	PIDHSZ		64
139df8bae1dSRodney W. Grimes #endif
140df8bae1dSRodney W. Grimes #endif
141df8bae1dSRodney W. Grimes #endif
142df8bae1dSRodney W. Grimes 
143df8bae1dSRodney W. Grimes struct	proc *pidhash[PIDHSZ];
144df8bae1dSRodney W. Grimes struct	pgrp *pgrphash[PIDHSZ];
145df8bae1dSRodney W. Grimes int	pidhashmask = PIDHSZ - 1;
146