Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zoneadmd/mcap.c
          +++ new/usr/src/cmd/zoneadmd/mcap.c
↓ open down ↓ 122 lines elided ↑ open up ↑
 123  123   *    phys-mcap-no-pf-throttle
 124  124   *      type: boolean
 125  125   *      true disables page fault throttling when over
 126  126   */
 127  127  #define TUNE_CMD        "phys-mcap-cmd"
 128  128  #define TUNE_NVMU       "phys-mcap-no-vmusage"
 129  129  #define TUNE_NPAGE      "phys-mcap-no-pageout"
 130  130  #define TUNE_NPFTHROT   "phys-mcap-no-pf-throttle"
 131  131  
 132  132  /*
      133 + * The large mapping value was derived empirically by seeing that mappings
      134 + * much bigger than 16mb sometimes take a relatively long time to invalidate
      135 + * (significant fraction of a second).
      136 + */
      137 +#define SEC_INTERIM     4       /* num secs to pause after stopped too long */
      138 +#define MSEC_TOO_LONG   100     /* release proc. after stopped for 100ms */
      139 +#define LARGE_MAPPING   16384   /* >= 16MB in KB - pageout in chunks */
      140 +
      141 +/*
 133  142   * These are only used in get_mem_info but global. We always need scale_rss and
 134  143   * prev_fast_rss to be persistent but we also have the other two global so we
 135  144   * can easily see these with mdb.
 136  145   */
 137  146  uint64_t        scale_rss = 0;
 138  147  uint64_t        prev_fast_rss = 0;
 139  148  uint64_t        fast_rss = 0;
 140  149  uint64_t        accurate_rss = 0;
 141  150  
 142  151  static char     zoneproc[MAXPATHLEN];
↓ open down ↓ 3 lines elided ↑ open up ↑
 146  155  static cond_t   shutdown_cv;
 147  156  static int      shutting_down = 0;
 148  157  static thread_t mcap_tid;
 149  158  static FILE     *debug_log_fp = NULL;
 150  159  static uint64_t zone_rss_cap;           /* RSS cap(KB) */
 151  160  static char     over_cmd[2 * BUFSIZ];   /* same size as zone_attr_value */
 152  161  static boolean_t skip_vmusage = B_FALSE;
 153  162  static boolean_t skip_pageout = B_FALSE;
 154  163  static boolean_t skip_pf_throttle = B_FALSE;
 155  164  
 156      -static zlog_t   *logp;
 157      -
 158  165  static int64_t check_suspend();
 159  166  static void get_mcap_tunables();
 160  167  
 161  168  /*
 162  169   * Structure to hold current state about a process address space that we're
 163  170   * working on.
 164  171   */
 165  172  typedef struct {
 166  173          int pr_curr;            /* the # of the mapping we're working on */
 167  174          int pr_nmap;            /* number of mappings in address space */
↓ open down ↓ 204 lines elided ↑ open up ↑
 372  379  /*
 373  380   * Work through a process paging out mappings until the whole address space was
 374  381   * examined or the excess is < 0.  Return our estimate of the updated excess.
 375  382   */
 376  383  static int64_t
 377  384  pageout_process(pid_t pid, int64_t excess)
 378  385  {
 379  386          int                     psfd;
 380  387          prmap_t                 *pmap;
 381  388          proc_map_t              cur;
 382      -        int                     res;
 383  389          int64_t                 sum_d_rss, d_rss;
 384  390          int64_t                 old_rss;
 385  391          int                     map_cnt;
 386  392          psinfo_t                psinfo;
 387  393          char                    pathbuf[MAXPATHLEN];
 388  394  
 389  395          (void) snprintf(pathbuf, sizeof (pathbuf), "%s/%d/psinfo", zoneproc,
 390  396              pid);
 391  397          if ((psfd = open(pathbuf, O_RDONLY, 0000)) < 0)
 392  398                  return (excess);
↓ open down ↓ 31 lines elided ↑ open up ↑
 424  430  
 425  431          debug("pid %ld: nmap %d sz %dKB rss %lldKB %s\n",
 426  432              pid, cur.pr_nmap, psinfo.pr_size, old_rss, psinfo.pr_psargs);
 427  433  
 428  434          /*
 429  435           * Within the process's address space, attempt to page out mappings.
 430  436           */
 431  437          sum_d_rss = 0;
 432  438          while (excess > 0 && pmap != NULL && !shutting_down) {
 433  439                  /* invalidate the entire mapping */
 434      -                if ((res = pageout_mapping(pid, pmap)) < 0)
      440 +                if (pageout_mapping(pid, pmap) < 0)
 435  441                          debug("pid %ld: mapping 0x%p %ldkb unpageable (%d)\n",
 436      -                            pid, pmap->pr_vaddr, pmap->pr_size / 1024, errno);
      442 +                            pid, (void *)pmap->pr_vaddr,
      443 +                            (long)pmap->pr_size / 1024L, errno);
 437  444  
 438  445                  map_cnt++;
 439  446  
 440  447                  /*
 441  448                   * Re-check the process rss and get the delta.
 442  449                   */
 443  450                  if (pread(psfd, &psinfo, sizeof (psinfo), 0)
 444  451                      != sizeof (psinfo)) {
 445  452                          excess -= old_rss;
 446  453                          goto done;
↓ open down ↓ 693 lines elided ↑ open up ↑
1140 1147          debug("thread shutdown\n");
1141 1148  }
1142 1149  
1143 1150  void
1144 1151  create_mcap_thread(zlog_t *zlogp, zoneid_t id)
1145 1152  {
1146 1153          int             res;
1147 1154  
1148 1155          shutting_down = 0;
1149 1156          zid = id;
1150      -        logp = zlogp;
1151 1157  
1152 1158          /* all but the lx brand currently use /proc */
1153 1159          if (strcmp(brand_name, "lx") == 0) {
1154 1160                  (void) snprintf(zoneproc, sizeof (zoneproc),
1155 1161                      "%s/root/native/proc", zonepath);
1156 1162          } else {
1157 1163                  (void) snprintf(zoneproc, sizeof (zoneproc), "%s/root/proc",
1158 1164                      zonepath);
1159 1165          }
1160 1166  
↓ open down ↓ 22 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX