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