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