2005-01-06 23:35:40 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1980, 1986, 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
* (c) UNIX System Laboratories, Inc.
|
|
|
|
* All or some portions of this file are derived from material licensed
|
|
|
|
* to the University of California by American Telephone and Telegraph
|
|
|
|
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
|
|
|
|
* the permission of UNIX System Laboratories, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1996-03-11 05:52:50 +00:00
|
|
|
* @(#)param.c 8.3 (Berkeley) 8/20/94
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
2003-06-11 00:56:59 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1996-03-02 18:24:13 +00:00
|
|
|
#include "opt_param.h"
|
2001-07-26 23:04:03 +00:00
|
|
|
#include "opt_maxusers.h"
|
1996-01-04 20:29:06 +00:00
|
|
|
|
2010-01-12 07:49:34 +00:00
|
|
|
#include <sys/limits.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
2001-07-26 23:04:03 +00:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2007-10-16 10:40:53 +00:00
|
|
|
#include <sys/sysctl.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2004-11-08 18:20:02 +00:00
|
|
|
#include <vm/vm_param.h>
|
2001-10-10 23:06:54 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* System parameter formulae.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HZ
|
2005-04-16 15:07:41 +00:00
|
|
|
# if defined(__amd64__) || defined(__i386__) || defined(__ia64__) || defined(__sparc64__)
|
2004-11-06 11:33:43 +00:00
|
|
|
# define HZ 1000
|
|
|
|
# else
|
|
|
|
# define HZ 100
|
2004-11-30 03:23:35 +00:00
|
|
|
# endif
|
2008-10-27 06:25:02 +00:00
|
|
|
# ifndef HZ_VM
|
2009-07-08 01:09:12 +00:00
|
|
|
# define HZ_VM 100
|
2008-10-27 06:25:02 +00:00
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# ifndef HZ_VM
|
|
|
|
# define HZ_VM HZ
|
|
|
|
# endif
|
2004-03-14 05:49:31 +00:00
|
|
|
#endif
|
2001-07-26 23:04:03 +00:00
|
|
|
#define NPROC (20 + 16 * maxusers)
|
|
|
|
#ifndef NBUF
|
|
|
|
#define NBUF 0
|
|
|
|
#endif
|
1999-04-09 16:28:11 +00:00
|
|
|
#ifndef MAXFILES
|
2001-07-26 23:04:03 +00:00
|
|
|
#define MAXFILES (maxproc * 2)
|
1999-04-09 16:28:11 +00:00
|
|
|
#endif
|
1998-11-05 14:28:26 +00:00
|
|
|
|
2008-12-18 15:34:38 +00:00
|
|
|
static int sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS);
|
|
|
|
|
2001-07-26 23:04:03 +00:00
|
|
|
int hz;
|
|
|
|
int tick;
|
|
|
|
int maxusers; /* base tunable */
|
|
|
|
int maxproc; /* maximum # of processes */
|
|
|
|
int maxprocperuid; /* max # of procs per user */
|
|
|
|
int maxfiles; /* sys. wide open files limit */
|
|
|
|
int maxfilesperproc; /* per-proc open files limit */
|
|
|
|
int ncallout; /* maximum # of timer events */
|
|
|
|
int nbuf;
|
2010-01-12 07:49:34 +00:00
|
|
|
int ngroups_max; /* max # groups per process */
|
2001-07-26 23:04:03 +00:00
|
|
|
int nswbuf;
|
Adjust some variables (mostly related to the buffer cache) that hold
address space sizes to be longs instead of ints. Specifically, the follow
values are now longs: runningbufspace, bufspace, maxbufspace,
bufmallocspace, maxbufmallocspace, lobufspace, hibufspace, lorunningspace,
hirunningspace, maxswzone, maxbcache, and maxpipekva. Previously, a
relatively small number (~ 44000) of buffers set in kern.nbuf would result
in integer overflows resulting either in hangs or bogus values of
hidirtybuffers and lodirtybuffers. Now one has to overflow a long to see
such problems. There was a check for a nbuf setting that would cause
overflows in the auto-tuning of nbuf. I've changed it to always check and
cap nbuf but warn if a user-supplied tunable would cause overflow.
Note that this changes the ABI of several sysctls that are used by things
like top(1), etc., so any MFC would probably require a some gross shims
to allow for that.
MFC after: 1 month
2009-03-09 19:35:20 +00:00
|
|
|
long maxswzone; /* max swmeta KVA storage */
|
|
|
|
long maxbcache; /* max buffer cache KVA storage */
|
2009-03-10 21:28:43 +00:00
|
|
|
long maxpipekva; /* Limit on pipe KVA */
|
2008-12-18 15:34:38 +00:00
|
|
|
int vm_guest; /* Running as virtual machine guest? */
|
2004-11-08 18:20:02 +00:00
|
|
|
u_long maxtsiz; /* max text size */
|
|
|
|
u_long dfldsiz; /* initial data size limit */
|
|
|
|
u_long maxdsiz; /* max data size */
|
|
|
|
u_long dflssiz; /* initial stack size limit */
|
|
|
|
u_long maxssiz; /* max stack size */
|
|
|
|
u_long sgrowsiz; /* amount to grow stack */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2009-03-23 20:18:06 +00:00
|
|
|
SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN, &hz, 0,
|
|
|
|
"Number of clock ticks per second");
|
2009-03-12 17:21:58 +00:00
|
|
|
SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN, &ncallout, 0,
|
|
|
|
"Number of pre-allocated timer events");
|
|
|
|
SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN, &nbuf, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Number of buffers in the buffer cache");
|
2009-03-12 17:21:58 +00:00
|
|
|
SYSCTL_INT(_kern, OID_AUTO, nswbuf, CTLFLAG_RDTUN, &nswbuf, 0,
|
|
|
|
"Number of swap buffers");
|
2009-03-12 17:23:02 +00:00
|
|
|
SYSCTL_LONG(_kern, OID_AUTO, maxswzone, CTLFLAG_RDTUN, &maxswzone, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Maximum memory for swap metadata");
|
2009-03-12 17:23:02 +00:00
|
|
|
SYSCTL_LONG(_kern, OID_AUTO, maxbcache, CTLFLAG_RDTUN, &maxbcache, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Maximum value of vfs.maxbufspace");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, maxtsiz, CTLFLAG_RDTUN, &maxtsiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Maximum text size");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, dfldsiz, CTLFLAG_RDTUN, &dfldsiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Initial data size limit");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, maxdsiz, CTLFLAG_RDTUN, &maxdsiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Maximum data size");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, dflssiz, CTLFLAG_RDTUN, &dflssiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Initial stack size limit");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, maxssiz, CTLFLAG_RDTUN, &maxssiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Maximum stack size");
|
2008-05-09 07:42:02 +00:00
|
|
|
SYSCTL_ULONG(_kern, OID_AUTO, sgrowsiz, CTLFLAG_RDTUN, &sgrowsiz, 0,
|
2009-03-23 20:18:06 +00:00
|
|
|
"Amount to grow stack on a stack fault");
|
2008-12-18 15:34:38 +00:00
|
|
|
SYSCTL_PROC(_kern, OID_AUTO, vm_guest, CTLFLAG_RD | CTLTYPE_STRING,
|
|
|
|
NULL, 0, sysctl_kern_vm_guest, "A",
|
2010-03-02 23:57:42 +00:00
|
|
|
"Virtual machine guest detected? (none|generic|xen)");
|
2007-10-16 10:40:53 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* These have to be allocated somewhere; allocating
|
|
|
|
* them here forces loader errors if this file is omitted
|
|
|
|
* (if they've been externed everywhere else; hah!).
|
|
|
|
*/
|
1995-07-29 11:44:31 +00:00
|
|
|
struct buf *swbuf;
|
2000-10-12 22:37:28 +00:00
|
|
|
|
2010-02-27 18:00:57 +00:00
|
|
|
/*
|
|
|
|
* The elements of this array are ordered based upon the values of the
|
|
|
|
* corresponding enum VM_GUEST members.
|
|
|
|
*/
|
2008-12-27 17:19:16 +00:00
|
|
|
static const char *const vm_guest_sysctl_names[] = {
|
|
|
|
"none",
|
|
|
|
"generic",
|
|
|
|
"xen",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef XEN
|
2008-12-08 18:39:59 +00:00
|
|
|
static const char *const vm_bnames[] = {
|
|
|
|
"QEMU", /* QEMU */
|
|
|
|
"Plex86", /* Plex86 */
|
|
|
|
"Bochs", /* Bochs */
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-10-27 08:09:05 +00:00
|
|
|
static const char *const vm_pnames[] = {
|
2008-10-27 06:25:02 +00:00
|
|
|
"VMware Virtual Platform", /* VMWare VM */
|
|
|
|
"Virtual Machine", /* Microsoft VirtualPC */
|
|
|
|
"VirtualBox", /* Sun xVM VirtualBox */
|
|
|
|
"Parallels Virtual Platform", /* Parallels VM */
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-12-18 15:34:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Detect known Virtual Machine hosts by inspecting the emulated BIOS.
|
|
|
|
*/
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
static enum VM_GUEST
|
2008-10-27 06:25:02 +00:00
|
|
|
detect_virtual(void)
|
|
|
|
{
|
|
|
|
char *sysenv;
|
|
|
|
int i;
|
|
|
|
|
2008-12-08 18:39:59 +00:00
|
|
|
sysenv = getenv("smbios.bios.vendor");
|
|
|
|
if (sysenv != NULL) {
|
|
|
|
for (i = 0; vm_bnames[i] != NULL; i++)
|
|
|
|
if (strcmp(sysenv, vm_bnames[i]) == 0) {
|
|
|
|
freeenv(sysenv);
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
return (VM_GUEST_VM);
|
2008-12-08 18:39:59 +00:00
|
|
|
}
|
|
|
|
freeenv(sysenv);
|
|
|
|
}
|
2008-10-27 06:25:02 +00:00
|
|
|
sysenv = getenv("smbios.system.product");
|
|
|
|
if (sysenv != NULL) {
|
2008-12-08 18:39:59 +00:00
|
|
|
for (i = 0; vm_pnames[i] != NULL; i++)
|
|
|
|
if (strcmp(sysenv, vm_pnames[i]) == 0) {
|
|
|
|
freeenv(sysenv);
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
return (VM_GUEST_VM);
|
2008-12-08 18:39:59 +00:00
|
|
|
}
|
|
|
|
freeenv(sysenv);
|
2008-10-27 06:25:02 +00:00
|
|
|
}
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
return (VM_GUEST_NO);
|
2008-10-27 06:25:02 +00:00
|
|
|
}
|
2008-12-27 17:19:16 +00:00
|
|
|
#endif
|
2008-10-27 06:25:02 +00:00
|
|
|
|
2001-07-26 23:04:03 +00:00
|
|
|
/*
|
2001-12-09 01:57:09 +00:00
|
|
|
* Boot time overrides that are not scaled against main memory
|
2001-07-26 23:04:03 +00:00
|
|
|
*/
|
|
|
|
void
|
2001-12-09 01:57:09 +00:00
|
|
|
init_param1(void)
|
2001-07-26 23:04:03 +00:00
|
|
|
{
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
#ifndef XEN
|
|
|
|
vm_guest = detect_virtual();
|
|
|
|
#else
|
|
|
|
vm_guest = VM_GUEST_XEN;
|
|
|
|
#endif
|
2008-10-27 06:25:02 +00:00
|
|
|
hz = -1;
|
2001-07-26 23:04:03 +00:00
|
|
|
TUNABLE_INT_FETCH("kern.hz", &hz);
|
2008-12-08 18:39:59 +00:00
|
|
|
if (hz == -1)
|
Introduce a sysctl kern.vm_guest that reflects what the kernel knows about
it running under a virtual environment. This also introduces a globally
accessible variable vm_guest that can be used where appropriate in the
kernel to inspect this environment.
To make it easier for the long run, an enum VM_GUEST is also introduced,
which could possibly be factored out in a header somewhere (but the
question is where - vm/vm_param.h? sys/param.h?) so it eventually becomes
a part of the standard KPI. In any case, it's a start.
The purpose of all this isn't to absolutely detect that the OS is running
under a virtual environment (cf. "redpill") but to allow the parts of the
kernel and the userland that care about this particular aspect and can do
something useful depending on it to have a standardised interface. Reducing
kern.hz is one example but there are other things that could be done like
avoiding context switches, not using CPU instructions that are known to be
slow in emulation, possibly different strategies in VM (memory) allocation,
CPU scheduling, etc.
It isn't clear if the JAILS/VIMAGE functionality should also be exposed
by this particular mechanism (probably not since they're not "full"
virtual hardware environments). Sometime in the future another sysctl and
a variable could be introduced to reflect if the kernel supports any kind
of virtual hosting (e.g. VMWare VMI, Xen dom0).
Reviewed by: silence from src-commiters@, virtualization@, kmacy@
Approved by: gnn (mentor)
Security: Obscurity doesn't help.
2008-12-17 19:57:12 +00:00
|
|
|
hz = vm_guest > VM_GUEST_NO ? HZ_VM : HZ;
|
2001-07-26 23:04:03 +00:00
|
|
|
tick = 1000000 / hz;
|
|
|
|
|
2001-08-20 16:29:13 +00:00
|
|
|
#ifdef VM_SWZONE_SIZE_MAX
|
2001-08-20 00:41:12 +00:00
|
|
|
maxswzone = VM_SWZONE_SIZE_MAX;
|
2001-08-20 16:29:13 +00:00
|
|
|
#endif
|
Adjust some variables (mostly related to the buffer cache) that hold
address space sizes to be longs instead of ints. Specifically, the follow
values are now longs: runningbufspace, bufspace, maxbufspace,
bufmallocspace, maxbufmallocspace, lobufspace, hibufspace, lorunningspace,
hirunningspace, maxswzone, maxbcache, and maxpipekva. Previously, a
relatively small number (~ 44000) of buffers set in kern.nbuf would result
in integer overflows resulting either in hangs or bogus values of
hidirtybuffers and lodirtybuffers. Now one has to overflow a long to see
such problems. There was a check for a nbuf setting that would cause
overflows in the auto-tuning of nbuf. I've changed it to always check and
cap nbuf but warn if a user-supplied tunable would cause overflow.
Note that this changes the ABI of several sysctls that are used by things
like top(1), etc., so any MFC would probably require a some gross shims
to allow for that.
MFC after: 1 month
2009-03-09 19:35:20 +00:00
|
|
|
TUNABLE_LONG_FETCH("kern.maxswzone", &maxswzone);
|
2001-08-20 16:29:13 +00:00
|
|
|
#ifdef VM_BCACHE_SIZE_MAX
|
2001-08-20 00:41:12 +00:00
|
|
|
maxbcache = VM_BCACHE_SIZE_MAX;
|
2001-08-20 16:29:13 +00:00
|
|
|
#endif
|
Adjust some variables (mostly related to the buffer cache) that hold
address space sizes to be longs instead of ints. Specifically, the follow
values are now longs: runningbufspace, bufspace, maxbufspace,
bufmallocspace, maxbufmallocspace, lobufspace, hibufspace, lorunningspace,
hirunningspace, maxswzone, maxbcache, and maxpipekva. Previously, a
relatively small number (~ 44000) of buffers set in kern.nbuf would result
in integer overflows resulting either in hangs or bogus values of
hidirtybuffers and lodirtybuffers. Now one has to overflow a long to see
such problems. There was a check for a nbuf setting that would cause
overflows in the auto-tuning of nbuf. I've changed it to always check and
cap nbuf but warn if a user-supplied tunable would cause overflow.
Note that this changes the ABI of several sysctls that are used by things
like top(1), etc., so any MFC would probably require a some gross shims
to allow for that.
MFC after: 1 month
2009-03-09 19:35:20 +00:00
|
|
|
TUNABLE_LONG_FETCH("kern.maxbcache", &maxbcache);
|
2001-10-10 23:06:54 +00:00
|
|
|
|
|
|
|
maxtsiz = MAXTSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.maxtsiz", &maxtsiz);
|
2001-10-10 23:06:54 +00:00
|
|
|
dfldsiz = DFLDSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.dfldsiz", &dfldsiz);
|
2001-10-10 23:06:54 +00:00
|
|
|
maxdsiz = MAXDSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.maxdsiz", &maxdsiz);
|
2001-10-10 23:06:54 +00:00
|
|
|
dflssiz = DFLSSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.dflssiz", &dflssiz);
|
2001-10-10 23:06:54 +00:00
|
|
|
maxssiz = MAXSSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.maxssiz", &maxssiz);
|
2001-10-10 23:06:54 +00:00
|
|
|
sgrowsiz = SGROWSIZ;
|
2004-11-08 18:20:02 +00:00
|
|
|
TUNABLE_ULONG_FETCH("kern.sgrowsiz", &sgrowsiz);
|
2010-01-12 07:49:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Let the administrator set {NGROUPS_MAX}, but disallow values
|
|
|
|
* less than NGROUPS_MAX which would violate POSIX.1-2008 or
|
|
|
|
* greater than INT_MAX-1 which would result in overflow.
|
|
|
|
*/
|
|
|
|
ngroups_max = NGROUPS_MAX;
|
|
|
|
TUNABLE_INT_FETCH("kern.ngroups", &ngroups_max);
|
|
|
|
if (ngroups_max < NGROUPS_MAX)
|
|
|
|
ngroups_max = NGROUPS_MAX;
|
2001-07-26 23:04:03 +00:00
|
|
|
}
|
2001-12-09 01:57:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Boot time overrides that are scaled against main memory
|
|
|
|
*/
|
|
|
|
void
|
2002-08-30 04:04:37 +00:00
|
|
|
init_param2(long physpages)
|
2001-12-09 01:57:09 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* Base parameters */
|
2002-02-06 01:19:19 +00:00
|
|
|
maxusers = MAXUSERS;
|
|
|
|
TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
|
|
|
|
if (maxusers == 0) {
|
2002-01-25 01:54:16 +00:00
|
|
|
maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
|
2001-12-09 01:57:09 +00:00
|
|
|
if (maxusers < 32)
|
|
|
|
maxusers = 32;
|
2002-01-25 01:54:16 +00:00
|
|
|
if (maxusers > 384)
|
|
|
|
maxusers = 384;
|
2001-12-09 01:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following can be overridden after boot via sysctl. Note:
|
|
|
|
* unless overriden, these macros are ultimately based on maxusers.
|
|
|
|
*/
|
|
|
|
maxproc = NPROC;
|
|
|
|
TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
|
2002-03-07 04:50:36 +00:00
|
|
|
/*
|
|
|
|
* Limit maxproc so that kmap entries cannot be exhausted by
|
|
|
|
* processes.
|
|
|
|
*/
|
|
|
|
if (maxproc > (physpages / 12))
|
|
|
|
maxproc = physpages / 12;
|
2001-12-09 01:57:09 +00:00
|
|
|
maxfiles = MAXFILES;
|
|
|
|
TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
|
2001-12-13 20:00:45 +00:00
|
|
|
maxprocperuid = (maxproc * 9) / 10;
|
|
|
|
maxfilesperproc = (maxfiles * 9) / 10;
|
2003-07-11 00:01:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cannot be changed after boot.
|
|
|
|
*/
|
|
|
|
nbuf = NBUF;
|
|
|
|
TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
|
|
|
|
|
|
|
|
ncallout = 16 + maxproc + maxfiles;
|
|
|
|
TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
|
|
|
|
}
|
2001-12-09 01:57:09 +00:00
|
|
|
|
2003-07-11 00:01:03 +00:00
|
|
|
/*
|
2008-07-04 19:36:58 +00:00
|
|
|
* Boot time overrides that are scaled against the kmem map
|
2003-07-11 00:01:03 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
init_param3(long kmempages)
|
|
|
|
{
|
2004-03-30 08:00:11 +00:00
|
|
|
|
2003-07-08 04:02:31 +00:00
|
|
|
/*
|
2008-07-04 19:36:58 +00:00
|
|
|
* The default for maxpipekva is max(5% of the kmem map, 512KB).
|
2004-03-30 08:00:11 +00:00
|
|
|
* See sys_pipe.c for more details.
|
2003-07-08 04:02:31 +00:00
|
|
|
*/
|
2003-08-11 05:51:51 +00:00
|
|
|
maxpipekva = (kmempages / 20) * PAGE_SIZE;
|
2003-07-08 04:02:31 +00:00
|
|
|
if (maxpipekva < 512 * 1024)
|
|
|
|
maxpipekva = 512 * 1024;
|
2009-03-10 21:28:43 +00:00
|
|
|
TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
|
2001-12-09 01:57:09 +00:00
|
|
|
}
|
2008-12-18 15:34:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sysctl stringiying handler for kern.vm_guest.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sysctl_kern_vm_guest(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
|
|
|
return (SYSCTL_OUT(req, vm_guest_sysctl_names[vm_guest],
|
|
|
|
strlen(vm_guest_sysctl_names[vm_guest])));
|
|
|
|
}
|