MCPcopy Create free account
hub / github.com/F-Stack/f-stack / init_param2

Function init_param2

freebsd/kern/subr_param.c:245–330  ·  view source on GitHub ↗

* Boot time overrides that are scaled against main memory */

Source from the content-addressed store, hash-verified

243 * Boot time overrides that are scaled against main memory
244 */
245void
246init_param2(long physpages)
247{
248
249 /* Base parameters */
250 maxusers = MAXUSERS;
251 TUNABLE_INT_FETCH("kern.maxusers", &maxusers);
252 if (maxusers == 0) {
253 maxusers = physpages / (2 * 1024 * 1024 / PAGE_SIZE);
254 if (maxusers < 32)
255 maxusers = 32;
256#ifdef VM_MAX_AUTOTUNE_MAXUSERS
257 if (maxusers > VM_MAX_AUTOTUNE_MAXUSERS)
258 maxusers = VM_MAX_AUTOTUNE_MAXUSERS;
259#endif
260 /*
261 * Scales down the function in which maxusers grows once
262 * we hit 384.
263 */
264 if (maxusers > 384)
265 maxusers = 384 + ((maxusers - 384) / 8);
266 }
267
268 /*
269 * The following can be overridden after boot via sysctl. Note:
270 * unless overriden, these macros are ultimately based on maxusers.
271 * Limit maxproc so that kmap entries cannot be exhausted by
272 * processes.
273 */
274 maxproc = NPROC;
275 TUNABLE_INT_FETCH("kern.maxproc", &maxproc);
276 if (maxproc > (physpages / 12))
277 maxproc = physpages / 12;
278 if (maxproc > pid_max)
279 maxproc = pid_max;
280 maxprocperuid = (maxproc * 9) / 10;
281
282 /*
283 * The default limit for maxfiles is 1/12 of the number of
284 * physical page but not less than 16 times maxusers.
285 * At most it can be 1/6 the number of physical pages.
286 */
287 maxfiles = imax(MAXFILES, physpages / 8);
288 TUNABLE_INT_FETCH("kern.maxfiles", &maxfiles);
289 if (maxfiles > (physpages / 4))
290 maxfiles = physpages / 4;
291 maxfilesperproc = (maxfiles / 10) * 9;
292 TUNABLE_INT_FETCH("kern.maxfilesperproc", &maxfilesperproc);
293
294 /*
295 * Cannot be changed after boot.
296 */
297 nbuf = NBUF;
298 TUNABLE_INT_FETCH("kern.nbuf", &nbuf);
299 TUNABLE_INT_FETCH("kern.bio_transient_maxcnt", &bio_transient_maxcnt);
300 maxphys = MAXPHYS;
301 TUNABLE_ULONG_FETCH("kern.maxphys", &maxphys);
302 if (maxphys == 0) {

Callers 14

init386Function · 0.85
mips_initFunction · 0.85
platform_startFunction · 0.85
platform_startFunction · 0.85
platform_startFunction · 0.85
mips_initFunction · 0.85
mips_initFunction · 0.85
mips_initFunction · 0.85
mips_initFunction · 0.85
mips_initFunction · 0.85
hammer_timeFunction · 0.85
initarmFunction · 0.85

Calls 2

imaxFunction · 0.85
flslFunction · 0.50

Tested by

no test coverage detected