xref: /freebsd/sys/kern/subr_param.c (revision 5a00f36414226a390bba7ec95705045a57393720)
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
395a00f364SDag-Erling Smørgrav  * $Id: param.c,v 1.32 1998/12/14 08:34:54 dillon Exp $
40df8bae1dSRodney W. Grimes  */
41df8bae1dSRodney W. Grimes 
423ea57f9dSMatthew Dillon #include <stddef.h>
433ea57f9dSMatthew Dillon 
4450c73f36SGarrett Wollman #include "opt_sysvipc.h"
454bd49128SPeter Wemm #include "opt_param.h"
4650c73f36SGarrett Wollman 
47df8bae1dSRodney W. Grimes #include <sys/param.h>
48df8bae1dSRodney W. Grimes 
49df8bae1dSRodney W. Grimes #ifdef SYSVSHM
50df8bae1dSRodney W. Grimes #include <machine/vmparam.h>
51df8bae1dSRodney W. Grimes #include <sys/shm.h>
52df8bae1dSRodney W. Grimes #endif
533d903220SDoug Rabson #ifdef SYSVSEM
5450c73f36SGarrett Wollman #include <sys/sem.h>
553d903220SDoug Rabson #endif
563d903220SDoug Rabson #ifdef SYSVMSG
5750c73f36SGarrett Wollman #include <sys/msg.h>
583d903220SDoug Rabson #endif
59df8bae1dSRodney W. Grimes 
60df8bae1dSRodney W. Grimes /*
61df8bae1dSRodney W. Grimes  * System parameter formulae.
62df8bae1dSRodney W. Grimes  *
63df8bae1dSRodney W. Grimes  * This file is copied into each directory where we compile
64df8bae1dSRodney W. Grimes  * the kernel; it should be modified there to suit local taste
65df8bae1dSRodney W. Grimes  * if necessary.
66df8bae1dSRodney W. Grimes  *
67ac7e6123SDavid Greenman  * Compiled with -DMAXUSERS=xx
68df8bae1dSRodney W. Grimes  */
69df8bae1dSRodney W. Grimes 
70df8bae1dSRodney W. Grimes #ifndef HZ
71df8bae1dSRodney W. Grimes #define	HZ 100
72df8bae1dSRodney W. Grimes #endif
73df8bae1dSRodney W. Grimes int	hz = HZ;
74df8bae1dSRodney W. Grimes int	tick = 1000000 / HZ;
75df471779SBruce Evans int	tickadj = howmany(30000, 60 * HZ);	/* can adjust 30ms in 60s */
76df8bae1dSRodney W. Grimes #define	NPROC (20 + 16 * MAXUSERS)
775a00f364SDag-Erling Smørgrav #ifndef MAXFILES
78d3c0af69SGuido van Rooij #define MAXFILES (NPROC*2)
795a00f364SDag-Erling Smørgrav #endif
800d94caffSDavid Greenman int	maxproc = NPROC;			/* maximum # of processes */
81e6373c9eSGuido van Rooij int	maxprocperuid = NPROC-1;		/* maximum # of processes per user */
82d3c0af69SGuido van Rooij int	maxfiles = MAXFILES;			/* system wide open files limit */
83d3c0af69SGuido van Rooij int	maxfilesperproc = MAXFILES;		/* per-process open files limit */
84d3c0af69SGuido van Rooij int	ncallout = 16 + NPROC + MAXFILES;	/* maximum # of timer events */
85cddc961aSDavid Greenman 
86cddc961aSDavid Greenman /* maximum # of mbuf clusters */
87cddc961aSDavid Greenman #ifndef NMBCLUSTERS
88cb7545a9SGarrett Wollman #define	NMBCLUSTERS (512 + MAXUSERS * 16)
89cddc961aSDavid Greenman #endif
90cb7545a9SGarrett Wollman int	nmbclusters = NMBCLUSTERS;
91cb7545a9SGarrett Wollman 
9298271db4SGarrett Wollman #if MAXFILES > NMBCLUSTERS
9398271db4SGarrett Wollman #define	MAXSOCKETS MAXFILES
9498271db4SGarrett Wollman #else
9598271db4SGarrett Wollman #define	MAXSOCKETS NMBCLUSTERS
9698271db4SGarrett Wollman #endif
9798271db4SGarrett Wollman int	maxsockets = MAXSOCKETS;
9898271db4SGarrett Wollman 
99649c409dSDavid Greenman /* allocate 1/4th amount of virtual address space for mbufs XXX */
100649c409dSDavid Greenman int	nmbufs = NMBCLUSTERS * 4;
101cddc961aSDavid Greenman 
102dd0b2081SDavid Greenman /* maximum # of sf_bufs (sendfile(2) zero-copy virtual buffers) */
103dd0b2081SDavid Greenman #ifndef NSFBUFS
104dd0b2081SDavid Greenman #define	NSFBUFS (512 + MAXUSERS * 16)
105dd0b2081SDavid Greenman #endif
106dd0b2081SDavid Greenman int	nsfbufs = NSFBUFS;
107dd0b2081SDavid Greenman 
108df8bae1dSRodney W. Grimes /*
109df8bae1dSRodney W. Grimes  * Values in support of System V compatible shared memory.	XXX
110df8bae1dSRodney W. Grimes  */
111df8bae1dSRodney W. Grimes #ifdef SYSVSHM
1123ab1adc5SJoerg Wunsch #ifndef SHMMAX
113f8845af0SPoul-Henning Kamp #define	SHMMAX	(SHMMAXPGS*PAGE_SIZE)
1143ab1adc5SJoerg Wunsch #endif
1153ab1adc5SJoerg Wunsch #ifndef SHMMIN
116df8bae1dSRodney W. Grimes #define	SHMMIN	1
1173ab1adc5SJoerg Wunsch #endif
1183ab1adc5SJoerg Wunsch #ifndef SHMMNI
119df8bae1dSRodney W. Grimes #define	SHMMNI	32			/* <= SHMMMNI in shm.h */
1203ab1adc5SJoerg Wunsch #endif
1213ab1adc5SJoerg Wunsch #ifndef SHMSEG
122df8bae1dSRodney W. Grimes #define	SHMSEG	8
1233ab1adc5SJoerg Wunsch #endif
1243ab1adc5SJoerg Wunsch #ifndef SHMALL
125e911eafcSPoul-Henning Kamp #define	SHMALL	(SHMMAXPGS)
1263ab1adc5SJoerg Wunsch #endif
127df8bae1dSRodney W. Grimes 
128df8bae1dSRodney W. Grimes struct	shminfo shminfo = {
129df8bae1dSRodney W. Grimes 	SHMMAX,
130df8bae1dSRodney W. Grimes 	SHMMIN,
131df8bae1dSRodney W. Grimes 	SHMMNI,
132df8bae1dSRodney W. Grimes 	SHMSEG,
133df8bae1dSRodney W. Grimes 	SHMALL
134df8bae1dSRodney W. Grimes };
135df8bae1dSRodney W. Grimes #endif
136df8bae1dSRodney W. Grimes 
137df8bae1dSRodney W. Grimes /*
1383d903220SDoug Rabson  * Values in support of System V compatible semaphores.
1393d903220SDoug Rabson  */
1403d903220SDoug Rabson 
1413d903220SDoug Rabson #ifdef SYSVSEM
1423d903220SDoug Rabson 
1433d903220SDoug Rabson struct seminfo seminfo = {
1443d903220SDoug Rabson                 SEMMAP,         /* # of entries in semaphore map */
1453d903220SDoug Rabson                 SEMMNI,         /* # of semaphore identifiers */
1463d903220SDoug Rabson                 SEMMNS,         /* # of semaphores in system */
1473d903220SDoug Rabson                 SEMMNU,         /* # of undo structures in system */
1483d903220SDoug Rabson                 SEMMSL,         /* max # of semaphores per id */
1493d903220SDoug Rabson                 SEMOPM,         /* max # of operations per semop call */
1503d903220SDoug Rabson                 SEMUME,         /* max # of undo entries per process */
1513d903220SDoug Rabson                 SEMUSZ,         /* size in bytes of undo structure */
1523d903220SDoug Rabson                 SEMVMX,         /* semaphore maximum value */
1533d903220SDoug Rabson                 SEMAEM          /* adjust on exit max value */
1543d903220SDoug Rabson };
1553d903220SDoug Rabson #endif
1563d903220SDoug Rabson 
1573d903220SDoug Rabson /*
1583d903220SDoug Rabson  * Values in support of System V compatible messages.
1593d903220SDoug Rabson  */
1603d903220SDoug Rabson 
1613d903220SDoug Rabson #ifdef SYSVMSG
1623d903220SDoug Rabson 
1633d903220SDoug Rabson struct msginfo msginfo = {
1643d903220SDoug Rabson                 MSGMAX,         /* max chars in a message */
1653d903220SDoug Rabson                 MSGMNI,         /* # of message queue identifiers */
1663d903220SDoug Rabson                 MSGMNB,         /* max chars in a queue */
1673d903220SDoug Rabson                 MSGTQL,         /* max messages in system */
1683d903220SDoug Rabson                 MSGSSZ,         /* size of a message segment */
1693d903220SDoug Rabson                 		/* (must be small power of 2 greater than 4) */
1703d903220SDoug Rabson                 MSGSEG          /* number of message segments */
1713d903220SDoug Rabson };
1723d903220SDoug Rabson #endif
1733d903220SDoug Rabson 
1743d903220SDoug Rabson /*
17528f8db14SBruce Evans  * These may be set to nonzero here or by patching.
17628f8db14SBruce Evans  * If they are nonzero at bootstrap time then they are
17728f8db14SBruce Evans  * initialized to values dependent on the memory size.
178df8bae1dSRodney W. Grimes  */
17928f8db14SBruce Evans #ifdef	NBUF
18028f8db14SBruce Evans int	nbuf = NBUF;
18128f8db14SBruce Evans #else
18228f8db14SBruce Evans int	nbuf = 0;
18328f8db14SBruce Evans #endif
18428f8db14SBruce Evans int	nswbuf = 0;
185df8bae1dSRodney W. Grimes 
186df8bae1dSRodney W. Grimes /*
187df8bae1dSRodney W. Grimes  * These have to be allocated somewhere; allocating
188df8bae1dSRodney W. Grimes  * them here forces loader errors if this file is omitted
189df8bae1dSRodney W. Grimes  * (if they've been externed everywhere else; hah!).
190df8bae1dSRodney W. Grimes  */
19128f8db14SBruce Evans struct	buf *swbuf;
192