xref: /freebsd/sys/kern/subr_param.c (revision 756a5412798b7de1709bb1de2db5ba2a5908cba3)
19454b2d8SWarner Losh /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
4df8bae1dSRodney W. Grimes  * Copyright (c) 1980, 1986, 1989, 1993
5df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
6df8bae1dSRodney W. Grimes  * (c) UNIX System Laboratories, Inc.
7df8bae1dSRodney W. Grimes  * All or some portions of this file are derived from material licensed
8df8bae1dSRodney W. Grimes  * to the University of California by American Telephone and Telegraph
9df8bae1dSRodney W. Grimes  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10df8bae1dSRodney W. Grimes  * the permission of UNIX System Laboratories, Inc.
11df8bae1dSRodney W. Grimes  *
12df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
13df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
14df8bae1dSRodney W. Grimes  * are met:
15df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
16df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
17df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
18df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
19df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
2069a28758SEd Maste  * 3. Neither the name of the University nor the names of its contributors
21df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
22df8bae1dSRodney W. Grimes  *    without specific prior written permission.
23df8bae1dSRodney W. Grimes  *
24df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
35df8bae1dSRodney W. Grimes  *
3670b012caSJeffrey Hsu  *	@(#)param.c	8.3 (Berkeley) 8/20/94
37df8bae1dSRodney W. Grimes  */
38df8bae1dSRodney W. Grimes 
39677b542eSDavid E. O'Brien #include <sys/cdefs.h>
40677b542eSDavid E. O'Brien __FBSDID("$FreeBSD$");
41677b542eSDavid E. O'Brien 
424bd49128SPeter Wemm #include "opt_param.h"
434053b05bSSergey Kandaurov #include "opt_msgbuf.h"
44ee342e1bSPeter Wemm #include "opt_maxusers.h"
4550c73f36SGarrett Wollman 
46df8bae1dSRodney W. Grimes #include <sys/param.h>
47ee342e1bSPeter Wemm #include <sys/systm.h>
48*756a5412SGleb Smirnoff #include <sys/buf.h>
49ee342e1bSPeter Wemm #include <sys/kernel.h>
5002c6fc21SKonstantin Belousov #include <sys/limits.h>
514053b05bSSergey Kandaurov #include <sys/msgbuf.h>
5202c6fc21SKonstantin Belousov #include <sys/sysctl.h>
5302c6fc21SKonstantin Belousov #include <sys/proc.h>
54df8bae1dSRodney W. Grimes 
55e9a3f785SAlan Cox #include <vm/vm.h>
567419d1e2SDag-Erling Smørgrav #include <vm/vm_param.h>
57e9a3f785SAlan Cox #include <vm/pmap.h>
58cbc89bfbSPaul Saab 
59df8bae1dSRodney W. Grimes /*
60df8bae1dSRodney W. Grimes  * System parameter formulae.
61df8bae1dSRodney W. Grimes  */
62df8bae1dSRodney W. Grimes 
63df8bae1dSRodney W. Grimes #ifndef HZ
64bcebf6a1SNathan Whitehorn #  if defined(__mips__) || defined(__arm__)
65df8bae1dSRodney W. Grimes #    define	HZ 100
66bcebf6a1SNathan Whitehorn #  else
67bcebf6a1SNathan Whitehorn #    define	HZ 1000
68df8bae1dSRodney W. Grimes #  endif
697f03c419SMaxim Sobolev #  ifndef HZ_VM
70347e22a6SMike Silbersack #    define	HZ_VM 100
717f03c419SMaxim Sobolev #  endif
727f03c419SMaxim Sobolev #else
737f03c419SMaxim Sobolev #  ifndef HZ_VM
747f03c419SMaxim Sobolev #    define	HZ_VM HZ
757f03c419SMaxim Sobolev #  endif
768f650450SPeter Wemm #endif
77ee342e1bSPeter Wemm #define	NPROC (20 + 16 * maxusers)
78ee342e1bSPeter Wemm #ifndef NBUF
79ee342e1bSPeter Wemm #define NBUF 0
80ee342e1bSPeter Wemm #endif
815a00f364SDag-Erling Smørgrav #ifndef MAXFILES
821f57d8c6SKonstantin Belousov #define	MAXFILES (40 + 32 * maxusers)
835a00f364SDag-Erling Smørgrav #endif
84dd0b2081SDavid Greenman 
853610a226SIvan Voras static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS);
863610a226SIvan Voras 
875b999a6bSDavide Italiano int	hz;				/* system clock's frequency */
885b999a6bSDavide Italiano int	tick;				/* usec per tick (1000000 / hz) */
895b999a6bSDavide Italiano struct bintime tick_bt;			/* bintime per tick (1s / hz) */
905b999a6bSDavide Italiano sbintime_t tick_sbt;
91ee342e1bSPeter Wemm int	maxusers;			/* base tunable */
92ee342e1bSPeter Wemm int	maxproc;			/* maximum # of processes */
93ee342e1bSPeter Wemm int	maxprocperuid;			/* max # of procs per user */
94ee342e1bSPeter Wemm int	maxfiles;			/* sys. wide open files limit */
95ee342e1bSPeter Wemm int	maxfilesperproc;		/* per-proc open files limit */
964053b05bSSergey Kandaurov int	msgbufsize;			/* size of kernel message buffer */
97ee342e1bSPeter Wemm int	nbuf;
98ee75e7deSKonstantin Belousov int	bio_transient_maxcnt;
99412f9500SBrooks Davis int	ngroups_max;			/* max # groups per process */
100ee342e1bSPeter Wemm int	nswbuf;
10102c6fc21SKonstantin Belousov pid_t	pid_max = PID_MAX;
1025bd65606SJohn Baldwin long	maxswzone;			/* max swmeta KVA storage */
1035bd65606SJohn Baldwin long	maxbcache;			/* max buffer cache KVA storage */
10464ecd139SJohn Baldwin long	maxpipekva;			/* Limit on pipe KVA */
10501e1933dSJohn Baldwin int	vm_guest = VM_GUEST_NO;		/* Running as virtual machine guest? */
1067419d1e2SDag-Erling Smørgrav u_long	maxtsiz;			/* max text size */
1077419d1e2SDag-Erling Smørgrav u_long	dfldsiz;			/* initial data size limit */
1087419d1e2SDag-Erling Smørgrav u_long	maxdsiz;			/* max data size */
1097419d1e2SDag-Erling Smørgrav u_long	dflssiz;			/* initial stack size limit */
1107419d1e2SDag-Erling Smørgrav u_long	maxssiz;			/* max stack size */
1117419d1e2SDag-Erling Smørgrav u_long	sgrowsiz;			/* amount to grow stack */
112df8bae1dSRodney W. Grimes 
113af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0,
1149b84ba1cSJohn Baldwin     "Number of clock ticks per second");
115af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0,
1169b84ba1cSJohn Baldwin     "Number of buffers in the buffer cache");
117af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0,
118b9f2a7daSJohn Baldwin     "Number of swap buffers");
119af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &msgbufsize, 0,
1204053b05bSSergey Kandaurov     "Size of the kernel message buffer");
121af3b2549SHans Petter Selasky SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxswzone, 0,
1229b84ba1cSJohn Baldwin     "Maximum memory for swap metadata");
123af3b2549SHans Petter Selasky SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxbcache, 0,
1249b84ba1cSJohn Baldwin     "Maximum value of vfs.maxbufspace");
125af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
126ee75e7deSKonstantin Belousov     &bio_transient_maxcnt, 0,
127ee75e7deSKonstantin Belousov     "Maximum number of transient BIOs mappings");
128af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxtsiz, 0,
1299b84ba1cSJohn Baldwin     "Maximum text size");
130af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dfldsiz, 0,
1319b84ba1cSJohn Baldwin     "Initial data size limit");
132af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxdsiz, 0,
1339b84ba1cSJohn Baldwin     "Maximum data size");
134af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dflssiz, 0,
1359b84ba1cSJohn Baldwin     "Initial stack size limit");
136af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxssiz, 0,
1379b84ba1cSJohn Baldwin     "Maximum stack size");
138af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &sgrowsiz, 0,
139ceb0f715SAndrey Zonov     "Amount to grow stack on a stack fault");
1403610a226SIvan Voras SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING,
1413610a226SIvan Voras     NULL, 0, sysctl_kern_vm_guest, "A",
14201e1933dSJohn Baldwin     "Virtual machine guest detected?");
1437c45a9c4SAlfred Perlstein 
144df8bae1dSRodney W. Grimes /*
1450b993ee5SAlan Cox  * The elements of this array are ordered based upon the values of the
1460b993ee5SAlan Cox  * corresponding enum VM_GUEST members.
1470b993ee5SAlan Cox  */
14834820bbfSBjoern A. Zeeb static const char *const vm_guest_sysctl_names[] = {
14934820bbfSBjoern A. Zeeb 	"none",
15034820bbfSBjoern A. Zeeb 	"generic",
15134820bbfSBjoern A. Zeeb 	"xen",
15240b4cb0fSSergey Kandaurov 	"hv",
15301e1933dSJohn Baldwin 	"vmware",
154fdb6320dSEric Badger 	"kvm",
155e0a6a23cSMarcelo Araujo 	"bhyve",
15634820bbfSBjoern A. Zeeb 	NULL
15734820bbfSBjoern A. Zeeb };
158903093ecSSergey Kandaurov CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);
15934820bbfSBjoern A. Zeeb 
1609722d88fSJason Evans /*
16166a11b9fSMatthew Dillon  * Boot time overrides that are not scaled against main memory
162ee342e1bSPeter Wemm  */
163ee342e1bSPeter Wemm void
16466a11b9fSMatthew Dillon init_param1(void)
165ee342e1bSPeter Wemm {
16601e1933dSJohn Baldwin 
167edc82223SKonstantin Belousov #if !defined(__mips__) && !defined(__arm64__) && !defined(__sparc64__)
168edc82223SKonstantin Belousov 	TUNABLE_INT_FETCH("kern.kstack_pages", &kstack_pages);
169edc82223SKonstantin Belousov #endif
1707f03c419SMaxim Sobolev 	hz = -1;
171ee342e1bSPeter Wemm 	TUNABLE_INT_FETCH("kern.hz", &hz);
1729bd2cbe4SJung-uk Kim 	if (hz == -1)
1733dc30911SIvan Voras 		hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ;
174ee342e1bSPeter Wemm 	tick = 1000000 / hz;
1755b999a6bSDavide Italiano 	tick_sbt = SBT_1S / hz;
1765b999a6bSDavide Italiano 	tick_bt = sbttobt(tick_sbt);
177ee342e1bSPeter Wemm 
1785d8cce17SJohn Baldwin 	/*
1795d8cce17SJohn Baldwin 	 * Arrange for ticks to wrap 10 minutes after boot to help catch
1805d8cce17SJohn Baldwin 	 * sign problems sooner.
1815d8cce17SJohn Baldwin 	 */
1825d8cce17SJohn Baldwin 	ticks = INT_MAX - (hz * 10 * 60);
1835d8cce17SJohn Baldwin 
184e1616f3aSMatthew Dillon #ifdef VM_SWZONE_SIZE_MAX
1852f9e4e80SMatthew Dillon 	maxswzone = VM_SWZONE_SIZE_MAX;
186e1616f3aSMatthew Dillon #endif
1875bd65606SJohn Baldwin 	TUNABLE_LONG_FETCH("kern.maxswzone", &maxswzone);
188e1616f3aSMatthew Dillon #ifdef VM_BCACHE_SIZE_MAX
1892f9e4e80SMatthew Dillon 	maxbcache = VM_BCACHE_SIZE_MAX;
190e1616f3aSMatthew Dillon #endif
1915bd65606SJohn Baldwin 	TUNABLE_LONG_FETCH("kern.maxbcache", &maxbcache);
1924053b05bSSergey Kandaurov 	msgbufsize = MSGBUF_SIZE;
1934053b05bSSergey Kandaurov 	TUNABLE_INT_FETCH("kern.msgbufsize", &msgbufsize);
194cbc89bfbSPaul Saab 
195cbc89bfbSPaul Saab 	maxtsiz = MAXTSIZ;
1967419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxtsiz", &maxtsiz);
197cbc89bfbSPaul Saab 	dfldsiz = DFLDSIZ;
1987419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.dfldsiz", &dfldsiz);
199cbc89bfbSPaul Saab 	maxdsiz = MAXDSIZ;
2007419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxdsiz", &maxdsiz);
201cbc89bfbSPaul Saab 	dflssiz = DFLSSIZ;
2027419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.dflssiz", &dflssiz);
203cbc89bfbSPaul Saab 	maxssiz = MAXSSIZ;
2047419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxssiz", &maxssiz);
205cbc89bfbSPaul Saab 	sgrowsiz = SGROWSIZ;
2067419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.sgrowsiz", &sgrowsiz);
207412f9500SBrooks Davis 
208412f9500SBrooks Davis 	/*
209412f9500SBrooks Davis 	 * Let the administrator set {NGROUPS_MAX}, but disallow values
210412f9500SBrooks Davis 	 * less than NGROUPS_MAX which would violate POSIX.1-2008 or
211412f9500SBrooks Davis 	 * greater than INT_MAX-1 which would result in overflow.
212412f9500SBrooks Davis 	 */
213412f9500SBrooks Davis 	ngroups_max = NGROUPS_MAX;
214412f9500SBrooks Davis 	TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
215412f9500SBrooks Davis 	if (ngroups_max < NGROUPS_MAX)
216412f9500SBrooks Davis 		ngroups_max = NGROUPS_MAX;
21702c6fc21SKonstantin Belousov 
21802c6fc21SKonstantin Belousov 	/*
21902c6fc21SKonstantin Belousov 	 * Only allow to lower the maximal pid.
2203fa615bcSKonstantin Belousov 	 * Prevent setting up a non-bootable system if pid_max is too low.
22102c6fc21SKonstantin Belousov 	 */
22202c6fc21SKonstantin Belousov 	TUNABLE_INT_FETCH("kern.pid_max", &pid_max);
22302c6fc21SKonstantin Belousov 	if (pid_max > PID_MAX)
22402c6fc21SKonstantin Belousov 		pid_max = PID_MAX;
2253fa615bcSKonstantin Belousov 	else if (pid_max < 300)
2263fa615bcSKonstantin Belousov 		pid_max = 300;
227ee75e7deSKonstantin Belousov 
228ee75e7deSKonstantin Belousov 	TUNABLE_INT_FETCH("vfs.unmapped_buf_allowed", &unmapped_buf_allowed);
229ee342e1bSPeter Wemm }
23066a11b9fSMatthew Dillon 
23166a11b9fSMatthew Dillon /*
23266a11b9fSMatthew Dillon  * Boot time overrides that are scaled against main memory
23366a11b9fSMatthew Dillon  */
23466a11b9fSMatthew Dillon void
235447b3772SPeter Wemm init_param2(long physpages)
23666a11b9fSMatthew Dillon {
23766a11b9fSMatthew Dillon 
23866a11b9fSMatthew Dillon 	/* Base parameters */
2390b94a0e9SMatthew Dillon 	maxusers = MAXUSERS;
2400b94a0e9SMatthew Dillon 	TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
2410b94a0e9SMatthew Dillon 	if (maxusers == 0) {
2424fbd563eSMatthew Dillon 		maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
24366a11b9fSMatthew Dillon 		if (maxusers < 32)
24466a11b9fSMatthew Dillon 			maxusers = 32;
24579f62ed6SAlfred Perlstein #ifdef VM_MAX_AUTOTUNE_MAXUSERS
24679f62ed6SAlfred Perlstein                 if (maxusers > VM_MAX_AUTOTUNE_MAXUSERS)
24779f62ed6SAlfred Perlstein                         maxusers = VM_MAX_AUTOTUNE_MAXUSERS;
24879f62ed6SAlfred Perlstein #endif
2497b6d92c0SAlfred Perlstein                 /*
25079f62ed6SAlfred Perlstein                  * Scales down the function in which maxusers grows once
25179f62ed6SAlfred Perlstein                  * we hit 384.
2527b6d92c0SAlfred Perlstein                  */
25379f62ed6SAlfred Perlstein                 if (maxusers > 384)
25479f62ed6SAlfred Perlstein                         maxusers = 384 + ((maxusers - 384) / 8);
25566a11b9fSMatthew Dillon         }
25666a11b9fSMatthew Dillon 
25766a11b9fSMatthew Dillon 	/*
25866a11b9fSMatthew Dillon 	 * The following can be overridden after boot via sysctl.  Note:
25966a11b9fSMatthew Dillon 	 * unless overriden, these macros are ultimately based on maxusers.
26077a7d074SMike Silbersack 	 * Limit maxproc so that kmap entries cannot be exhausted by
26177a7d074SMike Silbersack 	 * processes.
26277a7d074SMike Silbersack 	 */
263ead46972SAndre Oppermann 	maxproc = NPROC;
264ead46972SAndre Oppermann 	TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
26577a7d074SMike Silbersack 	if (maxproc > (physpages / 12))
26677a7d074SMike Silbersack 		maxproc = physpages / 12;
2671f57d8c6SKonstantin Belousov 	if (maxproc > pid_max)
2681f57d8c6SKonstantin Belousov 		maxproc = pid_max;
269ebacce5eSMike Silbersack 	maxprocperuid = (maxproc * 9) / 10;
270ead46972SAndre Oppermann 
271ead46972SAndre Oppermann 	/*
272ead46972SAndre Oppermann 	 * The default limit for maxfiles is 1/12 of the number of
273ead46972SAndre Oppermann 	 * physical page but not less than 16 times maxusers.
274ead46972SAndre Oppermann 	 * At most it can be 1/6 the number of physical pages.
275ead46972SAndre Oppermann 	 */
276ead46972SAndre Oppermann 	maxfiles = imax(MAXFILES, physpages / 8);
277ead46972SAndre Oppermann 	TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
278ead46972SAndre Oppermann 	if (maxfiles > (physpages / 4))
279ead46972SAndre Oppermann 		maxfiles = physpages / 4;
280ead46972SAndre Oppermann 	maxfilesperproc = (maxfiles / 10) * 9;
28132766cd2SAdrian Chadd 	TUNABLE_INT_FETCH("kern.maxfilesperproc", &maxfilesperproc);
28266a11b9fSMatthew Dillon 
28366a11b9fSMatthew Dillon 	/*
284347194c1SMike Silbersack 	 * Cannot be changed after boot.
285347194c1SMike Silbersack 	 */
286347194c1SMike Silbersack 	nbuf = NBUF;
287347194c1SMike Silbersack 	TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
288ee75e7deSKonstantin Belousov 	TUNABLE_INT_FETCH("kern.bio_transient_maxcnt", &bio_transient_maxcnt);
289347194c1SMike Silbersack 
290ead46972SAndre Oppermann 	/*
291*756a5412SGleb Smirnoff 	 * Physical buffers are pre-allocated buffers (struct buf) that
292*756a5412SGleb Smirnoff 	 * are used as temporary holders for I/O, such as paging I/O.
293*756a5412SGleb Smirnoff 	 */
294*756a5412SGleb Smirnoff 	nswbuf = min(nbuf / 4, 256);
295*756a5412SGleb Smirnoff 	TUNABLE_INT_FETCH("kern.nswbuf", &nswbuf);
296*756a5412SGleb Smirnoff 	if (nswbuf < NSWBUF_MIN)
297*756a5412SGleb Smirnoff 		nswbuf = NSWBUF_MIN;
298*756a5412SGleb Smirnoff 
299*756a5412SGleb Smirnoff 	/*
300e9a3f785SAlan Cox 	 * The default for maxpipekva is min(1/64 of the kernel address space,
301e9a3f785SAlan Cox 	 * max(1/64 of main memory, 512KB)).  See sys_pipe.c for more details.
302347194c1SMike Silbersack 	 */
303e9a3f785SAlan Cox 	maxpipekva = (physpages / 64) * PAGE_SIZE;
304ead46972SAndre Oppermann 	TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
305289016f2SMike Silbersack 	if (maxpipekva < 512 * 1024)
306289016f2SMike Silbersack 		maxpipekva = 512 * 1024;
307e9a3f785SAlan Cox 	if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
308e9a3f785SAlan Cox 		maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) /
309e9a3f785SAlan Cox 		    64;
31066a11b9fSMatthew Dillon }
3113610a226SIvan Voras 
3123610a226SIvan Voras /*
31346038d7fSKonstantin Belousov  * Sysctl stringifying handler for kern.vm_guest.
3143610a226SIvan Voras  */
3153610a226SIvan Voras static int
3163610a226SIvan Voras sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS)
3173610a226SIvan Voras {
318acfc962fSIan Lepore 	return (SYSCTL_OUT_STR(req, vm_guest_sysctl_names[vm_guest]));
3193610a226SIvan Voras }
320