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