Print this page
OS-399 zone phys. mem. cap should be a rctl and have associated kstat

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zonestat/zonestatd/zonestatd.c
          +++ new/usr/src/cmd/zonestat/zonestatd/zonestatd.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  24   25   */
  25   26  #include <alloca.h>
  26   27  #include <assert.h>
  27   28  #include <dirent.h>
  28   29  #include <dlfcn.h>
  29   30  #include <door.h>
  30   31  #include <errno.h>
  31   32  #include <exacct.h>
  32   33  #include <ctype.h>
  33   34  #include <fcntl.h>
↓ open down ↓ 2149 lines elided ↑ open up ↑
2183 2184          rctlblk_t *rblk;
2184 2185  
2185 2186          rblk = (rctlblk_t *)alloca(rctlblk_size());
2186 2187          if (getrctl(name, NULL, rblk, RCTL_USAGE)
2187 2188              != 0) {
2188 2189                  return (0);
2189 2190          }
2190 2191          return (rctlblk_get_value(rblk));
2191 2192  }
2192 2193  
2193      -#define ZSD_NUM_RCTL_VALS 19
     2194 +#define ZSD_NUM_RCTL_VALS 20
2194 2195  
2195 2196  /*
2196 2197   * Fetch the limit information for a zone.  This uses zone_enter() as the
2197 2198   * getrctl(2) system call only returns rctl information for the zone of
2198 2199   * the caller.
2199 2200   */
2200 2201  static int
2201 2202  zsd_get_zone_caps(zsd_ctl_t *ctl, zsd_zone_t *zone, uint64_t *cpu_shares,
2202 2203      uint64_t *cpu_cap, uint64_t *ram_cap, uint64_t *locked_cap,
2203 2204      uint64_t *vm_cap, uint64_t *processes_cap, uint64_t *processes,
↓ open down ↓ 26 lines elided ↑ open up ↑
2230 2231          *lofi_cap = ZS_LIMIT_NONE;
2231 2232  
2232 2233          *processes = 0;
2233 2234          *lwps = 0;
2234 2235          *shm = 0;
2235 2236          *shmids = 0;
2236 2237          *semids = 0;
2237 2238          *msgids = 0;
2238 2239          *lofi = 0;
2239 2240  
2240      -        /* Get the ram cap first since it is a zone attr */
2241      -        ret = zone_getattr(zone->zsz_id, ZONE_ATTR_PHYS_MCAP,
2242      -            ram_cap, sizeof (*ram_cap));
2243      -        if (ret < 0 || *ram_cap == 0)
2244      -                *ram_cap = ZS_LIMIT_NONE;
2245      -
2246 2241          /* Get the zone's default scheduling class */
2247 2242          ret = zone_getattr(zone->zsz_id, ZONE_ATTR_SCHED_CLASS,
2248 2243              class, sizeof (class));
2249 2244          if (ret < 0)
2250 2245                  return (-1);
2251 2246  
2252 2247          *sched = zsd_schedname2int(class, 0);
2253 2248  
2254 2249          /* rctl caps must be fetched from within the zone */
2255 2250          if (pipe(p) != 0)
↓ open down ↓ 35 lines elided ↑ open up ↑
2291 2286                  vals[i++] = zsd_get_zone_rctl_limit("zone.max-shm-memory");
2292 2287                  vals[i++] = zsd_get_zone_rctl_usage("zone.max-shm-memory");
2293 2288                  vals[i++] = zsd_get_zone_rctl_limit("zone.max-shm-ids");
2294 2289                  vals[i++] = zsd_get_zone_rctl_usage("zone.max-shm-ids");
2295 2290                  vals[i++] = zsd_get_zone_rctl_limit("zone.max-sem-ids");
2296 2291                  vals[i++] = zsd_get_zone_rctl_usage("zone.max-sem-ids");
2297 2292                  vals[i++] = zsd_get_zone_rctl_limit("zone.max-msg-ids");
2298 2293                  vals[i++] = zsd_get_zone_rctl_usage("zone.max-msg-ids");
2299 2294                  vals[i++] = zsd_get_zone_rctl_limit("zone.max-lofi");
2300 2295                  vals[i++] = zsd_get_zone_rctl_usage("zone.max-lofi");
     2296 +                vals[i++] = zsd_get_zone_rctl_usage("zone.max-physical-memory");
2301 2297  
2302 2298                  if (write(p[1], vals, ZSD_NUM_RCTL_VALS * sizeof (uint64_t)) !=
2303 2299                      ZSD_NUM_RCTL_VALS * sizeof (uint64_t)) {
2304 2300                          (void) close(p[1]);
2305 2301                          _exit(1);
2306 2302                  }
2307 2303  
2308 2304                  (void) close(p[1]);
2309 2305                  _exit(0);
2310 2306          }
↓ open down ↓ 24 lines elided ↑ open up ↑
2335 2331          *shm_cap = vals[i++];
2336 2332          *shm = vals[i++];
2337 2333          *shmids_cap = vals[i++];
2338 2334          *shmids = vals[i++];
2339 2335          *semids_cap = vals[i++];
2340 2336          *semids = vals[i++];
2341 2337          *msgids_cap = vals[i++];
2342 2338          *msgids = vals[i++];
2343 2339          *lofi_cap = vals[i++];
2344 2340          *lofi = vals[i++];
     2341 +        *ram_cap = vals[i++];
2345 2342  
2346 2343          /* Interpret maximum values as no cap */
2347 2344          if (*cpu_cap == UINT32_MAX || *cpu_cap == 0)
2348 2345                  *cpu_cap = ZS_LIMIT_NONE;
2349 2346          if (*processes_cap == sys->zss_processes_max)
2350 2347                  *processes_cap = ZS_LIMIT_NONE;
2351 2348          if (*lwps_cap == sys->zss_lwps_max)
2352 2349                  *lwps_cap = ZS_LIMIT_NONE;
2353 2350          if (*shm_cap == sys->zss_shm_max)
2354 2351                  *shm_cap = ZS_LIMIT_NONE;
↓ open down ↓ 2522 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX