subr_param.c (f28600390922dfcf1ccbe51a2c560b5f6cefa961) subr_param.c (66a11b9fb1208a4c4e0cdc76ace84334b70d5ab1)
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.

--- 77 unchanged lines hidden (view full) ---

86/*
87 * These have to be allocated somewhere; allocating
88 * them here forces loader errors if this file is omitted
89 * (if they've been externed everywhere else; hah!).
90 */
91struct buf *swbuf;
92
93/*
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.

--- 77 unchanged lines hidden (view full) ---

86/*
87 * These have to be allocated somewhere; allocating
88 * them here forces loader errors if this file is omitted
89 * (if they've been externed everywhere else; hah!).
90 */
91struct buf *swbuf;
92
93/*
94 * Boot time overrides
94 * Boot time overrides that are not scaled against main memory
95 */
96void
95 */
96void
97init_param(void)
97init_param1(void)
98{
99
98{
99
100 /* Base parameters */
101 maxusers = MAXUSERS;
102 TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
103 hz = HZ;
104 TUNABLE_INT_FETCH("kern.hz", &hz);
105 tick = 1000000 / hz;
106 tickadj = howmany(30000, 60 * hz); /* can adjust 30ms in 60s */
107
100 hz = HZ;
101 TUNABLE_INT_FETCH("kern.hz", &hz);
102 tick = 1000000 / hz;
103 tickadj = howmany(30000, 60 * hz); /* can adjust 30ms in 60s */
104
108 /* The following can be overridden after boot via sysctl */
109 maxproc = NPROC;
110 TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
111 maxfiles = MAXFILES;
112 TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
113 maxprocperuid = maxproc - 1;
114 maxfilesperproc = maxfiles;
115
116 /* Cannot be changed after boot */
117 nbuf = NBUF;
118 TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
119#ifdef VM_SWZONE_SIZE_MAX
120 maxswzone = VM_SWZONE_SIZE_MAX;
121#endif
122 TUNABLE_INT_FETCH("kern.maxswzone", &maxswzone);
123#ifdef VM_BCACHE_SIZE_MAX
124 maxbcache = VM_BCACHE_SIZE_MAX;
125#endif
126 TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache);
105#ifdef VM_SWZONE_SIZE_MAX
106 maxswzone = VM_SWZONE_SIZE_MAX;
107#endif
108 TUNABLE_INT_FETCH("kern.maxswzone", &maxswzone);
109#ifdef VM_BCACHE_SIZE_MAX
110 maxbcache = VM_BCACHE_SIZE_MAX;
111#endif
112 TUNABLE_INT_FETCH("kern.maxbcache", &maxbcache);
127 ncallout = 16 + maxproc + maxfiles;
128 TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
129
130 maxtsiz = MAXTSIZ;
131 TUNABLE_QUAD_FETCH("kern.maxtsiz", &maxtsiz);
132 dfldsiz = DFLDSIZ;
133 TUNABLE_QUAD_FETCH("kern.dfldsiz", &dfldsiz);
134 maxdsiz = MAXDSIZ;
135 TUNABLE_QUAD_FETCH("kern.maxdsiz", &maxdsiz);
136 dflssiz = DFLSSIZ;
137 TUNABLE_QUAD_FETCH("kern.dflssiz", &dflssiz);
138 maxssiz = MAXSSIZ;
139 TUNABLE_QUAD_FETCH("kern.maxssiz", &maxssiz);
140 sgrowsiz = SGROWSIZ;
141 TUNABLE_QUAD_FETCH("kern.sgrowsiz", &sgrowsiz);
142}
113
114 maxtsiz = MAXTSIZ;
115 TUNABLE_QUAD_FETCH("kern.maxtsiz", &maxtsiz);
116 dfldsiz = DFLDSIZ;
117 TUNABLE_QUAD_FETCH("kern.dfldsiz", &dfldsiz);
118 maxdsiz = MAXDSIZ;
119 TUNABLE_QUAD_FETCH("kern.maxdsiz", &maxdsiz);
120 dflssiz = DFLSSIZ;
121 TUNABLE_QUAD_FETCH("kern.dflssiz", &dflssiz);
122 maxssiz = MAXSSIZ;
123 TUNABLE_QUAD_FETCH("kern.maxssiz", &maxssiz);
124 sgrowsiz = SGROWSIZ;
125 TUNABLE_QUAD_FETCH("kern.sgrowsiz", &sgrowsiz);
126}
127
128/*
129 * Boot time overrides that are scaled against main memory
130 */
131void
132init_param2(int physpages)
133{
134
135 /* Base parameters */
136 if ((maxusers = MAXUSERS) == 0) {
137 maxusers = physpages / (1024 * 1024 / PAGE_SIZE);
138 if (maxusers < 32)
139 maxusers = 32;
140 if (maxusers > 512)
141 maxusers = 512;
142 }
143 TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
144
145 /*
146 * The following can be overridden after boot via sysctl. Note:
147 * unless overriden, these macros are ultimately based on maxusers.
148 */
149 maxproc = NPROC;
150 TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
151 maxfiles = MAXFILES;
152 TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
153 maxprocperuid = maxproc - 1;
154 maxfilesperproc = maxfiles;
155
156 /*
157 * Cannot be changed after boot.
158 */
159 nbuf = NBUF;
160 TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
161
162 ncallout = 16 + maxproc + maxfiles;
163 TUNABLE_INT_FETCH("kern.ncallout", &ncallout);
164}