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