xref: /illumos-gate/usr/src/uts/common/conf/param.c (revision 7b34a9a5df26271af0da06974fc361c468cd48d3)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24  * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
25  * Copyright 2012 Milan Jurik. All rights reserved.
26  */
27 
28 #include <sys/types.h>
29 #include <sys/time.h>
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/signal.h>
33 #include <sys/sysmacros.h>
34 #include <sys/cmn_err.h>
35 #include <sys/user.h>
36 #include <sys/proc.h>
37 #include <sys/task.h>
38 #include <sys/project.h>
39 #include <sys/klwp.h>
40 #include <sys/vnode.h>
41 #include <sys/file.h>
42 #include <sys/fcntl.h>
43 #include <sys/flock.h>
44 #include <sys/var.h>
45 #include <sys/stream.h>
46 #include <sys/strsubr.h>
47 #include <sys/conf.h>
48 #include <sys/class.h>
49 #include <sys/ts.h>
50 #include <sys/rt.h>
51 #include <sys/exec.h>
52 #include <sys/exechdr.h>
53 #include <sys/buf.h>
54 #include <sys/resource.h>
55 #include <vm/seg.h>
56 #include <vm/pvn.h>
57 #include <vm/seg_kmem.h>
58 #include <sys/vmparam.h>
59 #include <sys/machparam.h>
60 #include <sys/utsname.h>
61 #include <sys/kmem.h>
62 #include <sys/stack.h>
63 #include <sys/modctl.h>
64 #include <sys/fdbuffer.h>
65 #include <sys/cyclic_impl.h>
66 #include <sys/disp.h>
67 #include <sys/tuneable.h>
68 #include <sys/systeminfo.h>
69 
70 #include <sys/vmem.h>
71 #include <sys/clock.h>
72 #include <sys/clock_impl.h>
73 #include <sys/serializer.h>
74 
75 /*
76  * The following few lines describe generic things that must be compiled
77  * into the booted executable (unix) rather than genunix or any other
78  * module because they're required by crash dump readers, etc.
79  */
80 struct modctl modules;		/* head of linked list of modules */
81 char *default_path;		/* default module loading path */
82 struct swapinfo *swapinfo;	/* protected by the swapinfo_lock */
83 proc_t *practive;		/* active process list */
84 uint_t nproc;			/* current number of processes */
85 proc_t p0;			/* process 0 */
86 struct plock p0lock;		/* p0's p_lock */
87 klwp_t lwp0;			/* t0's lwp */
88 task_t *task0p;			/* task 0 */
89 kproject_t *proj0p;		/* location of project 0 */
90 
91 /*
92  * The following are "implementation architecture" dependent constants made
93  * available here in the form of initialized data for use by "implementation
94  * architecture" independent modules. See machparam.h.
95  */
96 const unsigned long	_pagesize	= (unsigned long)PAGESIZE;
97 const unsigned int	_pageshift	= (unsigned int)PAGESHIFT;
98 const unsigned long	_pageoffset	= (unsigned long)PAGEOFFSET;
99 /*
100  * XXX - This value pagemask has to be a 64bit size because
101  * large file support uses this mask on offsets which are 64 bit size.
102  * using unsigned leaves the higher 32 bits value as zero thus
103  * corrupting offset calculations in the file system and VM.
104  */
105 const u_longlong_t	_pagemask	= (u_longlong_t)PAGEMASK;
106 const unsigned long	_mmu_pagesize	= (unsigned long)MMU_PAGESIZE;
107 const unsigned int	_mmu_pageshift	= (unsigned int)MMU_PAGESHIFT;
108 const unsigned long	_mmu_pageoffset	= (unsigned long)MMU_PAGEOFFSET;
109 const unsigned long	_mmu_pagemask	= (unsigned long)MMU_PAGEMASK;
110 uintptr_t		_kernelbase	= (uintptr_t)KERNELBASE;
111 uintptr_t		_userlimit	= (uintptr_t)USERLIMIT;
112 uintptr_t		_userlimit32	= (uintptr_t)USERLIMIT32;
113 const uintptr_t		_argsbase	= (uintptr_t)ARGSBASE;
114 const unsigned int	_diskrpm	= (unsigned int)DISKRPM;
115 const unsigned long	_pgthresh	= (unsigned long)PGTHRESH;
116 const unsigned int	_maxslp		= (unsigned int)MAXSLP;
117 const unsigned long	_maxhandspreadpages = (unsigned long)MAXHANDSPREADPAGES;
118 const int		_ncpu		= (int)NCPU;
119 const int		_ncpu_log2	= (int)NCPU_LOG2;
120 const int		_ncpu_p2	= (int)NCPU_P2;
121 const unsigned long	_defaultstksz	= (unsigned long)DEFAULTSTKSZ;
122 const unsigned int	_nbpg		= (unsigned int)MMU_PAGESIZE;
123 
124 /*
125  * System parameter formulae.
126  *
127  * This file is copied into each directory where we compile
128  * the kernel; it should be modified there to suit local taste
129  * if necessary.
130  */
131 
132 /*
133  * hz is 100, but we set hires_tick to get higher resolution clock behavior
134  * (currently defined to be 1000 hz).  Higher values seem to work, but are not
135  * supported.
136  *
137  * This is configured via hires_tick to allow users to explicitly customize it
138  * to 0 should the need arise.
139  *
140  * If we do decide to play with higher values, remember that hz should
141  * satisfy the following constraints to avoid integer round-off problems:
142  *
143  * (1) hz should be in the range 100 <= hz <= MICROSEC.  If hz exceeds
144  *     MICROSEC, usec_per_tick will be zero and lots of stuff will break.
145  *     Similarly, if hz < 100 then hz / 100 == 0 and stuff will break.
146  *
147  * (2) If hz <= 1000, it should be both a multiple of 100 and a
148  *	divisor of 1000.
149  *
150  * (3) If hz > 1000, it should be both a multiple of 1000 and a
151  *	divisor of MICROSEC.
152  *
153  * Thus the only reasonable values of hz (i.e. the values that won't
154  * cause roundoff error) are: 100, 200, 500, 1000, 2000, 4000, 5000,
155  * 8000, 10000, 20000, 25000, 40000, 50000, 100000, 125000, 200000,
156  * 250000, 500000, 1000000.  As of this writing (1996) a clock rate
157  * of more than about 10 kHz seems utterly ridiculous, although
158  * this observation will no doubt seem quaintly amusing one day.
159  */
160 #define	HIRES_HZ_DEFAULT	1000
161 
162 int hz = HZ_DEFAULT;
163 int hires_hz = HIRES_HZ_DEFAULT;
164 
165 int hires_tick = 1;
166 int cpu_decay_factor = 10;	/* this is no longer tied to clock */
167 int max_hres_adj;	/* maximum adjustment of hrtime per tick */
168 int tick_per_msec;	/* clock ticks per millisecond (zero if hz < 1000) */
169 
170 /*
171  * Milliseconds, Microseconds, and Nanoseconds per clock tick
172  *
173  * Note:
174  *  msec_per_tick is zero if hz > 1000
175  */
176 int msec_per_tick;
177 int usec_per_tick;
178 int nsec_per_tick;
179 
180 /*
181  * Time Resolution values. These are defined in condvar.h and initialized in
182  * param_init(). Consumers of cv_reltimedwait() and cv_reltimedwait_sig()
183  * need to specify how accurate the timeout argument should be through
184  * one of these values. The intention is to allow the underlying implementation
185  * to anticipate or defer the expiration of timeouts, preventing unnecessary
186  * wakeups by batch processing similarly expiring events.
187  */
188 time_res_t time_res[TR_COUNT];
189 
190 /*
191  * Setting "snooping" to a non-zero value will cause a deadman panic if
192  * snoop_interval microseconds elapse without lbolt increasing.  The default
193  * snoop_interval is 50 seconds.
194  */
195 #define	SNOOP_INTERVAL_MIN	(MICROSEC)
196 #define	SNOOP_INTERVAL_DEFAULT	(50 * MICROSEC)
197 
198 int snooping = 0;
199 uint_t snoop_interval = SNOOP_INTERVAL_DEFAULT;
200 
201 /*
202  * Tables of initialization functions, called from main().
203  */
204 
205 extern void system_taskq_init(void);
206 extern void binit(void);
207 extern void space_init(void);
208 extern void dnlc_init(void);
209 extern void vfsinit(void);
210 extern void finit(void);
211 extern void strinit(void);
212 extern void flk_init(void);
213 extern void ftrace_init(void);
214 extern void softcall_init(void);
215 extern void ttyinit(void);
216 extern void schedctl_init(void);
217 extern void deadman_init(void);
218 extern void clock_timer_init(void);
219 extern void clock_realtime_init(void);
220 extern void clock_highres_init(void);
221 extern void clock_tick_mp_init(void);
222 extern void cu_init(void);
223 extern void callout_mp_init(void);
224 extern void cpu_seq_tbl_init(void);
225 
226 void	(*init_tbl[])(void) = {
227 	system_taskq_init,
228 	binit,
229 	space_init,
230 	dnlc_init,
231 	vfsinit,
232 	finit,
233 	strinit,
234 	serializer_init,
235 	softcall_init,
236 	ttyinit,
237 	as_init,
238 	pvn_init,
239 	anon_init,
240 	segvn_init,
241 	flk_init,
242 	cpu_seq_tbl_init,
243 	schedctl_init,
244 	fdb_init,
245 	deadman_init,
246 	clock_timer_init,
247 	clock_realtime_init,
248 	clock_highres_init,
249 	0
250 };
251 
252 
253 #if defined(__sparc)
254 	extern void siron_mp_init();
255 #endif
256 
257 /*
258  * Any per cpu resources should be initialized via
259  * an entry in mp_init_tbl().
260  */
261 void	(*mp_init_tbl[])(void) = {
262 	ftrace_init,
263 	cyclic_mp_init,
264 #if defined(__sparc)
265 	siron_mp_init,
266 #endif
267 	clock_tick_mp_init,
268 	cu_init,
269 	callout_mp_init,
270 	0
271 };
272 
273 int maxusers;		/* kitchen-sink knob for dynamic configuration */
274 
275 /*
276  * pidmax -- highest pid value assigned by the system
277  * Settable in /etc/system
278  */
279 int pidmax = DEFAULT_MAXPID;
280 
281 /*
282  * jump_pid - if set, this value is where pid numbers should start
283  * after the first few system pids (0-3) are used.  If 0, pids are
284  * chosen in the usual way. This variable can be used to quickly
285  * create large pids (by setting it to 100000, for example). pids
286  * less than this value will never be chosen.
287  */
288 pid_t jump_pid = DEFAULT_JUMPPID;
289 
290 /*
291  * autoup -- used in struct var for dynamic config of the age a delayed-write
292  * buffer must be in seconds before bdflush will write it out.
293  */
294 #define	DEFAULT_AUTOUP	30
295 int autoup = DEFAULT_AUTOUP;
296 
297 /*
298  * bufhwm -- tuneable variable for struct var for v_bufhwm.
299  * high water mark for buffer cache mem usage in units of K bytes.
300  *
301  * bufhwm_pct -- ditto, but given in % of physmem.
302  */
303 int bufhwm = 0;
304 int bufhwm_pct = 0;
305 
306 /*
307  * Process table.
308  */
309 int maxpid;
310 int max_nprocs;		/* set in param_init() */
311 int maxuprc;		/* set in param_init() */
312 int reserved_procs;
313 int nthread = 1;
314 
315 /*
316  * UFS tunables
317  */
318 int ufs_ninode;		/* declared here due to backwards compatibility */
319 int ndquot;		/* declared here due to backwards compatibility */
320 
321 /*
322  * Exec switch table. This is used by the generic exec module
323  * to switch out to the desired executable type, based on the
324  * magic number. The currently supported types are ELF, a.out
325  * (both NMAGIC and ZMAGIC), interpreter (#!) files,
326  * and Java executables.
327  */
328 /*
329  * Magic numbers
330  */
331 short elfmagic = 0x7f45;
332 short intpmagic = 0x2321;
333 short jmagic = 0x504b;
334 
335 #if defined(__sparc)
336 short aout_nmagic = NMAGIC;
337 short aout_zmagic = ZMAGIC;
338 short aout_omagic = OMAGIC;
339 #endif
340 short nomagic = 0;
341 
342 /*
343  * Magic strings
344  */
345 #define	ELF32MAGIC_STRING	"\x7f""ELF\x1"
346 #define	ELF64MAGIC_STRING	"\x7f""ELF\x2"
347 #define	INTPMAGIC_STRING	"#!"
348 #define	JAVAMAGIC_STRING	"PK\003\004"
349 #define	AOUT_OMAGIC_STRING	"\x1""\x07"	/* 0407 */
350 #define	AOUT_NMAGIC_STRING	"\x1""\x08"	/* 0410 */
351 #define	AOUT_ZMAGIC_STRING	"\x1""\x0b"	/* 0413 */
352 #define	NOMAGIC_STRING		""
353 
354 #define	SHBIN_CNTL(x)	((x)&037)
355 #define	SHBINMAGIC_STRING {SHBIN_CNTL('k'), SHBIN_CNTL('s'), SHBIN_CNTL('h'), 0}
356 #define	SHBINMAGIC_LEN	4
357 
358 char elf32magicstr[] = ELF32MAGIC_STRING;
359 char elf64magicstr[] = ELF64MAGIC_STRING;
360 char intpmagicstr[] = INTPMAGIC_STRING;
361 char shbinmagicstr[] = SHBINMAGIC_STRING;
362 char javamagicstr[] = JAVAMAGIC_STRING;
363 #if defined(__sparc)
364 char aout_nmagicstr[] = AOUT_NMAGIC_STRING;
365 char aout_zmagicstr[] = AOUT_ZMAGIC_STRING;
366 char aout_omagicstr[] = AOUT_OMAGIC_STRING;
367 #endif
368 char nomagicstr[] = NOMAGIC_STRING;
369 
370 char *execswnames[] = {
371 	"elfexec",	/* Elf32 */
372 #ifdef _LP64
373 	"elfexec",	/* Elf64 */
374 #endif
375 	"intpexec",
376 	"shbinexec",
377 	"javaexec",
378 #if defined(__sparc)
379 	"aoutexec",
380 	"aoutexec",
381 	"aoutexec",
382 #endif
383 	NULL,
384 	NULL,
385 	NULL
386 };
387 
388 struct execsw execsw[] = {
389 	{ elf32magicstr, 0, 5, NULL, NULL, NULL },
390 #ifdef _LP64
391 	{ elf64magicstr, 0, 5, NULL, NULL, NULL },
392 #endif
393 	{ intpmagicstr, 0, 2, NULL, NULL, NULL },
394 	{ shbinmagicstr, 0, SHBINMAGIC_LEN, NULL, NULL, NULL },
395 	{ javamagicstr, 0, 4, NULL, NULL, NULL },
396 #if defined(__sparc)
397 	{ aout_zmagicstr, 2, 2, NULL, NULL, NULL },
398 	{ aout_nmagicstr, 2, 2, NULL, NULL, NULL },
399 	{ aout_omagicstr, 2, 2, NULL, NULL, NULL },
400 #endif
401 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
402 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
403 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
404 	{ nomagicstr, 0, 0, NULL, NULL, NULL }
405 };
406 int nexectype = sizeof (execsw) / sizeof (execsw[0]);	/* # of exec types */
407 kmutex_t execsw_lock;	/* Used for allocation of execsw entries */
408 
409 /*
410  * symbols added to make changing proc.max-file-descriptor
411  * simple via /etc/system
412  */
413 #define	RLIM_FD_CUR 0x10000
414 #define	RLIM_FD_MAX 0x10000
415 
416 uint_t rlim_fd_cur = RLIM_FD_CUR;
417 uint_t rlim_fd_max = RLIM_FD_MAX;
418 
419 /*
420  * (Default resource limits were formerly declared here, but are now provided by
421  * the more general resource controls framework.)
422  */
423 
424 /*
425  * STREAMS tunables
426  */
427 int	nstrpush = 9;		/* maximum # of modules/drivers on a stream */
428 ssize_t	strctlsz = 1024;	/* maximum size of user-generated M_PROTO */
429 ssize_t	strmsgsz = 0x10000;	/* maximum size of user-generated M_DATA */
430 				/* for `strmsgsz', zero means unlimited */
431 /*
432  * Filesystem tunables
433  */
434 int	rstchown = 1;		/* POSIX_CHOWN_RESTRICTED is enabled */
435 int	ngroups_max = NGROUPS_MAX_DEFAULT;
436 
437 /*
438  * generic scheduling stuff
439  *
440  * Configurable parameters for RT and TS are in the respective
441  * scheduling class modules.
442  */
443 
444 pri_t maxclsyspri = MAXCLSYSPRI;
445 pri_t minclsyspri = MINCLSYSPRI;
446 char sys_name[] = "SYS";
447 
448 extern pri_t sys_init(id_t, int, classfuncs_t **);
449 extern classfuncs_t sys_classfuncs;
450 
451 sclass_t sclass[] = {
452 	{ "SYS",	sys_init,	&sys_classfuncs, STATIC_SCHED, 0 },
453 	{ "",	NULL,	NULL,	NULL, 0 },
454 	{ "",	NULL,	NULL,	NULL, 0 },
455 	{ "",	NULL,	NULL,	NULL, 0 },
456 	{ "",	NULL,	NULL,	NULL, 0 },
457 	{ "",	NULL,	NULL,	NULL, 0 },
458 	{ "",	NULL,	NULL,	NULL, 0 },
459 	{ "",	NULL,	NULL,	NULL, 0 },
460 	{ "",	NULL,	NULL,	NULL, 0 },
461 	{ "",	NULL,	NULL,	NULL, 0 }
462 };
463 
464 int loaded_classes = 1;		/* for loaded classes */
465 kmutex_t class_lock;		/* lock for class[] */
466 
467 int nclass = sizeof (sclass) / sizeof (sclass_t);
468 char initcls[] = "TS";
469 char *defaultclass = initcls;
470 
471 /*
472  * Tunable system parameters.
473  */
474 
475 /*
476  * The integers tune_* are done this way so that the tune
477  * data structure may be "tuned" if necessary from the /etc/system
478  * file. The tune data structure is initialized in param_init();
479  */
480 
481 tune_t tune;
482 
483 /*
484  * If freemem < t_getpgslow, then start to steal pages from processes.
485  */
486 int tune_t_gpgslo = 25;
487 
488 /*
489  * Rate at which fsflush is run, in seconds.
490  */
491 #define	DEFAULT_TUNE_T_FSFLUSHR	1
492 int tune_t_fsflushr = DEFAULT_TUNE_T_FSFLUSHR;
493 
494 /*
495  * The minimum available resident (not swappable) memory to maintain
496  * in order to avoid deadlock.  In pages.
497  */
498 int tune_t_minarmem = 25;
499 
500 /*
501  * The minimum available swappable memory to maintain in order to avoid
502  * deadlock.  In pages.
503  */
504 int tune_t_minasmem = 25;
505 
506 int tune_t_flckrec = 512;	/* max # of active frlocks */
507 
508 /*
509  * Number of currently available pages that cannot be 'locked'
510  * This is set in init_pages_pp_maximum, and must be initialized
511  * to zero here to detect an override in /etc/system
512  */
513 pgcnt_t pages_pp_maximum = 0;
514 
515 int boothowto;			/* boot flags passed to kernel */
516 struct var v;			/* System Configuration Information */
517 
518 /*
519  * System Configuration Information
520  */
521 
522 /*
523  * The physical system's host identifier, expressed as a decimal string.
524  * Code should only directly access this value when writing to it (setting the
525  * physical system's host identifier).  Code that reads the physical system's
526  * host identifier should use zone_get_hostid(NULL) instead.
527  */
528 char hw_serial[HW_HOSTID_LEN] = "0";
529 
530 #if defined(__sparc)
531 
532 /*
533  * On sparc machines, read hw_serial from the firmware at boot time
534  * and simply assert Oracle is the hardware provider.
535  */
536 char architecture[] = "sparcv9";
537 char architecture_32[] = "sparc";
538 char hw_provider[] = "Oracle Corporation";
539 
540 #elif defined(__i386)
541 
542 char architecture[] = "i386";
543 char architecture_32[] = "i386";
544 char hw_provider[SYS_NMLN] = "";
545 
546 #elif defined(__amd64)
547 
548 char architecture[] = "amd64";
549 char architecture_32[] = "i386";
550 char hw_provider[SYS_NMLN] = "";
551 
552 #else
553 #error "unknown processor architecture"
554 #endif
555 
556 char srpc_domain[SYS_NMLN] = "";
557 char platform[SYS_NMLN] = "";	/* read from the devinfo root node */
558 
559 /* Initialize isa_list */
560 char *isa_list = architecture;
561 
562 static pgcnt_t original_physmem = 0;
563 
564 #define	MIN_DEFAULT_MAXUSERS	8u
565 #define	MAX_DEFAULT_MAXUSERS	2048u
566 #define	MAX_MAXUSERS		4096u
567 
568 void
569 param_preset(void)
570 {
571 	original_physmem = physmem;
572 }
573 
574 void
575 param_calc(int platform_max_nprocs)
576 {
577 	/*
578 	 * Default to about one "user" per megabyte, taking into
579 	 * account both physical and virtual constraints.
580 	 * Note: 2^20 is a meg; shifting right by (20 - PAGESHIFT)
581 	 * converts pages to megs without integer overflow.
582 	 */
583 #if defined(__sparc)
584 	if (physmem > original_physmem) {
585 		physmem = original_physmem;
586 		cmn_err(CE_NOTE, "physmem limited to %ld", physmem);
587 	}
588 #endif
589 	if (maxusers == 0) {
590 		pgcnt_t physmegs = physmem >> (20 - PAGESHIFT);
591 		pgcnt_t virtmegs = vmem_size(heap_arena, VMEM_FREE) >> 20;
592 		maxusers = MIN(MAX(MIN(physmegs, virtmegs),
593 		    MIN_DEFAULT_MAXUSERS), MAX_DEFAULT_MAXUSERS);
594 	}
595 	if (maxusers > MAX_MAXUSERS) {
596 		maxusers = MAX_MAXUSERS;
597 		cmn_err(CE_NOTE, "maxusers limited to %d", MAX_MAXUSERS);
598 	}
599 
600 #ifdef DEBUG
601 	/*
602 	 * The purpose of maxusers is to prevent memory overcommit.
603 	 * DEBUG kernels take more space, so reduce maxusers a bit.
604 	 */
605 	maxusers = (3 * maxusers) / 4;
606 #endif
607 
608 	/*
609 	 * We need to dynamically change any variables now so that
610 	 * the setting of maxusers and pidmax propagate to the other
611 	 * variables that are dependent on them.
612 	 */
613 	if (reserved_procs == 0)
614 		reserved_procs = 5;
615 	if (pidmax < reserved_procs || pidmax > MAX_MAXPID)
616 		maxpid = MAX_MAXPID;
617 	else
618 		maxpid = pidmax;
619 
620 	/*
621 	 * This allows platform-dependent code to constrain the maximum
622 	 * number of processes allowed in case there are e.g. VM limitations
623 	 * with how many contexts are available.
624 	 */
625 	if (max_nprocs == 0)
626 		max_nprocs = (10 + 16 * maxusers);
627 	if (platform_max_nprocs > 0 && max_nprocs > platform_max_nprocs)
628 		max_nprocs = platform_max_nprocs;
629 	if (max_nprocs > maxpid)
630 		max_nprocs = maxpid;
631 
632 	if (maxuprc == 0)
633 		maxuprc = (max_nprocs - reserved_procs);
634 }
635 
636 void
637 param_init(void)
638 {
639 	/*
640 	 * Set each individual element of struct var v to be the
641 	 * default value. This is done this way
642 	 * so that a user can set the assigned integer value in the
643 	 * /etc/system file *IF* tuning is needed.
644 	 */
645 	v.v_proc = max_nprocs;	/* v_proc - max # of processes system wide */
646 	v.v_maxupttl = max_nprocs - reserved_procs;
647 	v.v_maxsyspri = (int)maxclsyspri;  /* max global pri for sysclass */
648 	v.v_maxup = MIN(maxuprc, v.v_maxupttl); /* max procs per user */
649 	v.v_autoup = autoup;	/* v_autoup - delay for delayed writes */
650 
651 	/*
652 	 * Set each individual element of struct tune to be the
653 	 * default value. Each struct element This is done this way
654 	 *  so that a user can set the assigned integer value in the
655 	 * /etc/system file *IF* tuning is needed.
656 	 */
657 	tune.t_gpgslo = tune_t_gpgslo;
658 	tune.t_fsflushr = tune_t_fsflushr;
659 	tune.t_minarmem = tune_t_minarmem;
660 	tune.t_minasmem = tune_t_minasmem;
661 	tune.t_flckrec = tune_t_flckrec;
662 
663 	/*
664 	 * Initialization for file descriptors to correct mistaken settings in
665 	 * /etc/system.  Initialization of limits performed by resource control
666 	 * system.
667 	 */
668 	if (rlim_fd_cur > rlim_fd_max)
669 		rlim_fd_cur = rlim_fd_max;
670 
671 	/*
672 	 * calculations needed if hz was set in /etc/system
673 	 */
674 	if (hires_tick)
675 		hz = hires_hz;
676 
677 	tick_per_msec = hz / MILLISEC;
678 	msec_per_tick = MILLISEC / hz;
679 	usec_per_tick = MICROSEC / hz;
680 	nsec_per_tick = NANOSEC / hz;
681 	max_hres_adj = nsec_per_tick >> ADJ_SHIFT;
682 
683 	/*
684 	 * Consumers of relative timedwait functions must specify how accurately
685 	 * the given timeout must expire. This is currently TR_CLOCK_TICK for
686 	 * the vast majority of consumers, but nsec_per_tick becomes an
687 	 * artificial value in a tickless world. Each caller of such routines
688 	 * should re-evaluate their usage and specify the appropriate
689 	 * resolution.
690 	 */
691 	time_res[TR_NANOSEC] = NANOSEC / NANOSEC;
692 	time_res[TR_MICROSEC] = NANOSEC / MICROSEC;
693 	time_res[TR_MILLISEC] = NANOSEC / MILLISEC;
694 	time_res[TR_SEC] = NANOSEC / SEC;
695 	time_res[TR_CLOCK_TICK] = nsec_per_tick;
696 }
697 
698 /*
699  * Validate tuneable parameters following /etc/system processing,
700  * but prior to param_init().
701  */
702 void
703 param_check(void)
704 {
705 #if defined(__x86)
706 	if (physmem != original_physmem) {
707 		cmn_err(CE_NOTE, "physmem cannot be modified to 0x%lx"
708 		    " via /etc/system. Please use eeprom(1M) instead.",
709 		    physmem);
710 		physmem = original_physmem;
711 	}
712 #endif
713 	if (ngroups_max < NGROUPS_UMIN)
714 		ngroups_max = NGROUPS_UMIN;
715 	if (ngroups_max > NGROUPS_UMAX)
716 		ngroups_max = NGROUPS_UMAX;
717 
718 	/* If we have many groups then the ucred proto message also grows. */
719 	if (ngroups_max > NGROUPS_OLDMAX &&
720 	    strctlsz < (ngroups_max - NGROUPS_OLDMAX) * sizeof (gid_t) + 1024) {
721 		strctlsz = (ngroups_max - NGROUPS_OLDMAX) * sizeof (gid_t) +
722 		    1024;
723 	}
724 
725 	if (autoup <= 0) {
726 		autoup = DEFAULT_AUTOUP;
727 		cmn_err(CE_WARN, "autoup <= 0; defaulting to %d", autoup);
728 	}
729 
730 	if (tune_t_fsflushr <= 0) {
731 		tune_t_fsflushr = DEFAULT_TUNE_T_FSFLUSHR;
732 		cmn_err(CE_WARN, "tune_t_fsflushr <= 0; defaulting to %d",
733 		    tune_t_fsflushr);
734 	}
735 
736 	if (jump_pid < 0 || jump_pid >= pidmax) {
737 		jump_pid = 0;
738 		cmn_err(CE_WARN, "jump_pid < 0 or >= pidmax; ignored");
739 	}
740 
741 	if (snoop_interval < SNOOP_INTERVAL_MIN) {
742 		snoop_interval = SNOOP_INTERVAL_DEFAULT;
743 		cmn_err(CE_WARN, "snoop_interval < minimum (%d); defaulting"
744 		    " to %d", SNOOP_INTERVAL_MIN, SNOOP_INTERVAL_DEFAULT);
745 	}
746 }
747