Print this page
NEX-1974 Support for more than 16 groups with AUTH_SYS
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
re #13613 rb4516 Tunables needs volatile keyword


  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 
  70 #include <sys/vmem.h>
  71 #include <sys/clock.h>
  72 #include <sys/clock_impl.h>
  73 #include <sys/serializer.h>
  74 
  75 /*
  76  * The following few lines describe generic things that must be compiled
  77  * into the booted executable (unix) rather than genunix or any other
  78  * module because they're required by crash dump readers, etc.
  79  */
  80 struct modctl modules;          /* head of linked list of modules */
  81 char *default_path;             /* default module loading path */
  82 struct swapinfo *swapinfo;      /* protected by the swapinfo_lock */
  83 proc_t *practive;               /* active process list */
  84 uint_t nproc;                   /* current number of processes */
  85 proc_t p0;                      /* process 0 */
  86 struct plock p0lock;            /* p0's p_lock */
  87 klwp_t lwp0;                    /* t0's lwp */
  88 task_t *task0p;                 /* task 0 */


 142  *     Similarly, if hz < 100 then hz / 100 == 0 and stuff will break.
 143  *
 144  * (2) If hz <= 1000, it should be both a multiple of 100 and a
 145  *      divisor of 1000.
 146  *
 147  * (3) If hz > 1000, it should be both a multiple of 1000 and a
 148  *      divisor of MICROSEC.
 149  *
 150  * Thus the only reasonable values of hz (i.e. the values that won't
 151  * cause roundoff error) are: 100, 200, 500, 1000, 2000, 4000, 5000,
 152  * 8000, 10000, 20000, 25000, 40000, 50000, 100000, 125000, 200000,
 153  * 250000, 500000, 1000000.  As of this writing (1996) a clock rate
 154  * of more than about 10 kHz seems utterly ridiculous, although
 155  * this observation will no doubt seem quaintly amusing one day.
 156  */
 157 #define HIRES_HZ_DEFAULT        1000
 158 
 159 int hz = HZ_DEFAULT;
 160 int hires_hz = HIRES_HZ_DEFAULT;
 161 
 162 int hires_tick = 0;
 163 int cpu_decay_factor = 10;      /* this is no longer tied to clock */
 164 int max_hres_adj;       /* maximum adjustment of hrtime per tick */
 165 int tick_per_msec;      /* clock ticks per millisecond (zero if hz < 1000) */
 166 
 167 /*
 168  * Milliseconds, Microseconds, and Nanoseconds per clock tick
 169  *
 170  * Note:
 171  *  msec_per_tick is zero if hz > 1000
 172  */
 173 int msec_per_tick;
 174 int usec_per_tick;
 175 int nsec_per_tick;
 176 
 177 /*
 178  * Time Resolution values. These are defined in condvar.h and initialized in
 179  * param_init(). Consumers of cv_reltimedwait() and cv_reltimedwait_sig()
 180  * need to specify how accurate the timeout argument should be through
 181  * one of these values. The intention is to allow the underlying implementation
 182  * to anticipate or defer the expiration of timeouts, preventing unnecessary


 250 #if defined(__sparc)
 251         extern void siron_mp_init();
 252 #endif
 253 
 254 /*
 255  * Any per cpu resources should be initialized via
 256  * an entry in mp_init_tbl().
 257  */
 258 void    (*mp_init_tbl[])(void) = {
 259         ftrace_init,
 260         cyclic_mp_init,
 261 #if defined(__sparc)
 262         siron_mp_init,
 263 #endif
 264         clock_tick_mp_init,
 265         cu_init,
 266         callout_mp_init,
 267         0
 268 };
 269 
 270 int maxusers;           /* kitchen-sink knob for dynamic configuration */
 271 
 272 /*
 273  * pidmax -- highest pid value assigned by the system
 274  * Settable in /etc/system
 275  */
 276 int pidmax = DEFAULT_MAXPID;
 277 
 278 /*
 279  * jump_pid - if set, this value is where pid numbers should start
 280  * after the first few system pids (0-3) are used.  If 0, pids are
 281  * chosen in the usual way. This variable can be used to quickly
 282  * create large pids (by setting it to 100000, for example). pids
 283  * less than this value will never be chosen.
 284  */
 285 pid_t jump_pid = DEFAULT_JUMPPID;
 286 
 287 /*
 288  * autoup -- used in struct var for dynamic config of the age a delayed-write
 289  * buffer must be in seconds before bdflush will write it out.
 290  */
 291 #define DEFAULT_AUTOUP  30
 292 int autoup = DEFAULT_AUTOUP;
 293 
 294 /*
 295  * bufhwm -- tuneable variable for struct var for v_bufhwm.
 296  * high water mark for buffer cache mem usage in units of K bytes.
 297  *
 298  * bufhwm_pct -- ditto, but given in % of physmem.
 299  */
 300 int bufhwm = 0;
 301 int bufhwm_pct = 0;
 302 
 303 /*
 304  * Process table.
 305  */
 306 int maxpid;
 307 int max_nprocs;         /* set in param_init() */
 308 int maxuprc;            /* set in param_init() */
 309 int reserved_procs;
 310 int nthread = 1;
 311 
 312 /*
 313  * UFS tunables
 314  */
 315 int ufs_ninode;         /* declared here due to backwards compatibility */
 316 int ndquot;             /* declared here due to backwards compatibility */
 317 
 318 /*
 319  * Exec switch table. This is used by the generic exec module
 320  * to switch out to the desired executable type, based on the
 321  * magic number. The currently supported types are ELF, a.out
 322  * (both NMAGIC and ZMAGIC), interpreter (#!) files,
 323  * and Java executables.
 324  */
 325 /*
 326  * Magic numbers
 327  */
 328 short elfmagic = 0x7f45;
 329 short intpmagic = 0x2321;
 330 short jmagic = 0x504b;
 331 
 332 #if defined(__sparc)
 333 short aout_nmagic = NMAGIC;
 334 short aout_zmagic = ZMAGIC;
 335 short aout_omagic = OMAGIC;
 336 #endif


 393 #if defined(__sparc)
 394         { aout_zmagicstr, 2, 2, NULL, NULL, NULL },
 395         { aout_nmagicstr, 2, 2, NULL, NULL, NULL },
 396         { aout_omagicstr, 2, 2, NULL, NULL, NULL },
 397 #endif
 398         { nomagicstr, 0, 0, NULL, NULL, NULL },
 399         { nomagicstr, 0, 0, NULL, NULL, NULL },
 400         { nomagicstr, 0, 0, NULL, NULL, NULL },
 401         { nomagicstr, 0, 0, NULL, NULL, NULL }
 402 };
 403 int nexectype = sizeof (execsw) / sizeof (execsw[0]);   /* # of exec types */
 404 kmutex_t execsw_lock;   /* Used for allocation of execsw entries */
 405 
 406 /*
 407  * symbols added to make changing proc.max-file-descriptor
 408  * simple via /etc/system
 409  */
 410 #define RLIM_FD_CUR 0x10000
 411 #define RLIM_FD_MAX 0x10000
 412 
 413 uint_t rlim_fd_cur = RLIM_FD_CUR;
 414 uint_t rlim_fd_max = RLIM_FD_MAX;
 415 
 416 /*
 417  * (Default resource limits were formerly declared here, but are now provided by
 418  * the more general resource controls framework.)
 419  */
 420 
 421 /*
 422  * STREAMS tunables
 423  */
 424 int     nstrpush = 9;           /* maximum # of modules/drivers on a stream */
 425 ssize_t strctlsz = 1024;        /* maximum size of user-generated M_PROTO */
 426 ssize_t strmsgsz = 0x10000;     /* maximum size of user-generated M_DATA */
 427                                 /* for `strmsgsz', zero means unlimited */
 428 /*
 429  * Filesystem tunables
 430  */
 431 int     rstchown = 1;           /* POSIX_CHOWN_RESTRICTED is enabled */
 432 int     ngroups_max = NGROUPS_MAX_DEFAULT;
 433 
 434 /*
 435  * generic scheduling stuff
 436  *
 437  * Configurable parameters for RT and TS are in the respective
 438  * scheduling class modules.
 439  */
 440 
 441 pri_t maxclsyspri = MAXCLSYSPRI;
 442 pri_t minclsyspri = MINCLSYSPRI;
 443 char sys_name[] = "SYS";
 444 
 445 extern pri_t sys_init(id_t, int, classfuncs_t **);
 446 extern classfuncs_t sys_classfuncs;
 447 
 448 sclass_t sclass[] = {
 449         { "SYS",        sys_init,       &sys_classfuncs, STATIC_SCHED, 0 },
 450         { "",   NULL,   NULL,   NULL, 0 },
 451         { "",   NULL,   NULL,   NULL, 0 },


 469  * Tunable system parameters.
 470  */
 471 
 472 /*
 473  * The integers tune_* are done this way so that the tune
 474  * data structure may be "tuned" if necessary from the /etc/system
 475  * file. The tune data structure is initialized in param_init();
 476  */
 477 
 478 tune_t tune;
 479 
 480 /*
 481  * If freemem < t_getpgslow, then start to steal pages from processes.
 482  */
 483 int tune_t_gpgslo = 25;
 484 
 485 /*
 486  * Rate at which fsflush is run, in seconds.
 487  */
 488 #define DEFAULT_TUNE_T_FSFLUSHR 1
 489 int tune_t_fsflushr = DEFAULT_TUNE_T_FSFLUSHR;
 490 
 491 /*
 492  * The minimum available resident (not swappable) memory to maintain
 493  * in order to avoid deadlock.  In pages.
 494  */
 495 int tune_t_minarmem = 25;
 496 
 497 /*
 498  * The minimum available swappable memory to maintain in order to avoid
 499  * deadlock.  In pages.
 500  */
 501 int tune_t_minasmem = 25;
 502 
 503 int tune_t_flckrec = 512;       /* max # of active frlocks */
 504 
 505 /*
 506  * Number of currently available pages that cannot be 'locked'
 507  * This is set in init_pages_pp_maximum, and must be initialized
 508  * to zero here to detect an override in /etc/system
 509  */
 510 pgcnt_t pages_pp_maximum = 0;
 511 
 512 int boothowto;                  /* boot flags passed to kernel */
 513 struct var v;                   /* System Configuration Information */
 514 
 515 /*
 516  * System Configuration Information
 517  */
 518 
 519 /*
 520  * The physical system's host identifier, expressed as a decimal string.
 521  * Code should only directly access this value when writing to it (setting the
 522  * physical system's host identifier).  Code that reads the physical system's
 523  * host identifier should use zone_get_hostid(NULL) instead.
 524  */
 525 char hw_serial[HW_HOSTID_LEN] = "0";
 526 
 527 #if defined(__sparc)
 528 
 529 /*
 530  * On sparc machines, read hw_serial from the firmware at boot time




  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 */


 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


 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


 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 },


 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