Print this page
        
*** 20,30 ****
   */
  
  /*
   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
   * Use is subject to license terms.
!  * Copyright 2012 Joyent, Inc.  All rights reserved.
   */
  
  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  /*        All Rights Reserved   */
  
--- 20,30 ----
   */
  
  /*
   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
   * Use is subject to license terms.
!  * Copyright 2011 Joyent, Inc.  All rights reserved.
   */
  
  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  /*        All Rights Reserved   */
  
*** 178,204 ****
                  return (physinstalled);
  
          case _CONFIG_AVPHYS_PAGES:
                  /*
                   * If the non-global zone has a phys. memory cap, use
!                  * the phys. memory cap - zone's rss.  We always
                   * report the system-wide value for the global zone, even
!                  * though memory capping can be used on the global zone too.
!                  * We use the cached value for the RSS since vm_getusage()
!                  * is so expensive and we don't need this value to be exact.
                   */
                  if (!INGLOBALZONE(curproc) &&
                      curproc->p_zone->zone_phys_mem_ctl != UINT64_MAX) {
                          pgcnt_t cap, rss, free;
  
                          cap = btop(curproc->p_zone->zone_phys_mem_ctl);
                          if (cap > physinstalled)
                                  return (freemem);
  
!                         rss = btop(curproc->p_zone->zone_phys_mem);
                          /*
!                          * Because this is a soft cap, it is possible
                           * for rss to be temporarily over the cap.
                           */
                          if (cap > rss)
                                  free = cap - rss;
                          else
--- 178,207 ----
                  return (physinstalled);
  
          case _CONFIG_AVPHYS_PAGES:
                  /*
                   * If the non-global zone has a phys. memory cap, use
!                  * the phys. memory cap - zone's current rss.  We always
                   * report the system-wide value for the global zone, even
!                  * though rcapd can be used on the global zone too.
                   */
                  if (!INGLOBALZONE(curproc) &&
                      curproc->p_zone->zone_phys_mem_ctl != UINT64_MAX) {
                          pgcnt_t cap, rss, free;
+                         vmusage_t in_use;
+                         size_t cnt = 1;
  
                          cap = btop(curproc->p_zone->zone_phys_mem_ctl);
                          if (cap > physinstalled)
                                  return (freemem);
  
!                         if (vm_getusage(VMUSAGE_ZONE, 1, &in_use, &cnt,
!                             FKIOCTL) != 0)
!                                 in_use.vmu_rss_all = 0;
!                         rss = btop(in_use.vmu_rss_all);
                          /*
!                          * Because rcapd implements a soft cap, it is possible
                           * for rss to be temporarily over the cap.
                           */
                          if (cap > rss)
                                  free = cap - rss;
                          else