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