1/*-
2 * Copyright (c) 1980, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 21 unchanged lines hidden (view full) ---
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)param.c 8.3 (Berkeley) 8/20/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/subr_param.c 245469 2013-01-15 19:26:17Z alfred $");
39
40#include "opt_param.h"
41#include "opt_msgbuf.h"
42#include "opt_maxusers.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>
--- 41 unchanged lines hidden (view full) ---
88int maxprocperuid; /* max # of procs per user */
89int maxfiles; /* sys. wide open files limit */
90int maxfilesperproc; /* per-proc open files limit */
91int msgbufsize; /* size of kernel message buffer */
92int ncallout; /* maximum # of timer events */
93int nbuf;
94int ngroups_max; /* max # groups per process */
95int nswbuf;
96quad_t maxmbufmem; /* max mbuf memory */
97pid_t pid_max = PID_MAX;
98long maxswzone; /* max swmeta KVA storage */
99long maxbcache; /* max buffer cache KVA storage */
100long maxpipekva; /* Limit on pipe KVA */
101int vm_guest; /* Running as virtual machine guest? */
102u_long maxtsiz; /* max text size */
103u_long dfldsiz; /* initial data size limit */
104u_long maxdsiz; /* max data size */
--- 164 unchanged lines hidden (view full) ---
269}
270
271/*
272 * Boot time overrides that are scaled against main memory
273 */
274void
275init_param2(long physpages)
276{
277 quad_t realmem;
278
279 /* Base parameters */
280 maxusers = MAXUSERS;
281 TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
282 if (maxusers == 0) {
283 maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
284 if (maxusers < 32)
285 maxusers = 32;
--- 43 unchanged lines hidden (view full) ---
329 *
330 * Clip callout to result of previous function of maxusers maximum
331 * 384. This is still huge, but acceptable.
332 */
333 ncallout = imin(16 + maxproc + maxfiles, 18508);
334 TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
335
336 /*
337 * The default limit for all mbuf related memory is 1/2 of all
338 * available kernel memory (physical or kmem).
339 * At most it can be 3/4 of available kernel memory.
340 */
341 realmem = qmin((quad_t)physpages * PAGE_SIZE,
342 VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
343 maxmbufmem = realmem / 2;
344 TUNABLE_QUAD_FETCH("kern.maxmbufmem", &maxmbufmem);
345 if (maxmbufmem > (realmem / 4) * 3)
346 maxmbufmem = (realmem / 4) * 3;
347
348 /*
349 * The default for maxpipekva is min(1/64 of the kernel address space,
350 * max(1/64 of main memory, 512KB)). See sys_pipe.c for more details.
351 */
352 maxpipekva = (physpages / 64) * PAGE_SIZE;
353 TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
354 if (maxpipekva < 512 * 1024)
355 maxpipekva = 512 * 1024;
356 if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
--- 13 unchanged lines hidden ---
2 * Copyright (c) 1980, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 21 unchanged lines hidden (view full) ---
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)param.c 8.3 (Berkeley) 8/20/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/subr_param.c 245469 2013-01-15 19:26:17Z alfred $");
39
40#include "opt_param.h"
41#include "opt_msgbuf.h"
42#include "opt_maxusers.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>
--- 41 unchanged lines hidden (view full) ---
88int maxprocperuid; /* max # of procs per user */
89int maxfiles; /* sys. wide open files limit */
90int maxfilesperproc; /* per-proc open files limit */
91int msgbufsize; /* size of kernel message buffer */
92int ncallout; /* maximum # of timer events */
93int nbuf;
94int ngroups_max; /* max # groups per process */
95int nswbuf;
96quad_t maxmbufmem; /* max mbuf memory */
97pid_t pid_max = PID_MAX;
98long maxswzone; /* max swmeta KVA storage */
99long maxbcache; /* max buffer cache KVA storage */
100long maxpipekva; /* Limit on pipe KVA */
101int vm_guest; /* Running as virtual machine guest? */
102u_long maxtsiz; /* max text size */
103u_long dfldsiz; /* initial data size limit */
104u_long maxdsiz; /* max data size */
--- 164 unchanged lines hidden (view full) ---
269}
270
271/*
272 * Boot time overrides that are scaled against main memory
273 */
274void
275init_param2(long physpages)
276{
277 quad_t realmem;
278
279 /* Base parameters */
280 maxusers = MAXUSERS;
281 TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
282 if (maxusers == 0) {
283 maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
284 if (maxusers < 32)
285 maxusers = 32;
--- 43 unchanged lines hidden (view full) ---
329 *
330 * Clip callout to result of previous function of maxusers maximum
331 * 384. This is still huge, but acceptable.
332 */
333 ncallout = imin(16 + maxproc + maxfiles, 18508);
334 TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
335
336 /*
337 * The default limit for all mbuf related memory is 1/2 of all
338 * available kernel memory (physical or kmem).
339 * At most it can be 3/4 of available kernel memory.
340 */
341 realmem = qmin((quad_t)physpages * PAGE_SIZE,
342 VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS);
343 maxmbufmem = realmem / 2;
344 TUNABLE_QUAD_FETCH("kern.maxmbufmem", &maxmbufmem);
345 if (maxmbufmem > (realmem / 4) * 3)
346 maxmbufmem = (realmem / 4) * 3;
347
348 /*
349 * The default for maxpipekva is min(1/64 of the kernel address space,
350 * max(1/64 of main memory, 512KB)). See sys_pipe.c for more details.
351 */
352 maxpipekva = (physpages / 64) * PAGE_SIZE;
353 TUNABLE_LONG_FETCH("kern.ipc.maxpipekva", &maxpipekva);
354 if (maxpipekva < 512 * 1024)
355 maxpipekva = 512 * 1024;
356 if (maxpipekva > (VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 64)
--- 13 unchanged lines hidden ---