xref: /freebsd/sys/kern/subr_param.c (revision acfc962f82ae2a27618c2aa1f9babe9b4ecfcf93)
19454b2d8SWarner Losh /*-
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  * 4. Neither the name of the University nor the names of its contributors
19df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
20df8bae1dSRodney W. Grimes  *    without specific prior written permission.
21df8bae1dSRodney W. Grimes  *
22df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
33df8bae1dSRodney W. Grimes  *
3470b012caSJeffrey Hsu  *	@(#)param.c	8.3 (Berkeley) 8/20/94
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
37677b542eSDavid E. O'Brien #include <sys/cdefs.h>
38677b542eSDavid E. O'Brien __FBSDID("$FreeBSD$");
39677b542eSDavid E. O'Brien 
404bd49128SPeter Wemm #include "opt_param.h"
414053b05bSSergey Kandaurov #include "opt_msgbuf.h"
42ee342e1bSPeter Wemm #include "opt_maxusers.h"
4350c73f36SGarrett Wollman 
44df8bae1dSRodney W. Grimes #include <sys/param.h>
45ee342e1bSPeter Wemm #include <sys/systm.h>
46ee342e1bSPeter Wemm #include <sys/kernel.h>
4702c6fc21SKonstantin Belousov #include <sys/limits.h>
484053b05bSSergey Kandaurov #include <sys/msgbuf.h>
4902c6fc21SKonstantin Belousov #include <sys/sysctl.h>
5002c6fc21SKonstantin Belousov #include <sys/proc.h>
51df8bae1dSRodney W. Grimes 
52e9a3f785SAlan Cox #include <vm/vm.h>
537419d1e2SDag-Erling Smørgrav #include <vm/vm_param.h>
54e9a3f785SAlan Cox #include <vm/pmap.h>
55cbc89bfbSPaul Saab 
56df8bae1dSRodney W. Grimes /*
57df8bae1dSRodney W. Grimes  * System parameter formulae.
58df8bae1dSRodney W. Grimes  */
59df8bae1dSRodney W. Grimes 
60df8bae1dSRodney W. Grimes #ifndef HZ
61bcebf6a1SNathan Whitehorn #  if defined(__mips__) || defined(__arm__)
62df8bae1dSRodney W. Grimes #    define	HZ 100
63bcebf6a1SNathan Whitehorn #  else
64bcebf6a1SNathan Whitehorn #    define	HZ 1000
65df8bae1dSRodney W. Grimes #  endif
667f03c419SMaxim Sobolev #  ifndef HZ_VM
67347e22a6SMike Silbersack #    define	HZ_VM 100
687f03c419SMaxim Sobolev #  endif
697f03c419SMaxim Sobolev #else
707f03c419SMaxim Sobolev #  ifndef HZ_VM
717f03c419SMaxim Sobolev #    define	HZ_VM HZ
727f03c419SMaxim Sobolev #  endif
738f650450SPeter Wemm #endif
74ee342e1bSPeter Wemm #define	NPROC (20 + 16 * maxusers)
75ee342e1bSPeter Wemm #ifndef NBUF
76ee342e1bSPeter Wemm #define NBUF 0
77ee342e1bSPeter Wemm #endif
785a00f364SDag-Erling Smørgrav #ifndef MAXFILES
79ee342e1bSPeter Wemm #define	MAXFILES (maxproc * 2)
805a00f364SDag-Erling Smørgrav #endif
81dd0b2081SDavid Greenman 
823610a226SIvan Voras static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS);
833610a226SIvan Voras 
845b999a6bSDavide Italiano int	hz;				/* system clock's frequency */
855b999a6bSDavide Italiano int	tick;				/* usec per tick (1000000 / hz) */
865b999a6bSDavide Italiano struct bintime tick_bt;			/* bintime per tick (1s / hz) */
875b999a6bSDavide Italiano sbintime_t tick_sbt;
88ee342e1bSPeter Wemm int	maxusers;			/* base tunable */
89ee342e1bSPeter Wemm int	maxproc;			/* maximum # of processes */
90ee342e1bSPeter Wemm int	maxprocperuid;			/* max # of procs per user */
91ee342e1bSPeter Wemm int	maxfiles;			/* sys. wide open files limit */
92ee342e1bSPeter Wemm int	maxfilesperproc;		/* per-proc open files limit */
934053b05bSSergey Kandaurov int	msgbufsize;			/* size of kernel message buffer */
94ee342e1bSPeter Wemm int	nbuf;
95ee75e7deSKonstantin Belousov int	bio_transient_maxcnt;
96412f9500SBrooks Davis int	ngroups_max;			/* max # groups per process */
97ee342e1bSPeter Wemm int	nswbuf;
9802c6fc21SKonstantin Belousov pid_t	pid_max = PID_MAX;
995bd65606SJohn Baldwin long	maxswzone;			/* max swmeta KVA storage */
1005bd65606SJohn Baldwin long	maxbcache;			/* max buffer cache KVA storage */
10164ecd139SJohn Baldwin long	maxpipekva;			/* Limit on pipe KVA */
10201e1933dSJohn Baldwin #ifdef XEN
10301e1933dSJohn Baldwin int	vm_guest = VM_GUEST_XEN;
10401e1933dSJohn Baldwin #else
10501e1933dSJohn Baldwin int	vm_guest = VM_GUEST_NO;		/* Running as virtual machine guest? */
10601e1933dSJohn Baldwin #endif
1077419d1e2SDag-Erling Smørgrav u_long	maxtsiz;			/* max text size */
1087419d1e2SDag-Erling Smørgrav u_long	dfldsiz;			/* initial data size limit */
1097419d1e2SDag-Erling Smørgrav u_long	maxdsiz;			/* max data size */
1107419d1e2SDag-Erling Smørgrav u_long	dflssiz;			/* initial stack size limit */
1117419d1e2SDag-Erling Smørgrav u_long	maxssiz;			/* max stack size */
1127419d1e2SDag-Erling Smørgrav u_long	sgrowsiz;			/* amount to grow stack */
113df8bae1dSRodney W. Grimes 
114af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0,
1159b84ba1cSJohn Baldwin     "Number of clock ticks per second");
116af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0,
1179b84ba1cSJohn Baldwin     "Number of buffers in the buffer cache");
118af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nswbuf, 0,
119b9f2a7daSJohn Baldwin     "Number of swap buffers");
120af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, msgbufsize, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &msgbufsize, 0,
1214053b05bSSergey Kandaurov     "Size of the kernel message buffer");
122af3b2549SHans Petter Selasky SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxswzone, 0,
1239b84ba1cSJohn Baldwin     "Maximum memory for swap metadata");
124af3b2549SHans Petter Selasky SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &maxbcache, 0,
1259b84ba1cSJohn Baldwin     "Maximum value of vfs.maxbufspace");
126af3b2549SHans Petter Selasky SYSCTL_INT(_kern, OID_AUTO, bio_transient_maxcnt, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
127ee75e7deSKonstantin Belousov     &bio_transient_maxcnt, 0,
128ee75e7deSKonstantin Belousov     "Maximum number of transient BIOs mappings");
129af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxtsiz, 0,
1309b84ba1cSJohn Baldwin     "Maximum text size");
131af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dfldsiz, 0,
1329b84ba1cSJohn Baldwin     "Initial data size limit");
133af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxdsiz, 0,
1349b84ba1cSJohn Baldwin     "Maximum data size");
135af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &dflssiz, 0,
1369b84ba1cSJohn Baldwin     "Initial stack size limit");
137af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &maxssiz, 0,
1389b84ba1cSJohn Baldwin     "Maximum stack size");
139af3b2549SHans Petter Selasky SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, &sgrowsiz, 0,
140ceb0f715SAndrey Zonov     "Amount to grow stack on a stack fault");
1413610a226SIvan Voras SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING,
1423610a226SIvan Voras     NULL, 0, sysctl_kern_vm_guest, "A",
14301e1933dSJohn Baldwin     "Virtual machine guest detected?");
1447c45a9c4SAlfred Perlstein 
145df8bae1dSRodney W. Grimes /*
146df8bae1dSRodney W. Grimes  * These have to be allocated somewhere; allocating
147df8bae1dSRodney W. Grimes  * them here forces loader errors if this file is omitted
148df8bae1dSRodney W. Grimes  * (if they've been externed everywhere else; hah!).
149df8bae1dSRodney W. Grimes  */
15028f8db14SBruce Evans struct	buf *swbuf;
1519722d88fSJason Evans 
1520b993ee5SAlan Cox /*
1530b993ee5SAlan Cox  * The elements of this array are ordered based upon the values of the
1540b993ee5SAlan Cox  * corresponding enum VM_GUEST members.
1550b993ee5SAlan Cox  */
15634820bbfSBjoern A. Zeeb static const char *const vm_guest_sysctl_names[] = {
15734820bbfSBjoern A. Zeeb 	"none",
15834820bbfSBjoern A. Zeeb 	"generic",
15934820bbfSBjoern A. Zeeb 	"xen",
16040b4cb0fSSergey Kandaurov 	"hv",
16101e1933dSJohn Baldwin 	"vmware",
16234820bbfSBjoern A. Zeeb 	NULL
16334820bbfSBjoern A. Zeeb };
164903093ecSSergey Kandaurov CTASSERT(nitems(vm_guest_sysctl_names) - 1 == VM_LAST);
16534820bbfSBjoern A. Zeeb 
1669722d88fSJason Evans /*
16766a11b9fSMatthew Dillon  * Boot time overrides that are not scaled against main memory
168ee342e1bSPeter Wemm  */
169ee342e1bSPeter Wemm void
17066a11b9fSMatthew Dillon init_param1(void)
171ee342e1bSPeter Wemm {
17201e1933dSJohn Baldwin 
1737f03c419SMaxim Sobolev 	hz = -1;
174ee342e1bSPeter Wemm 	TUNABLE_INT_FETCH("kern.hz", &hz);
1759bd2cbe4SJung-uk Kim 	if (hz == -1)
1763dc30911SIvan Voras 		hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ;
177ee342e1bSPeter Wemm 	tick = 1000000 / hz;
1785b999a6bSDavide Italiano 	tick_sbt = SBT_1S / hz;
1795b999a6bSDavide Italiano 	tick_bt = sbttobt(tick_sbt);
180ee342e1bSPeter Wemm 
181e1616f3aSMatthew Dillon #ifdef VM_SWZONE_SIZE_MAX
1822f9e4e80SMatthew Dillon 	maxswzone = VM_SWZONE_SIZE_MAX;
183e1616f3aSMatthew Dillon #endif
1845bd65606SJohn Baldwin 	TUNABLE_LONG_FETCH("kern.maxswzone", &maxswzone);
185e1616f3aSMatthew Dillon #ifdef VM_BCACHE_SIZE_MAX
1862f9e4e80SMatthew Dillon 	maxbcache = VM_BCACHE_SIZE_MAX;
187e1616f3aSMatthew Dillon #endif
1885bd65606SJohn Baldwin 	TUNABLE_LONG_FETCH("kern.maxbcache", &maxbcache);
1894053b05bSSergey Kandaurov 	msgbufsize = MSGBUF_SIZE;
1904053b05bSSergey Kandaurov 	TUNABLE_INT_FETCH("kern.msgbufsize", &msgbufsize);
191cbc89bfbSPaul Saab 
192cbc89bfbSPaul Saab 	maxtsiz = MAXTSIZ;
1937419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxtsiz", &maxtsiz);
194cbc89bfbSPaul Saab 	dfldsiz = DFLDSIZ;
1957419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.dfldsiz", &dfldsiz);
196cbc89bfbSPaul Saab 	maxdsiz = MAXDSIZ;
1977419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxdsiz", &maxdsiz);
198cbc89bfbSPaul Saab 	dflssiz = DFLSSIZ;
1997419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.dflssiz", &dflssiz);
200cbc89bfbSPaul Saab 	maxssiz = MAXSSIZ;
2017419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.maxssiz", &maxssiz);
202cbc89bfbSPaul Saab 	sgrowsiz = SGROWSIZ;
2037419d1e2SDag-Erling Smørgrav 	TUNABLE_ULONG_FETCH("kern.sgrowsiz", &sgrowsiz);
204412f9500SBrooks Davis 
205412f9500SBrooks Davis 	/*
206412f9500SBrooks Davis 	 * Let the administrator set {NGROUPS_MAX}, but disallow values
207412f9500SBrooks Davis 	 * less than NGROUPS_MAX which would violate POSIX.1-2008 or
208412f9500SBrooks Davis 	 * greater than INT_MAX-1 which would result in overflow.
209412f9500SBrooks Davis 	 */
210412f9500SBrooks Davis 	ngroups_max = NGROUPS_MAX;
211412f9500SBrooks Davis 	TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
212412f9500SBrooks Davis 	if (ngroups_max < NGROUPS_MAX)
213412f9500SBrooks Davis 		ngroups_max = NGROUPS_MAX;
21402c6fc21SKonstantin Belousov 
21502c6fc21SKonstantin Belousov 	/*
21602c6fc21SKonstantin Belousov 	 * Only allow to lower the maximal pid.
2173fa615bcSKonstantin Belousov 	 * Prevent setting up a non-bootable system if pid_max is too low.
21802c6fc21SKonstantin Belousov 	 */
21902c6fc21SKonstantin Belousov 	TUNABLE_INT_FETCH("kern.pid_max", &pid_max);
22002c6fc21SKonstantin Belousov 	if (pid_max > PID_MAX)
22102c6fc21SKonstantin Belousov 		pid_max = PID_MAX;
2223fa615bcSKonstantin Belousov 	else if (pid_max < 300)
2233fa615bcSKonstantin Belousov 		pid_max = 300;
224ee75e7deSKonstantin Belousov 
225ee75e7deSKonstantin Belousov 	TUNABLE_INT_FETCH("vfs.unmapped_buf_allowed", &unmapped_buf_allowed);
226ee342e1bSPeter Wemm }
22766a11b9fSMatthew Dillon 
22866a11b9fSMatthew Dillon /*
22966a11b9fSMatthew Dillon  * Boot time overrides that are scaled against main memory
23066a11b9fSMatthew Dillon  */
23166a11b9fSMatthew Dillon void
232447b3772SPeter Wemm init_param2(long physpages)
23366a11b9fSMatthew Dillon {
23466a11b9fSMatthew Dillon 
23566a11b9fSMatthew Dillon 	/* Base parameters */
2360b94a0e9SMatthew Dillon 	maxusers = MAXUSERS;
2370b94a0e9SMatthew Dillon 	TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
2380b94a0e9SMatthew Dillon 	if (maxusers == 0) {
2394fbd563eSMatthew Dillon 		maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
24066a11b9fSMatthew Dillon 		if (maxusers < 32)
24166a11b9fSMatthew Dillon 			maxusers = 32;
24279f62ed6SAlfred Perlstein #ifdef VM_MAX_AUTOTUNE_MAXUSERS
24379f62ed6SAlfred Perlstein                 if (maxusers > VM_MAX_AUTOTUNE_MAXUSERS)
24479f62ed6SAlfred Perlstein                         maxusers = VM_MAX_AUTOTUNE_MAXUSERS;
24579f62ed6SAlfred Perlstein #endif
2467b6d92c0SAlfred Perlstein                 /*
24779f62ed6SAlfred Perlstein                  * Scales down the function in which maxusers grows once
24879f62ed6SAlfred Perlstein                  * we hit 384.
2497b6d92c0SAlfred Perlstein                  */
25079f62ed6SAlfred Perlstein                 if (maxusers > 384)
25179f62ed6SAlfred Perlstein                         maxusers = 384 + ((maxusers - 384) / 8);
25266a11b9fSMatthew Dillon         }
25366a11b9fSMatthew Dillon 
25466a11b9fSMatthew Dillon 	/*
25566a11b9fSMatthew Dillon 	 * The following can be overridden after boot via sysctl.  Note:
25666a11b9fSMatthew Dillon 	 * unless overriden, these macros are ultimately based on maxusers.
25777a7d074SMike Silbersack 	 * Limit maxproc so that kmap entries cannot be exhausted by
25877a7d074SMike Silbersack 	 * processes.
25977a7d074SMike Silbersack 	 */
260ead46972SAndre Oppermann 	maxproc = NPROC;
261ead46972SAndre Oppermann 	TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
26277a7d074SMike Silbersack 	if (maxproc > (physpages / 12))
26377a7d074SMike Silbersack 		maxproc = physpages / 12;
264ebacce5eSMike Silbersack 	maxprocperuid = (maxproc * 9) / 10;
265ead46972SAndre Oppermann 
266ead46972SAndre Oppermann 	/*
267ead46972SAndre Oppermann 	 * The default limit for maxfiles is 1/12 of the number of
268ead46972SAndre Oppermann 	 * physical page but not less than 16 times maxusers.
269ead46972SAndre Oppermann 	 * At most it can be 1/6 the number of physical pages.
270ead46972SAndre Oppermann 	 */
271ead46972SAndre Oppermann 	maxfiles = imax(MAXFILES, physpages / 8);
272ead46972SAndre Oppermann 	TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
273ead46972SAndre Oppermann 	if (maxfiles > (physpages / 4))
274ead46972SAndre Oppermann 		maxfiles = physpages / 4;
275ead46972SAndre Oppermann 	maxfilesperproc = (maxfiles / 10) * 9;
27666a11b9fSMatthew Dillon 
27766a11b9fSMatthew Dillon 	/*
278347194c1SMike Silbersack 	 * Cannot be changed after boot.
279347194c1SMike Silbersack 	 */
280347194c1SMike Silbersack 	nbuf = NBUF;
281347194c1SMike Silbersack 	TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
282ee75e7deSKonstantin Belousov 	TUNABLE_INT_FETCH("kern.bio_transient_maxcnt", &bio_transient_maxcnt);
283347194c1SMike Silbersack 
284ead46972SAndre Oppermann 	/*
285e9a3f785SAlan Cox 	 * The default for maxpipekva is min(1/64 of the kernel address space,
286e9a3f785SAlan Cox 	 * max(1/64 of main memory, 512KB)).  See sys_pipe.c for more details.
287347194c1SMike Silbersack 	 */
288e9a3f785SAlan Cox 	maxpipekva = (physpages / 64) * PAGE_SIZE;
289ead46972SAndre Oppermann 	TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
290289016f2SMike Silbersack 	if (maxpipekva < 512 * 1024)
291289016f2SMike Silbersack 		maxpipekva = 512 * 1024;
292e9a3f785SAlan Cox 	if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
293e9a3f785SAlan Cox 		maxpipekva = (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) /
294e9a3f785SAlan Cox 		    64;
29566a11b9fSMatthew Dillon }
2963610a226SIvan Voras 
2973610a226SIvan Voras /*
29846038d7fSKonstantin Belousov  * Sysctl stringifying handler for kern.vm_guest.
2993610a226SIvan Voras  */
3003610a226SIvan Voras static int
3013610a226SIvan Voras sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS)
3023610a226SIvan Voras {
303*acfc962fSIan Lepore 	return (SYSCTL_OUT_STR(req, vm_guest_sysctl_names[vm_guest]));
3043610a226SIvan Voras }
305