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