xref: /titanic_51/usr/src/uts/common/conf/param.c (revision b97d6ca7333c353b6ca20c20c99fb1be8d32a8de)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5381a2a9aSdr146992  * Common Development and Distribution License (the "License").
6381a2a9aSdr146992  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
2223d9e5acSMichael Corcoran  * Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
23*b97d6ca7SMilan Jurik  * Copyright 2012 Milan Jurik. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #include <sys/types.h>
277c478bd9Sstevel@tonic-gate #include <sys/time.h>
287c478bd9Sstevel@tonic-gate #include <sys/param.h>
297c478bd9Sstevel@tonic-gate #include <sys/systm.h>
307c478bd9Sstevel@tonic-gate #include <sys/signal.h>
317c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
327c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
337c478bd9Sstevel@tonic-gate #include <sys/user.h>
347c478bd9Sstevel@tonic-gate #include <sys/proc.h>
357c478bd9Sstevel@tonic-gate #include <sys/task.h>
367c478bd9Sstevel@tonic-gate #include <sys/project.h>
377c478bd9Sstevel@tonic-gate #include <sys/klwp.h>
387c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
397c478bd9Sstevel@tonic-gate #include <sys/file.h>
407c478bd9Sstevel@tonic-gate #include <sys/fcntl.h>
417c478bd9Sstevel@tonic-gate #include <sys/flock.h>
427c478bd9Sstevel@tonic-gate #include <sys/var.h>
437c478bd9Sstevel@tonic-gate #include <sys/stream.h>
447c478bd9Sstevel@tonic-gate #include <sys/strsubr.h>
457c478bd9Sstevel@tonic-gate #include <sys/conf.h>
467c478bd9Sstevel@tonic-gate #include <sys/class.h>
477c478bd9Sstevel@tonic-gate #include <sys/ts.h>
487c478bd9Sstevel@tonic-gate #include <sys/rt.h>
497c478bd9Sstevel@tonic-gate #include <sys/exec.h>
507c478bd9Sstevel@tonic-gate #include <sys/exechdr.h>
517c478bd9Sstevel@tonic-gate #include <sys/buf.h>
527c478bd9Sstevel@tonic-gate #include <sys/resource.h>
537c478bd9Sstevel@tonic-gate #include <vm/seg.h>
547c478bd9Sstevel@tonic-gate #include <vm/pvn.h>
557c478bd9Sstevel@tonic-gate #include <vm/seg_kmem.h>
567c478bd9Sstevel@tonic-gate #include <sys/vmparam.h>
577c478bd9Sstevel@tonic-gate #include <sys/machparam.h>
587c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
597c478bd9Sstevel@tonic-gate #include <sys/kmem.h>
607c478bd9Sstevel@tonic-gate #include <sys/stack.h>
617c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
627c478bd9Sstevel@tonic-gate #include <sys/fdbuffer.h>
637c478bd9Sstevel@tonic-gate #include <sys/cyclic_impl.h>
647c478bd9Sstevel@tonic-gate #include <sys/disp.h>
657c478bd9Sstevel@tonic-gate #include <sys/tuneable.h>
665679c89fSjv227347 #include <sys/systeminfo.h>
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #include <sys/vmem.h>
697c478bd9Sstevel@tonic-gate #include <sys/clock.h>
70d3d50737SRafael Vanoni #include <sys/clock_impl.h>
717c478bd9Sstevel@tonic-gate #include <sys/serializer.h>
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * The following few lines describe generic things that must be compiled
757c478bd9Sstevel@tonic-gate  * into the booted executable (unix) rather than genunix or any other
767c478bd9Sstevel@tonic-gate  * module because they're required by crash dump readers, etc.
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate struct modctl modules;		/* head of linked list of modules */
797c478bd9Sstevel@tonic-gate char *default_path;		/* default module loading path */
807c478bd9Sstevel@tonic-gate struct swapinfo *swapinfo;	/* protected by the swapinfo_lock */
817c478bd9Sstevel@tonic-gate proc_t *practive;		/* active process list */
827c478bd9Sstevel@tonic-gate uint_t nproc;			/* current number of processes */
837c478bd9Sstevel@tonic-gate proc_t p0;			/* process 0 */
847c478bd9Sstevel@tonic-gate struct plock p0lock;		/* p0's p_lock */
857c478bd9Sstevel@tonic-gate klwp_t lwp0;			/* t0's lwp */
867c478bd9Sstevel@tonic-gate task_t *task0p;			/* task 0 */
877c478bd9Sstevel@tonic-gate kproject_t *proj0p;		/* location of project 0 */
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /*
907c478bd9Sstevel@tonic-gate  * The following are "implementation architecture" dependent constants made
917c478bd9Sstevel@tonic-gate  * available here in the form of initialized data for use by "implementation
927c478bd9Sstevel@tonic-gate  * architecture" independent modules. See machparam.h.
937c478bd9Sstevel@tonic-gate  */
947c478bd9Sstevel@tonic-gate const unsigned long	_pagesize	= (unsigned long)PAGESIZE;
957c478bd9Sstevel@tonic-gate const unsigned int	_pageshift	= (unsigned int)PAGESHIFT;
967c478bd9Sstevel@tonic-gate const unsigned long	_pageoffset	= (unsigned long)PAGEOFFSET;
977c478bd9Sstevel@tonic-gate /*
987c478bd9Sstevel@tonic-gate  * XXX - This value pagemask has to be a 64bit size because
997c478bd9Sstevel@tonic-gate  * large file support uses this mask on offsets which are 64 bit size.
1007c478bd9Sstevel@tonic-gate  * using unsigned leaves the higher 32 bits value as zero thus
1017c478bd9Sstevel@tonic-gate  * corrupting offset calculations in the file system and VM.
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate const u_longlong_t	_pagemask	= (u_longlong_t)PAGEMASK;
1047c478bd9Sstevel@tonic-gate const unsigned long	_mmu_pagesize	= (unsigned long)MMU_PAGESIZE;
1057c478bd9Sstevel@tonic-gate const unsigned int	_mmu_pageshift	= (unsigned int)MMU_PAGESHIFT;
1067c478bd9Sstevel@tonic-gate const unsigned long	_mmu_pageoffset	= (unsigned long)MMU_PAGEOFFSET;
1077c478bd9Sstevel@tonic-gate const unsigned long	_mmu_pagemask	= (unsigned long)MMU_PAGEMASK;
1087c478bd9Sstevel@tonic-gate uintptr_t		_kernelbase	= (uintptr_t)KERNELBASE;
1097c478bd9Sstevel@tonic-gate uintptr_t		_userlimit	= (uintptr_t)USERLIMIT;
1107c478bd9Sstevel@tonic-gate uintptr_t		_userlimit32	= (uintptr_t)USERLIMIT32;
1117c478bd9Sstevel@tonic-gate const uintptr_t		_argsbase	= (uintptr_t)ARGSBASE;
1127c478bd9Sstevel@tonic-gate const unsigned int	_diskrpm	= (unsigned int)DISKRPM;
1137c478bd9Sstevel@tonic-gate const unsigned long	_pgthresh	= (unsigned long)PGTHRESH;
1147c478bd9Sstevel@tonic-gate const unsigned int	_maxslp		= (unsigned int)MAXSLP;
1157c478bd9Sstevel@tonic-gate const unsigned long	_maxhandspreadpages = (unsigned long)MAXHANDSPREADPAGES;
1167c478bd9Sstevel@tonic-gate const int		_ncpu 		= (int)NCPU;
11723d9e5acSMichael Corcoran const int		_ncpu_log2	= (int)NCPU_LOG2;
118cb15d5d9SPeter Rival const int		_ncpu_p2	= (int)NCPU_P2;
1197c478bd9Sstevel@tonic-gate const unsigned long	_defaultstksz	= (unsigned long)DEFAULTSTKSZ;
1207c478bd9Sstevel@tonic-gate const unsigned int	_nbpg		= (unsigned int)MMU_PAGESIZE;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * System parameter formulae.
1247c478bd9Sstevel@tonic-gate  *
1257c478bd9Sstevel@tonic-gate  * This file is copied into each directory where we compile
1267c478bd9Sstevel@tonic-gate  * the kernel; it should be modified there to suit local taste
1277c478bd9Sstevel@tonic-gate  * if necessary.
1287c478bd9Sstevel@tonic-gate  */
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * Default hz is 100, but if we set hires_tick we get higher resolution
1327c478bd9Sstevel@tonic-gate  * clock behavior (currently defined to be 1000 hz).  Higher values seem
1337c478bd9Sstevel@tonic-gate  * to work, but are not supported.
1347c478bd9Sstevel@tonic-gate  *
1357c478bd9Sstevel@tonic-gate  * If we do decide to play with higher values, remember that hz should
1367c478bd9Sstevel@tonic-gate  * satisfy the following constraints to avoid integer round-off problems:
1377c478bd9Sstevel@tonic-gate  *
1387c478bd9Sstevel@tonic-gate  * (1) hz should be in the range 100 <= hz <= MICROSEC.  If hz exceeds
1397c478bd9Sstevel@tonic-gate  *     MICROSEC, usec_per_tick will be zero and lots of stuff will break.
1407c478bd9Sstevel@tonic-gate  *     Similarly, if hz < 100 then hz / 100 == 0 and stuff will break.
1417c478bd9Sstevel@tonic-gate  *
1427c478bd9Sstevel@tonic-gate  * (2) If hz <= 1000, it should be both a multiple of 100 and a
1437c478bd9Sstevel@tonic-gate  *	divisor of 1000.
1447c478bd9Sstevel@tonic-gate  *
1457c478bd9Sstevel@tonic-gate  * (3) If hz > 1000, it should be both a multiple of 1000 and a
1467c478bd9Sstevel@tonic-gate  *	divisor of MICROSEC.
1477c478bd9Sstevel@tonic-gate  *
1487c478bd9Sstevel@tonic-gate  * Thus the only reasonable values of hz (i.e. the values that won't
1497c478bd9Sstevel@tonic-gate  * cause roundoff error) are: 100, 200, 500, 1000, 2000, 4000, 5000,
1507c478bd9Sstevel@tonic-gate  * 8000, 10000, 20000, 25000, 40000, 50000, 100000, 125000, 200000,
1517c478bd9Sstevel@tonic-gate  * 250000, 500000, 1000000.  As of this writing (1996) a clock rate
1527c478bd9Sstevel@tonic-gate  * of more than about 10 kHz seems utterly ridiculous, although
1537c478bd9Sstevel@tonic-gate  * this observation will no doubt seem quaintly amusing one day.
1547c478bd9Sstevel@tonic-gate  */
155d3d50737SRafael Vanoni #define	HIRES_HZ_DEFAULT	1000
156d3d50737SRafael Vanoni 
157d3d50737SRafael Vanoni int hz = HZ_DEFAULT;
158d3d50737SRafael Vanoni int hires_hz = HIRES_HZ_DEFAULT;
159d3d50737SRafael Vanoni 
1607c478bd9Sstevel@tonic-gate int hires_tick = 0;
1617c478bd9Sstevel@tonic-gate int cpu_decay_factor = 10;	/* this is no longer tied to clock */
1627c478bd9Sstevel@tonic-gate int max_hres_adj;	/* maximum adjustment of hrtime per tick */
163d3d50737SRafael Vanoni int tick_per_msec;	/* clock ticks per millisecond (zero if hz < 1000) */
164d3d50737SRafael Vanoni 
165d3d50737SRafael Vanoni /*
166d3d50737SRafael Vanoni  * Milliseconds, Microseconds, and Nanoseconds per clock tick
167d3d50737SRafael Vanoni  *
168d3d50737SRafael Vanoni  * Note:
169d3d50737SRafael Vanoni  *  msec_per_tick is zero if hz > 1000
170d3d50737SRafael Vanoni  */
171d3d50737SRafael Vanoni int msec_per_tick;
172d3d50737SRafael Vanoni int usec_per_tick;
173d3d50737SRafael Vanoni int nsec_per_tick;
174d3d50737SRafael Vanoni 
175d3d50737SRafael Vanoni /*
176d3d50737SRafael Vanoni  * Time Resolution values. These are defined in condvar.h and initialized in
177d3d50737SRafael Vanoni  * param_init(). Consumers of cv_reltimedwait() and cv_reltimedwait_sig()
178d3d50737SRafael Vanoni  * need to specify how accurate the timeout argument should be through
179d3d50737SRafael Vanoni  * one of these values. The intention is to allow the underlying implementation
180d3d50737SRafael Vanoni  * to anticipate or defer the expiration of timeouts, preventing unnecessary
181d3d50737SRafael Vanoni  * wakeups by batch processing similarly expiring events.
182d3d50737SRafael Vanoni  */
183d3d50737SRafael Vanoni time_res_t time_res[TR_COUNT];
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate /*
1867c478bd9Sstevel@tonic-gate  * Setting "snooping" to a non-zero value will cause a deadman panic if
1877c478bd9Sstevel@tonic-gate  * snoop_interval microseconds elapse without lbolt increasing.  The default
1887c478bd9Sstevel@tonic-gate  * snoop_interval is 50 seconds.
1897c478bd9Sstevel@tonic-gate  */
1907c478bd9Sstevel@tonic-gate #define	SNOOP_INTERVAL_MIN	(MICROSEC)
1917c478bd9Sstevel@tonic-gate #define	SNOOP_INTERVAL_DEFAULT	(50 * MICROSEC)
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate int snooping = 0;
1947c478bd9Sstevel@tonic-gate uint_t snoop_interval = SNOOP_INTERVAL_DEFAULT;
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * Tables of initialization functions, called from main().
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate extern void system_taskq_init(void);
2017c478bd9Sstevel@tonic-gate extern void binit(void);
2027c478bd9Sstevel@tonic-gate extern void space_init(void);
2037c478bd9Sstevel@tonic-gate extern void dnlc_init(void);
2047c478bd9Sstevel@tonic-gate extern void vfsinit(void);
2057c478bd9Sstevel@tonic-gate extern void finit(void);
2067c478bd9Sstevel@tonic-gate extern void strinit(void);
2077c478bd9Sstevel@tonic-gate extern void flk_init(void);
2087c478bd9Sstevel@tonic-gate extern void ftrace_init(void);
2097c478bd9Sstevel@tonic-gate extern void softcall_init(void);
2107c478bd9Sstevel@tonic-gate extern void ttyinit(void);
2117c478bd9Sstevel@tonic-gate extern void schedctl_init(void);
2127c478bd9Sstevel@tonic-gate extern void deadman_init(void);
2137c478bd9Sstevel@tonic-gate extern void clock_timer_init(void);
2147c478bd9Sstevel@tonic-gate extern void clock_realtime_init(void);
2157c478bd9Sstevel@tonic-gate extern void clock_highres_init(void);
2162850d85bSmv143129 extern void clock_tick_mp_init(void);
217b885580bSAlexander Kolbasov extern void cu_init(void);
21887a18d3fSMadhavan Venkataraman extern void callout_mp_init(void);
2196890d023SEric Saxe extern void cpu_seq_tbl_init(void);
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate void	(*init_tbl[])(void) = {
2227c478bd9Sstevel@tonic-gate 	system_taskq_init,
2237c478bd9Sstevel@tonic-gate 	binit,
2247c478bd9Sstevel@tonic-gate 	space_init,
2257c478bd9Sstevel@tonic-gate 	dnlc_init,
2267c478bd9Sstevel@tonic-gate 	vfsinit,
2277c478bd9Sstevel@tonic-gate 	finit,
2287c478bd9Sstevel@tonic-gate 	strinit,
2297c478bd9Sstevel@tonic-gate 	serializer_init,
2307c478bd9Sstevel@tonic-gate 	softcall_init,
2317c478bd9Sstevel@tonic-gate 	ttyinit,
2327c478bd9Sstevel@tonic-gate 	as_init,
2337c478bd9Sstevel@tonic-gate 	pvn_init,
2347c478bd9Sstevel@tonic-gate 	anon_init,
2357c478bd9Sstevel@tonic-gate 	segvn_init,
2367c478bd9Sstevel@tonic-gate 	flk_init,
2376890d023SEric Saxe 	cpu_seq_tbl_init,
2387c478bd9Sstevel@tonic-gate 	schedctl_init,
2397c478bd9Sstevel@tonic-gate 	fdb_init,
2407c478bd9Sstevel@tonic-gate 	deadman_init,
2417c478bd9Sstevel@tonic-gate 	clock_timer_init,
2427c478bd9Sstevel@tonic-gate 	clock_realtime_init,
2437c478bd9Sstevel@tonic-gate 	clock_highres_init,
2447c478bd9Sstevel@tonic-gate 	0
2457c478bd9Sstevel@tonic-gate };
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 
2483aedfe0bSmishra #if defined(__sparc)
2493aedfe0bSmishra 	extern void siron_mp_init();
2503aedfe0bSmishra #endif
2513aedfe0bSmishra 
2527c478bd9Sstevel@tonic-gate /*
2537c478bd9Sstevel@tonic-gate  * Any per cpu resources should be initialized via
2547c478bd9Sstevel@tonic-gate  * an entry in mp_init_tbl().
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate void	(*mp_init_tbl[])(void) = {
2577c478bd9Sstevel@tonic-gate 	ftrace_init,
2587c478bd9Sstevel@tonic-gate 	cyclic_mp_init,
2593aedfe0bSmishra #if defined(__sparc)
2603aedfe0bSmishra 	siron_mp_init,
2613aedfe0bSmishra #endif
2622850d85bSmv143129 	clock_tick_mp_init,
263b885580bSAlexander Kolbasov 	cu_init,
26487a18d3fSMadhavan Venkataraman 	callout_mp_init,
2657c478bd9Sstevel@tonic-gate 	0
2667c478bd9Sstevel@tonic-gate };
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate int maxusers;		/* kitchen-sink knob for dynamic configuration */
2697c478bd9Sstevel@tonic-gate 
2707c478bd9Sstevel@tonic-gate /*
2717c478bd9Sstevel@tonic-gate  * pidmax -- highest pid value assigned by the system
2727c478bd9Sstevel@tonic-gate  * Settable in /etc/system
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate int pidmax = DEFAULT_MAXPID;
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * jump_pid - if set, this value is where pid numbers should start
2787c478bd9Sstevel@tonic-gate  * after the first few system pids (0-3) are used.  If 0, pids are
2797c478bd9Sstevel@tonic-gate  * chosen in the usual way. This variable can be used to quickly
2807c478bd9Sstevel@tonic-gate  * create large pids (by setting it to 100000, for example). pids
2817c478bd9Sstevel@tonic-gate  * less than this value will never be chosen.
2827c478bd9Sstevel@tonic-gate  */
2837c478bd9Sstevel@tonic-gate pid_t jump_pid = DEFAULT_JUMPPID;
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate /*
2867c478bd9Sstevel@tonic-gate  * autoup -- used in struct var for dynamic config of the age a delayed-write
2877c478bd9Sstevel@tonic-gate  * buffer must be in seconds before bdflush will write it out.
2887c478bd9Sstevel@tonic-gate  */
2897c478bd9Sstevel@tonic-gate #define	DEFAULT_AUTOUP	30
2907c478bd9Sstevel@tonic-gate int autoup = DEFAULT_AUTOUP;
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate  * bufhwm -- tuneable variable for struct var for v_bufhwm.
2947c478bd9Sstevel@tonic-gate  * high water mark for buffer cache mem usage in units of K bytes.
2957c478bd9Sstevel@tonic-gate  *
2967c478bd9Sstevel@tonic-gate  * bufhwm_pct -- ditto, but given in % of physmem.
2977c478bd9Sstevel@tonic-gate  */
2987c478bd9Sstevel@tonic-gate int bufhwm = 0;
2997c478bd9Sstevel@tonic-gate int bufhwm_pct = 0;
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate /*
3027c478bd9Sstevel@tonic-gate  * Process table.
3037c478bd9Sstevel@tonic-gate  */
3047c478bd9Sstevel@tonic-gate int maxpid;
3057c478bd9Sstevel@tonic-gate int max_nprocs;		/* set in param_init() */
3067c478bd9Sstevel@tonic-gate int maxuprc;		/* set in param_init() */
3077c478bd9Sstevel@tonic-gate int reserved_procs;
3087c478bd9Sstevel@tonic-gate int nthread = 1;
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate  * UFS tunables
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate int ufs_ninode;		/* declared here due to backwards compatibility */
3147c478bd9Sstevel@tonic-gate int ndquot;		/* declared here due to backwards compatibility */
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Exec switch table. This is used by the generic exec module
3187c478bd9Sstevel@tonic-gate  * to switch out to the desired executable type, based on the
3197c478bd9Sstevel@tonic-gate  * magic number. The currently supported types are ELF, a.out
3207c478bd9Sstevel@tonic-gate  * (both NMAGIC and ZMAGIC), interpreter (#!) files,
3217c478bd9Sstevel@tonic-gate  * and Java executables.
3227c478bd9Sstevel@tonic-gate  */
3237c478bd9Sstevel@tonic-gate /*
3247c478bd9Sstevel@tonic-gate  * Magic numbers
3257c478bd9Sstevel@tonic-gate  */
3267c478bd9Sstevel@tonic-gate short elfmagic = 0x7f45;
3277c478bd9Sstevel@tonic-gate short intpmagic = 0x2321;
3287c478bd9Sstevel@tonic-gate short jmagic = 0x504b;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate #if defined(__sparc)
3317c478bd9Sstevel@tonic-gate short aout_nmagic = NMAGIC;
3327c478bd9Sstevel@tonic-gate short aout_zmagic = ZMAGIC;
3337c478bd9Sstevel@tonic-gate short aout_omagic = OMAGIC;
3347c478bd9Sstevel@tonic-gate #endif
3357c478bd9Sstevel@tonic-gate short nomagic = 0;
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate  * Magic strings
3397c478bd9Sstevel@tonic-gate  */
3407c478bd9Sstevel@tonic-gate #define	ELF32MAGIC_STRING	"\x7f""ELF\x1"
3417c478bd9Sstevel@tonic-gate #define	ELF64MAGIC_STRING	"\x7f""ELF\x2"
3427c478bd9Sstevel@tonic-gate #define	INTPMAGIC_STRING	"#!"
3437c478bd9Sstevel@tonic-gate #define	JAVAMAGIC_STRING	"PK\003\004"
3447c478bd9Sstevel@tonic-gate #define	AOUT_OMAGIC_STRING	"\x1""\x07"	/* 0407 */
3457c478bd9Sstevel@tonic-gate #define	AOUT_NMAGIC_STRING	"\x1""\x08"	/* 0410 */
3467c478bd9Sstevel@tonic-gate #define	AOUT_ZMAGIC_STRING	"\x1""\x0b"	/* 0413 */
3477c478bd9Sstevel@tonic-gate #define	NOMAGIC_STRING		""
3487c478bd9Sstevel@tonic-gate 
3497c2fbfb3SApril Chin #define	SHBIN_CNTL(x)	((x)&037)
3507c2fbfb3SApril Chin #define	SHBINMAGIC_STRING {SHBIN_CNTL('k'), SHBIN_CNTL('s'), SHBIN_CNTL('h'), 0}
3517c2fbfb3SApril Chin #define	SHBINMAGIC_LEN	4
3527c2fbfb3SApril Chin 
3537c478bd9Sstevel@tonic-gate char elf32magicstr[] = ELF32MAGIC_STRING;
3547c478bd9Sstevel@tonic-gate char elf64magicstr[] = ELF64MAGIC_STRING;
3557c478bd9Sstevel@tonic-gate char intpmagicstr[] = INTPMAGIC_STRING;
3567c2fbfb3SApril Chin char shbinmagicstr[] = SHBINMAGIC_STRING;
3577c478bd9Sstevel@tonic-gate char javamagicstr[] = JAVAMAGIC_STRING;
3587c478bd9Sstevel@tonic-gate #if defined(__sparc)
3597c478bd9Sstevel@tonic-gate char aout_nmagicstr[] = AOUT_NMAGIC_STRING;
3607c478bd9Sstevel@tonic-gate char aout_zmagicstr[] = AOUT_ZMAGIC_STRING;
3617c478bd9Sstevel@tonic-gate char aout_omagicstr[] = AOUT_OMAGIC_STRING;
3627c478bd9Sstevel@tonic-gate #endif
3637c478bd9Sstevel@tonic-gate char nomagicstr[] = NOMAGIC_STRING;
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate char *execswnames[] = {
3667c478bd9Sstevel@tonic-gate 	"elfexec",	/* Elf32 */
3677c478bd9Sstevel@tonic-gate #ifdef _LP64
3687c478bd9Sstevel@tonic-gate 	"elfexec",	/* Elf64 */
3697c478bd9Sstevel@tonic-gate #endif
3707c478bd9Sstevel@tonic-gate 	"intpexec",
3717c2fbfb3SApril Chin 	"shbinexec",
3727c478bd9Sstevel@tonic-gate 	"javaexec",
3737c478bd9Sstevel@tonic-gate #if defined(__sparc)
3747c478bd9Sstevel@tonic-gate 	"aoutexec",
3757c478bd9Sstevel@tonic-gate 	"aoutexec",
3767c478bd9Sstevel@tonic-gate 	"aoutexec",
3777c478bd9Sstevel@tonic-gate #endif
3787c478bd9Sstevel@tonic-gate 	NULL,
3797c478bd9Sstevel@tonic-gate 	NULL,
3807c478bd9Sstevel@tonic-gate 	NULL
3817c478bd9Sstevel@tonic-gate };
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate struct execsw execsw[] = {
3847c478bd9Sstevel@tonic-gate 	{ elf32magicstr, 0, 5, NULL, NULL, NULL },
3857c478bd9Sstevel@tonic-gate #ifdef _LP64
3867c478bd9Sstevel@tonic-gate 	{ elf64magicstr, 0, 5, NULL, NULL, NULL },
3877c478bd9Sstevel@tonic-gate #endif
3887c478bd9Sstevel@tonic-gate 	{ intpmagicstr, 0, 2, NULL, NULL, NULL },
3897c2fbfb3SApril Chin 	{ shbinmagicstr, 0, SHBINMAGIC_LEN, NULL, NULL, NULL },
3907c478bd9Sstevel@tonic-gate 	{ javamagicstr, 0, 4, NULL, NULL, NULL },
3917c478bd9Sstevel@tonic-gate #if defined(__sparc)
3927c478bd9Sstevel@tonic-gate 	{ aout_zmagicstr, 2, 2, NULL, NULL, NULL },
3937c478bd9Sstevel@tonic-gate 	{ aout_nmagicstr, 2, 2, NULL, NULL, NULL },
3947c478bd9Sstevel@tonic-gate 	{ aout_omagicstr, 2, 2, NULL, NULL, NULL },
3957c478bd9Sstevel@tonic-gate #endif
3967c478bd9Sstevel@tonic-gate 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
3977c478bd9Sstevel@tonic-gate 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
3987c478bd9Sstevel@tonic-gate 	{ nomagicstr, 0, 0, NULL, NULL, NULL },
3997c478bd9Sstevel@tonic-gate 	{ nomagicstr, 0, 0, NULL, NULL, NULL }
4007c478bd9Sstevel@tonic-gate };
4017c478bd9Sstevel@tonic-gate int nexectype = sizeof (execsw) / sizeof (execsw[0]);	/* # of exec types */
4027c478bd9Sstevel@tonic-gate kmutex_t execsw_lock;	/* Used for allocation of execsw entries */
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate  * symbols added to make changing max-file-descriptors
4067c478bd9Sstevel@tonic-gate  * simple via /etc/system
4077c478bd9Sstevel@tonic-gate  */
4087c478bd9Sstevel@tonic-gate #define	RLIM_FD_CUR 0x100
4097c478bd9Sstevel@tonic-gate #define	RLIM_FD_MAX 0x10000
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate uint_t rlim_fd_cur = RLIM_FD_CUR;
4127c478bd9Sstevel@tonic-gate uint_t rlim_fd_max = RLIM_FD_MAX;
4137c478bd9Sstevel@tonic-gate 
4147c478bd9Sstevel@tonic-gate /*
4157c478bd9Sstevel@tonic-gate  * (Default resource limits were formerly declared here, but are now provided by
4167c478bd9Sstevel@tonic-gate  * the more general resource controls framework.)
4177c478bd9Sstevel@tonic-gate  */
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate /*
420e4506d67Smeem  * STREAMS tunables
4217c478bd9Sstevel@tonic-gate  */
422e4506d67Smeem int	nstrpush = 9;		/* maximum # of modules/drivers on a stream */
423e4506d67Smeem ssize_t	strctlsz = 1024;	/* maximum size of user-generated M_PROTO */
424e4506d67Smeem ssize_t	strmsgsz = 0x10000;	/* maximum size of user-generated M_DATA */
425e4506d67Smeem 				/* for `strmsgsz', zero means unlimited */
4267c478bd9Sstevel@tonic-gate /*
427e4506d67Smeem  * Filesystem tunables
4287c478bd9Sstevel@tonic-gate  */
4297c478bd9Sstevel@tonic-gate int	rstchown = 1;		/* POSIX_CHOWN_RESTRICTED is enabled */
4307c478bd9Sstevel@tonic-gate int	ngroups_max = NGROUPS_MAX_DEFAULT;
4317c478bd9Sstevel@tonic-gate 
4327c478bd9Sstevel@tonic-gate /*
4337c478bd9Sstevel@tonic-gate  * generic scheduling stuff
4347c478bd9Sstevel@tonic-gate  *
4357c478bd9Sstevel@tonic-gate  * Configurable parameters for RT and TS are in the respective
4367c478bd9Sstevel@tonic-gate  * scheduling class modules.
4377c478bd9Sstevel@tonic-gate  */
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate pri_t maxclsyspri = MAXCLSYSPRI;
4407c478bd9Sstevel@tonic-gate pri_t minclsyspri = MINCLSYSPRI;
4417c478bd9Sstevel@tonic-gate char sys_name[] = "SYS";
4427c478bd9Sstevel@tonic-gate 
443*b97d6ca7SMilan Jurik extern pri_t sys_init(id_t, int, classfuncs_t **);
4447c478bd9Sstevel@tonic-gate extern classfuncs_t sys_classfuncs;
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate sclass_t sclass[] = {
4477c478bd9Sstevel@tonic-gate 	{ "SYS",	sys_init,	&sys_classfuncs, STATIC_SCHED, 0 },
4487c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4497c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4507c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4517c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4527c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4537c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4547c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4557c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 },
4567c478bd9Sstevel@tonic-gate 	{ "",	NULL,	NULL,	NULL, 0 }
4577c478bd9Sstevel@tonic-gate };
4587c478bd9Sstevel@tonic-gate 
4597c478bd9Sstevel@tonic-gate int loaded_classes = 1;		/* for loaded classes */
4607c478bd9Sstevel@tonic-gate kmutex_t class_lock;		/* lock for class[] */
4617c478bd9Sstevel@tonic-gate 
4627c478bd9Sstevel@tonic-gate int nclass = sizeof (sclass) / sizeof (sclass_t);
4637c478bd9Sstevel@tonic-gate char initcls[] = "TS";
4647c478bd9Sstevel@tonic-gate char *defaultclass = initcls;
4657c478bd9Sstevel@tonic-gate 
4667c478bd9Sstevel@tonic-gate /*
4677c478bd9Sstevel@tonic-gate  * Tunable system parameters.
4687c478bd9Sstevel@tonic-gate  */
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate /*
4717c478bd9Sstevel@tonic-gate  * The integers tune_* are done this way so that the tune
4727c478bd9Sstevel@tonic-gate  * data structure may be "tuned" if necessary from the /etc/system
4737c478bd9Sstevel@tonic-gate  * file. The tune data structure is initialized in param_init();
4747c478bd9Sstevel@tonic-gate  */
4757c478bd9Sstevel@tonic-gate 
4767c478bd9Sstevel@tonic-gate tune_t tune;
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate /*
4797c478bd9Sstevel@tonic-gate  * If freemem < t_getpgslow, then start to steal pages from processes.
4807c478bd9Sstevel@tonic-gate  */
4817c478bd9Sstevel@tonic-gate int tune_t_gpgslo = 25;
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate /*
4847c478bd9Sstevel@tonic-gate  * Rate at which fsflush is run, in seconds.
4857c478bd9Sstevel@tonic-gate  */
4867c478bd9Sstevel@tonic-gate #define	DEFAULT_TUNE_T_FSFLUSHR	1
4877c478bd9Sstevel@tonic-gate int tune_t_fsflushr = DEFAULT_TUNE_T_FSFLUSHR;
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate /*
4907c478bd9Sstevel@tonic-gate  * The minimum available resident (not swappable) memory to maintain
4917c478bd9Sstevel@tonic-gate  * in order to avoid deadlock.  In pages.
4927c478bd9Sstevel@tonic-gate  */
4937c478bd9Sstevel@tonic-gate int tune_t_minarmem = 25;
4947c478bd9Sstevel@tonic-gate 
4957c478bd9Sstevel@tonic-gate /*
4967c478bd9Sstevel@tonic-gate  * The minimum available swappable memory to maintain in order to avoid
4977c478bd9Sstevel@tonic-gate  * deadlock.  In pages.
4987c478bd9Sstevel@tonic-gate  */
4997c478bd9Sstevel@tonic-gate int tune_t_minasmem = 25;
5007c478bd9Sstevel@tonic-gate 
5017c478bd9Sstevel@tonic-gate int tune_t_flckrec = 512;	/* max # of active frlocks */
5027c478bd9Sstevel@tonic-gate 
5037c478bd9Sstevel@tonic-gate /*
5047c478bd9Sstevel@tonic-gate  * Number of currently available pages that cannot be 'locked'
5057c478bd9Sstevel@tonic-gate  * This is set in init_pages_pp_maximum, and must be initialized
5067c478bd9Sstevel@tonic-gate  * to zero here to detect an override in /etc/system
5077c478bd9Sstevel@tonic-gate  */
5087c478bd9Sstevel@tonic-gate pgcnt_t pages_pp_maximum = 0;
5097c478bd9Sstevel@tonic-gate 
5107c478bd9Sstevel@tonic-gate int boothowto;			/* boot flags passed to kernel */
5117c478bd9Sstevel@tonic-gate struct var v;			/* System Configuration Information */
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate /*
5147c478bd9Sstevel@tonic-gate  * System Configuration Information
5157c478bd9Sstevel@tonic-gate  */
5167c478bd9Sstevel@tonic-gate 
5175679c89fSjv227347 /*
5185679c89fSjv227347  * The physical system's host identifier, expressed as a decimal string.
5195679c89fSjv227347  * Code should only directly access this value when writing to it (setting the
5205679c89fSjv227347  * physical system's host identifier).  Code that reads the physical system's
5215679c89fSjv227347  * host identifier should use zone_get_hostid(NULL) instead.
5225679c89fSjv227347  */
5235679c89fSjv227347 char hw_serial[HW_HOSTID_LEN] = "0";
5245679c89fSjv227347 
5257c478bd9Sstevel@tonic-gate #if defined(__sparc)
5267c478bd9Sstevel@tonic-gate 
5277c478bd9Sstevel@tonic-gate /*
5287c478bd9Sstevel@tonic-gate  * On sparc machines, read hw_serial from the firmware at boot time
52987ea2c5cSAnil udupa  * and simply assert Oracle is the hardware provider.
5307c478bd9Sstevel@tonic-gate  */
5317c478bd9Sstevel@tonic-gate char architecture[] = "sparcv9";
5327c478bd9Sstevel@tonic-gate char architecture_32[] = "sparc";
53387ea2c5cSAnil udupa char hw_provider[] = "Oracle Corporation";
5347c478bd9Sstevel@tonic-gate 
5357c478bd9Sstevel@tonic-gate #elif defined(__i386)
5367c478bd9Sstevel@tonic-gate 
5377c478bd9Sstevel@tonic-gate /*
5387c478bd9Sstevel@tonic-gate  * On x86 machines, read hw_serial, hw_provider and srpc_domain from
5397c478bd9Sstevel@tonic-gate  * /etc/bootrc at boot time.
5407c478bd9Sstevel@tonic-gate  */
5417c478bd9Sstevel@tonic-gate char architecture[] = "i386";
5427c478bd9Sstevel@tonic-gate char architecture_32[] = "i386";
5437c478bd9Sstevel@tonic-gate char hw_provider[SYS_NMLN] = "";
5447c478bd9Sstevel@tonic-gate 
5457c478bd9Sstevel@tonic-gate #elif defined(__amd64)
5467c478bd9Sstevel@tonic-gate 
5477c478bd9Sstevel@tonic-gate /*
5487c478bd9Sstevel@tonic-gate  * On amd64 machines, read hw_serial, hw_provider and srpc_domain from
5497c478bd9Sstevel@tonic-gate  * /etc/bootrc at boot time.
5507c478bd9Sstevel@tonic-gate  */
5517c478bd9Sstevel@tonic-gate char architecture[] = "amd64";
5527c478bd9Sstevel@tonic-gate char architecture_32[] = "i386";
5537c478bd9Sstevel@tonic-gate char hw_provider[SYS_NMLN] = "";
5547c478bd9Sstevel@tonic-gate 
5557c478bd9Sstevel@tonic-gate #else
5567c478bd9Sstevel@tonic-gate #error "unknown processor architecture"
5577c478bd9Sstevel@tonic-gate #endif
5587c478bd9Sstevel@tonic-gate 
5597c478bd9Sstevel@tonic-gate char srpc_domain[SYS_NMLN] = "";
5607c478bd9Sstevel@tonic-gate char platform[SYS_NMLN] = "";	/* read from the devinfo root node */
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate /* Initialize isa_list */
5637c478bd9Sstevel@tonic-gate char *isa_list = architecture;
5647c478bd9Sstevel@tonic-gate 
5657c478bd9Sstevel@tonic-gate static pgcnt_t original_physmem = 0;
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate #define	MIN_DEFAULT_MAXUSERS	8u
5687c478bd9Sstevel@tonic-gate #define	MAX_DEFAULT_MAXUSERS	2048u
5697c478bd9Sstevel@tonic-gate #define	MAX_MAXUSERS		4096u
5707c478bd9Sstevel@tonic-gate 
5717c478bd9Sstevel@tonic-gate void
5727c478bd9Sstevel@tonic-gate param_preset(void)
5737c478bd9Sstevel@tonic-gate {
5747c478bd9Sstevel@tonic-gate 	original_physmem = physmem;
5757c478bd9Sstevel@tonic-gate }
5767c478bd9Sstevel@tonic-gate 
5777c478bd9Sstevel@tonic-gate void
5787c478bd9Sstevel@tonic-gate param_calc(int platform_max_nprocs)
5797c478bd9Sstevel@tonic-gate {
5807c478bd9Sstevel@tonic-gate 	/*
5817c478bd9Sstevel@tonic-gate 	 * Default to about one "user" per megabyte, taking into
5827c478bd9Sstevel@tonic-gate 	 * account both physical and virtual constraints.
5837c478bd9Sstevel@tonic-gate 	 * Note: 2^20 is a meg; shifting right by (20 - PAGESHIFT)
5847c478bd9Sstevel@tonic-gate 	 * converts pages to megs without integer overflow.
5857c478bd9Sstevel@tonic-gate 	 */
5864944b02eSkchow #if defined(__sparc)
5877c478bd9Sstevel@tonic-gate 	if (physmem > original_physmem) {
5887c478bd9Sstevel@tonic-gate 		physmem = original_physmem;
5897c478bd9Sstevel@tonic-gate 		cmn_err(CE_NOTE, "physmem limited to %ld", physmem);
5907c478bd9Sstevel@tonic-gate 	}
5914944b02eSkchow #endif
5927c478bd9Sstevel@tonic-gate 	if (maxusers == 0) {
5937c478bd9Sstevel@tonic-gate 		pgcnt_t physmegs = physmem >> (20 - PAGESHIFT);
5947c478bd9Sstevel@tonic-gate 		pgcnt_t virtmegs = vmem_size(heap_arena, VMEM_FREE) >> 20;
5957c478bd9Sstevel@tonic-gate 		maxusers = MIN(MAX(MIN(physmegs, virtmegs),
5967c478bd9Sstevel@tonic-gate 		    MIN_DEFAULT_MAXUSERS), MAX_DEFAULT_MAXUSERS);
5977c478bd9Sstevel@tonic-gate 	}
5987c478bd9Sstevel@tonic-gate 	if (maxusers > MAX_MAXUSERS) {
5997c478bd9Sstevel@tonic-gate 		maxusers = MAX_MAXUSERS;
6007c478bd9Sstevel@tonic-gate 		cmn_err(CE_NOTE, "maxusers limited to %d", MAX_MAXUSERS);
6017c478bd9Sstevel@tonic-gate 	}
6027c478bd9Sstevel@tonic-gate 
6037c478bd9Sstevel@tonic-gate 	if (ngroups_max > NGROUPS_MAX_DEFAULT)
60435b1ab99Sjosephb 		cmn_err(CE_WARN, "ngroups_max of %d > %d, NFS AUTH_SYS will"
60535b1ab99Sjosephb 		    " not work properly", ngroups_max, NGROUPS_MAX_DEFAULT);
6067c478bd9Sstevel@tonic-gate 
6077c478bd9Sstevel@tonic-gate #ifdef DEBUG
6087c478bd9Sstevel@tonic-gate 	/*
6097c478bd9Sstevel@tonic-gate 	 * The purpose of maxusers is to prevent memory overcommit.
6107c478bd9Sstevel@tonic-gate 	 * DEBUG kernels take more space, so reduce maxusers a bit.
6117c478bd9Sstevel@tonic-gate 	 */
6127c478bd9Sstevel@tonic-gate 	maxusers = (3 * maxusers) / 4;
6137c478bd9Sstevel@tonic-gate #endif
6147c478bd9Sstevel@tonic-gate 
6157c478bd9Sstevel@tonic-gate 	/*
6167c478bd9Sstevel@tonic-gate 	 * We need to dynamically change any variables now so that
6177c478bd9Sstevel@tonic-gate 	 * the setting of maxusers and pidmax propagate to the other
6187c478bd9Sstevel@tonic-gate 	 * variables that are dependent on them.
6197c478bd9Sstevel@tonic-gate 	 */
6207c478bd9Sstevel@tonic-gate 	if (reserved_procs == 0)
6217c478bd9Sstevel@tonic-gate 		reserved_procs = 5;
6227c478bd9Sstevel@tonic-gate 	if (pidmax < reserved_procs || pidmax > MAX_MAXPID)
6237c478bd9Sstevel@tonic-gate 		maxpid = MAX_MAXPID;
6247c478bd9Sstevel@tonic-gate 	else
6257c478bd9Sstevel@tonic-gate 		maxpid = pidmax;
6267c478bd9Sstevel@tonic-gate 
6277c478bd9Sstevel@tonic-gate 	/*
6287c478bd9Sstevel@tonic-gate 	 * This allows platform-dependent code to constrain the maximum
6297c478bd9Sstevel@tonic-gate 	 * number of processes allowed in case there are e.g. VM limitations
6307c478bd9Sstevel@tonic-gate 	 * with how many contexts are available.
6317c478bd9Sstevel@tonic-gate 	 */
6327c478bd9Sstevel@tonic-gate 	if (max_nprocs == 0)
6337c478bd9Sstevel@tonic-gate 		max_nprocs = (10 + 16 * maxusers);
6347c478bd9Sstevel@tonic-gate 	if (platform_max_nprocs > 0 && max_nprocs > platform_max_nprocs)
6357c478bd9Sstevel@tonic-gate 		max_nprocs = platform_max_nprocs;
6367c478bd9Sstevel@tonic-gate 	if (max_nprocs > maxpid)
6377c478bd9Sstevel@tonic-gate 		max_nprocs = maxpid;
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate 	if (maxuprc == 0)
6407c478bd9Sstevel@tonic-gate 		maxuprc = (max_nprocs - reserved_procs);
6417c478bd9Sstevel@tonic-gate }
6427c478bd9Sstevel@tonic-gate 
6437c478bd9Sstevel@tonic-gate void
6447c478bd9Sstevel@tonic-gate param_init(void)
6457c478bd9Sstevel@tonic-gate {
6467c478bd9Sstevel@tonic-gate 	/*
6477c478bd9Sstevel@tonic-gate 	 * Set each individual element of struct var v to be the
6487c478bd9Sstevel@tonic-gate 	 * default value. This is done this way
6497c478bd9Sstevel@tonic-gate 	 * so that a user can set the assigned integer value in the
6507c478bd9Sstevel@tonic-gate 	 * /etc/system file *IF* tuning is needed.
6517c478bd9Sstevel@tonic-gate 	 */
6527c478bd9Sstevel@tonic-gate 	v.v_proc = max_nprocs;	/* v_proc - max # of processes system wide */
6537c478bd9Sstevel@tonic-gate 	v.v_maxupttl = max_nprocs - reserved_procs;
6547c478bd9Sstevel@tonic-gate 	v.v_maxsyspri = (int)maxclsyspri;  /* max global pri for sysclass */
6557c478bd9Sstevel@tonic-gate 	v.v_maxup = MIN(maxuprc, v.v_maxupttl); /* max procs per user */
6567c478bd9Sstevel@tonic-gate 	v.v_autoup = autoup;	/* v_autoup - delay for delayed writes */
6577c478bd9Sstevel@tonic-gate 
6587c478bd9Sstevel@tonic-gate 	/*
6597c478bd9Sstevel@tonic-gate 	 * Set each individual element of struct tune to be the
6607c478bd9Sstevel@tonic-gate 	 * default value. Each struct element This is done this way
6617c478bd9Sstevel@tonic-gate 	 *  so that a user can set the assigned integer value in the
6627c478bd9Sstevel@tonic-gate 	 * /etc/system file *IF* tuning is needed.
6637c478bd9Sstevel@tonic-gate 	 */
6647c478bd9Sstevel@tonic-gate 	tune.t_gpgslo = tune_t_gpgslo;
6657c478bd9Sstevel@tonic-gate 	tune.t_fsflushr = tune_t_fsflushr;
6667c478bd9Sstevel@tonic-gate 	tune.t_minarmem = tune_t_minarmem;
6677c478bd9Sstevel@tonic-gate 	tune.t_minasmem = tune_t_minasmem;
6687c478bd9Sstevel@tonic-gate 	tune.t_flckrec = tune_t_flckrec;
6697c478bd9Sstevel@tonic-gate 
6707c478bd9Sstevel@tonic-gate 	/*
6717c478bd9Sstevel@tonic-gate 	 * Initialization for file descriptors to correct mistaken settings in
6727c478bd9Sstevel@tonic-gate 	 * /etc/system.  Initialization of limits performed by resource control
6737c478bd9Sstevel@tonic-gate 	 * system.
6747c478bd9Sstevel@tonic-gate 	 */
6757c478bd9Sstevel@tonic-gate 	if (rlim_fd_cur > rlim_fd_max)
6767c478bd9Sstevel@tonic-gate 		rlim_fd_cur = rlim_fd_max;
6777c478bd9Sstevel@tonic-gate 
6787c478bd9Sstevel@tonic-gate 	/*
6797c478bd9Sstevel@tonic-gate 	 * calculations needed if hz was set in /etc/system
6807c478bd9Sstevel@tonic-gate 	 */
6817c478bd9Sstevel@tonic-gate 	if (hires_tick)
6827c478bd9Sstevel@tonic-gate 		hz = hires_hz;
6837c478bd9Sstevel@tonic-gate 
6847c478bd9Sstevel@tonic-gate 	tick_per_msec = hz / MILLISEC;
6857c478bd9Sstevel@tonic-gate 	msec_per_tick = MILLISEC / hz;
6867c478bd9Sstevel@tonic-gate 	usec_per_tick = MICROSEC / hz;
6877c478bd9Sstevel@tonic-gate 	nsec_per_tick = NANOSEC / hz;
6887c478bd9Sstevel@tonic-gate 	max_hres_adj = nsec_per_tick >> ADJ_SHIFT;
689d3d50737SRafael Vanoni 
690d3d50737SRafael Vanoni 	/*
691d3d50737SRafael Vanoni 	 * Consumers of relative timedwait functions must specify how accurately
692d3d50737SRafael Vanoni 	 * the given timeout must expire. This is currently TR_CLOCK_TICK for
693d3d50737SRafael Vanoni 	 * the vast majority of consumers, but nsec_per_tick becomes an
694d3d50737SRafael Vanoni 	 * artificial value in a tickless world. Each caller of such routines
695d3d50737SRafael Vanoni 	 * should re-evaluate their usage and specify the appropriate
696d3d50737SRafael Vanoni 	 * resolution.
697d3d50737SRafael Vanoni 	 */
698d3d50737SRafael Vanoni 	time_res[TR_NANOSEC] = SEC;
699d3d50737SRafael Vanoni 	time_res[TR_MICROSEC] = MILLISEC;
700d3d50737SRafael Vanoni 	time_res[TR_MILLISEC] = MICROSEC;
701d3d50737SRafael Vanoni 	time_res[TR_SEC] = NANOSEC;
702d3d50737SRafael Vanoni 	time_res[TR_CLOCK_TICK] = nsec_per_tick;
7037c478bd9Sstevel@tonic-gate }
7047c478bd9Sstevel@tonic-gate 
7057c478bd9Sstevel@tonic-gate /*
7067c478bd9Sstevel@tonic-gate  * Validate tuneable parameters following /etc/system processing,
7077c478bd9Sstevel@tonic-gate  * but prior to param_init().
7087c478bd9Sstevel@tonic-gate  */
7097c478bd9Sstevel@tonic-gate void
7107c478bd9Sstevel@tonic-gate param_check(void)
7117c478bd9Sstevel@tonic-gate {
71235b1ab99Sjosephb #if defined(__x86)
71335b1ab99Sjosephb 	if (physmem != original_physmem) {
71435b1ab99Sjosephb 		cmn_err(CE_NOTE, "physmem cannot be modified to 0x%lx"
71535b1ab99Sjosephb 		    " via /etc/system. Please use eeprom(1M) instead.",
71635b1ab99Sjosephb 		    physmem);
71735b1ab99Sjosephb 		physmem = original_physmem;
71835b1ab99Sjosephb 	}
71935b1ab99Sjosephb #endif
72067dbe2beSCasper H.S. Dik 	if (ngroups_max < NGROUPS_UMIN)
72167dbe2beSCasper H.S. Dik 		ngroups_max = NGROUPS_UMIN;
72267dbe2beSCasper H.S. Dik 	if (ngroups_max > NGROUPS_UMAX)
72367dbe2beSCasper H.S. Dik 		ngroups_max = NGROUPS_UMAX;
72467dbe2beSCasper H.S. Dik 
72567dbe2beSCasper H.S. Dik 	/* If we have many groups then the ucred proto message also grows. */
72667dbe2beSCasper H.S. Dik 	if (ngroups_max > NGROUPS_OLDMAX &&
72767dbe2beSCasper H.S. Dik 	    strctlsz < (ngroups_max - NGROUPS_OLDMAX) * sizeof (gid_t) + 1024) {
72867dbe2beSCasper H.S. Dik 		strctlsz = (ngroups_max - NGROUPS_OLDMAX) * sizeof (gid_t) +
72967dbe2beSCasper H.S. Dik 		    1024;
73067dbe2beSCasper H.S. Dik 	}
7317c478bd9Sstevel@tonic-gate 
7327c478bd9Sstevel@tonic-gate 	if (autoup <= 0) {
7337c478bd9Sstevel@tonic-gate 		autoup = DEFAULT_AUTOUP;
7347c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "autoup <= 0; defaulting to %d", autoup);
7357c478bd9Sstevel@tonic-gate 	}
7367c478bd9Sstevel@tonic-gate 
7377c478bd9Sstevel@tonic-gate 	if (tune_t_fsflushr <= 0) {
7387c478bd9Sstevel@tonic-gate 		tune_t_fsflushr = DEFAULT_TUNE_T_FSFLUSHR;
7397c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "tune_t_fsflushr <= 0; defaulting to %d",
7407c478bd9Sstevel@tonic-gate 		    tune_t_fsflushr);
7417c478bd9Sstevel@tonic-gate 	}
7427c478bd9Sstevel@tonic-gate 
7437c478bd9Sstevel@tonic-gate 	if (jump_pid < 0 || jump_pid >= pidmax) {
7447c478bd9Sstevel@tonic-gate 		jump_pid = 0;
7457c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "jump_pid < 0 or >= pidmax; ignored");
7467c478bd9Sstevel@tonic-gate 	}
7477c478bd9Sstevel@tonic-gate 
7487c478bd9Sstevel@tonic-gate 	if (snoop_interval < SNOOP_INTERVAL_MIN) {
7497c478bd9Sstevel@tonic-gate 		snoop_interval = SNOOP_INTERVAL_DEFAULT;
7507c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "snoop_interval < minimum (%d); defaulting"
7517c478bd9Sstevel@tonic-gate 		    " to %d", SNOOP_INTERVAL_MIN, SNOOP_INTERVAL_DEFAULT);
7527c478bd9Sstevel@tonic-gate 	}
7537c478bd9Sstevel@tonic-gate }
754