xref: /freebsd/sys/kern/subr_param.c (revision dd0b2081f452c0339a44a9647866cf9990111086)
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
39dd0b2081SDavid Greenman  * $Id: param.c,v 1.30 1998/07/11 13:06:38 bde 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 
47df8bae1dSRodney W. Grimes #ifdef SYSVSHM
48df8bae1dSRodney W. Grimes #include <machine/vmparam.h>
49df8bae1dSRodney W. Grimes #include <sys/shm.h>
50df8bae1dSRodney W. Grimes #endif
513d903220SDoug Rabson #ifdef SYSVSEM
5250c73f36SGarrett Wollman #include <sys/sem.h>
533d903220SDoug Rabson #endif
543d903220SDoug Rabson #ifdef SYSVMSG
5550c73f36SGarrett Wollman #include <sys/msg.h>
563d903220SDoug Rabson #endif
57df8bae1dSRodney W. Grimes 
58df8bae1dSRodney W. Grimes /*
59df8bae1dSRodney W. Grimes  * System parameter formulae.
60df8bae1dSRodney W. Grimes  *
61df8bae1dSRodney W. Grimes  * This file is copied into each directory where we compile
62df8bae1dSRodney W. Grimes  * the kernel; it should be modified there to suit local taste
63df8bae1dSRodney W. Grimes  * if necessary.
64df8bae1dSRodney W. Grimes  *
65ac7e6123SDavid Greenman  * Compiled with -DMAXUSERS=xx
66df8bae1dSRodney W. Grimes  */
67df8bae1dSRodney W. Grimes 
68df8bae1dSRodney W. Grimes #ifndef HZ
69df8bae1dSRodney W. Grimes #define	HZ 100
70df8bae1dSRodney W. Grimes #endif
71df8bae1dSRodney W. Grimes int	hz = HZ;
72df8bae1dSRodney W. Grimes int	tick = 1000000 / HZ;
73df471779SBruce Evans int	tickadj = howmany(30000, 60 * HZ);	/* can adjust 30ms in 60s */
74df8bae1dSRodney W. Grimes #define	NPROC (20 + 16 * MAXUSERS)
75d3c0af69SGuido van Rooij #define MAXFILES (NPROC*2)
760d94caffSDavid Greenman int	maxproc = NPROC;			/* maximum # of processes */
77e6373c9eSGuido van Rooij int	maxprocperuid = NPROC-1;		/* maximum # of processes per user */
78d3c0af69SGuido van Rooij int	maxfiles = MAXFILES;			/* system wide open files limit */
79d3c0af69SGuido van Rooij int	maxfilesperproc = MAXFILES;		/* per-process open files limit */
80d3c0af69SGuido van Rooij int	ncallout = 16 + NPROC + MAXFILES;	/* maximum # of timer events */
81cddc961aSDavid Greenman 
82cddc961aSDavid Greenman /* maximum # of mbuf clusters */
83cddc961aSDavid Greenman #ifndef NMBCLUSTERS
84cb7545a9SGarrett Wollman #define	NMBCLUSTERS (512 + MAXUSERS * 16)
85cddc961aSDavid Greenman #endif
86cb7545a9SGarrett Wollman int	nmbclusters = NMBCLUSTERS;
87cb7545a9SGarrett Wollman 
8898271db4SGarrett Wollman #if MAXFILES > NMBCLUSTERS
8998271db4SGarrett Wollman #define	MAXSOCKETS MAXFILES
9098271db4SGarrett Wollman #else
9198271db4SGarrett Wollman #define	MAXSOCKETS NMBCLUSTERS
9298271db4SGarrett Wollman #endif
9398271db4SGarrett Wollman int	maxsockets = MAXSOCKETS;
9498271db4SGarrett Wollman 
95649c409dSDavid Greenman /* allocate 1/4th amount of virtual address space for mbufs XXX */
96649c409dSDavid Greenman int	nmbufs = NMBCLUSTERS * 4;
97cddc961aSDavid Greenman 
98dd0b2081SDavid Greenman /* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */
99dd0b2081SDavid Greenman #ifndef NSFBUFS
100dd0b2081SDavid Greenman #define	NSFBUFS (512 + MAXUSERS * 16)
101dd0b2081SDavid Greenman #endif
102dd0b2081SDavid Greenman int	nsfbufs = NSFBUFS;
103dd0b2081SDavid Greenman 
104df8bae1dSRodney W. Grimes /*
105df8bae1dSRodney W. Grimes  * Values in support of System V compatible shared memory.	XXX
106df8bae1dSRodney W. Grimes  */
107df8bae1dSRodney W. Grimes #ifdef SYSVSHM
1083ab1adc5SJoerg Wunsch #ifndef SHMMAX
109f8845af0SPoul-Henning Kamp #define	SHMMAX	(SHMMAXPGS*PAGE_SIZE)
1103ab1adc5SJoerg Wunsch #endif
1113ab1adc5SJoerg Wunsch #ifndef SHMMIN
112df8bae1dSRodney W. Grimes #define	SHMMIN	1
1133ab1adc5SJoerg Wunsch #endif
1143ab1adc5SJoerg Wunsch #ifndef SHMMNI
115df8bae1dSRodney W. Grimes #define	SHMMNI	32			/* <= SHMMMNI in shm.h */
1163ab1adc5SJoerg Wunsch #endif
1173ab1adc5SJoerg Wunsch #ifndef SHMSEG
118df8bae1dSRodney W. Grimes #define	SHMSEG	8
1193ab1adc5SJoerg Wunsch #endif
1203ab1adc5SJoerg Wunsch #ifndef SHMALL
121e911eafcSPoul-Henning Kamp #define	SHMALL	(SHMMAXPGS)
1223ab1adc5SJoerg Wunsch #endif
123df8bae1dSRodney W. Grimes 
124df8bae1dSRodney W. Grimes struct	shminfo shminfo = {
125df8bae1dSRodney W. Grimes 	SHMMAX,
126df8bae1dSRodney W. Grimes 	SHMMIN,
127df8bae1dSRodney W. Grimes 	SHMMNI,
128df8bae1dSRodney W. Grimes 	SHMSEG,
129df8bae1dSRodney W. Grimes 	SHMALL
130df8bae1dSRodney W. Grimes };
131df8bae1dSRodney W. Grimes #endif
132df8bae1dSRodney W. Grimes 
133df8bae1dSRodney W. Grimes /*
1343d903220SDoug Rabson  * Values in support of System V compatible semaphores.
1353d903220SDoug Rabson  */
1363d903220SDoug Rabson 
1373d903220SDoug Rabson #ifdef SYSVSEM
1383d903220SDoug Rabson 
1393d903220SDoug Rabson struct seminfo seminfo = {
1403d903220SDoug Rabson                 SEMMAP,         /* # of entries in semaphore map */
1413d903220SDoug Rabson                 SEMMNI,         /* # of semaphore identifiers */
1423d903220SDoug Rabson                 SEMMNS,         /* # of semaphores in system */
1433d903220SDoug Rabson                 SEMMNU,         /* # of undo structures in system */
1443d903220SDoug Rabson                 SEMMSL,         /* max # of semaphores per id */
1453d903220SDoug Rabson                 SEMOPM,         /* max # of operations per semop call */
1463d903220SDoug Rabson                 SEMUME,         /* max # of undo entries per process */
1473d903220SDoug Rabson                 SEMUSZ,         /* size in bytes of undo structure */
1483d903220SDoug Rabson                 SEMVMX,         /* semaphore maximum value */
1493d903220SDoug Rabson                 SEMAEM          /* adjust on exit max value */
1503d903220SDoug Rabson };
1513d903220SDoug Rabson #endif
1523d903220SDoug Rabson 
1533d903220SDoug Rabson /*
1543d903220SDoug Rabson  * Values in support of System V compatible messages.
1553d903220SDoug Rabson  */
1563d903220SDoug Rabson 
1573d903220SDoug Rabson #ifdef SYSVMSG
1583d903220SDoug Rabson 
1593d903220SDoug Rabson struct msginfo msginfo = {
1603d903220SDoug Rabson                 MSGMAX,         /* max chars in a message */
1613d903220SDoug Rabson                 MSGMNI,         /* # of message queue identifiers */
1623d903220SDoug Rabson                 MSGMNB,         /* max chars in a queue */
1633d903220SDoug Rabson                 MSGTQL,         /* max messages in system */
1643d903220SDoug Rabson                 MSGSSZ,         /* size of a message segment */
1653d903220SDoug Rabson                 		/* (must be small power of 2 greater than 4) */
1663d903220SDoug Rabson                 MSGSEG          /* number of message segments */
1673d903220SDoug Rabson };
1683d903220SDoug Rabson #endif
1693d903220SDoug Rabson 
1703d903220SDoug Rabson /*
17128f8db14SBruce Evans  * These may be set to nonzero here or by patching.
17228f8db14SBruce Evans  * If they are nonzero at bootstrap time then they are
17328f8db14SBruce Evans  * initialized to values dependent on the memory size.
174df8bae1dSRodney W. Grimes  */
17528f8db14SBruce Evans #ifdef	NBUF
17628f8db14SBruce Evans int	nbuf = NBUF;
17728f8db14SBruce Evans #else
17828f8db14SBruce Evans int	nbuf = 0;
17928f8db14SBruce Evans #endif
18028f8db14SBruce Evans int	nswbuf = 0;
181df8bae1dSRodney W. Grimes 
182df8bae1dSRodney W. Grimes /*
183df8bae1dSRodney W. Grimes  * These have to be allocated somewhere; allocating
184df8bae1dSRodney W. Grimes  * them here forces loader errors if this file is omitted
185df8bae1dSRodney W. Grimes  * (if they've been externed everywhere else; hah!).
186df8bae1dSRodney W. Grimes  */
18728f8db14SBruce Evans struct	buf *swbuf;
188