5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  28 /*        All Rights Reserved   */
  29 
  30 #include <sys/param.h>
  31 #include <sys/types.h>
  32 #include <sys/sysmacros.h>
  33 #include <sys/systm.h>
  34 #include <sys/tuneable.h>
  35 #include <sys/errno.h>
  36 #include <sys/var.h>
  37 #include <sys/signal.h>
  38 #include <sys/time.h>
  39 #include <sys/sysconfig.h>
  40 #include <sys/resource.h>
  41 #include <sys/ulimit.h>
  42 #include <sys/unistd.h>
  43 #include <sys/debug.h>
  44 #include <sys/cpuvar.h>
 
 
 153                         mutex_exit(&curproc->p_lock);
 154                         return ((uint_t)sigqsz_max);
 155                 }
 156 
 157         case _CONFIG_SIGRT_MIN:
 158                 return (_SIGRTMIN);
 159 
 160         case _CONFIG_SIGRT_MAX:
 161                 return (_SIGRTMAX);
 162 
 163         case _CONFIG_TIMER_MAX:
 164                 return (timer_max);
 165 
 166         case _CONFIG_PHYS_PAGES:
 167                 /*
 168                  * If the non-global zone has a phys. memory cap, use that.
 169                  * We always report the system-wide value for the global zone,
 170                  * even though rcapd can be used on the global zone too.
 171                  */
 172                 if (!INGLOBALZONE(curproc) &&
 173                     curproc->p_zone->zone_phys_mcap != 0)
 174                         return (MIN(btop(curproc->p_zone->zone_phys_mcap),
 175                             physinstalled));
 176 
 177                 return (physinstalled);
 178 
 179         case _CONFIG_AVPHYS_PAGES:
 180                 /*
 181                  * If the non-global zone has a phys. memory cap, use
 182                  * the phys. memory cap - zone's current rss.  We always
 183                  * report the system-wide value for the global zone, even
 184                  * though rcapd can be used on the global zone too.
 185                  */
 186                 if (!INGLOBALZONE(curproc) &&
 187                     curproc->p_zone->zone_phys_mcap != 0) {
 188                         pgcnt_t cap, rss, free;
 189                         vmusage_t in_use;
 190                         size_t cnt = 1;
 191 
 192                         cap = btop(curproc->p_zone->zone_phys_mcap);
 193                         if (cap > physinstalled)
 194                                 return (freemem);
 195 
 196                         if (vm_getusage(VMUSAGE_ZONE, 1, &in_use, &cnt,
 197                             FKIOCTL) != 0)
 198                                 in_use.vmu_rss_all = 0;
 199                         rss = btop(in_use.vmu_rss_all);
 200                         /*
 201                          * Because rcapd implements a soft cap, it is possible
 202                          * for rss to be temporarily over the cap.
 203                          */
 204                         if (cap > rss)
 205                                 free = cap - rss;
 206                         else
 207                                 free = 0;
 208                         return (MIN(free, freemem));
 209                 }
 210 
 211                 return (freemem);
 212 
 | 
 
 
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2011 Joyent, Inc.  All rights reserved.
  26  */
  27 
  28 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  29 /*        All Rights Reserved   */
  30 
  31 #include <sys/param.h>
  32 #include <sys/types.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/systm.h>
  35 #include <sys/tuneable.h>
  36 #include <sys/errno.h>
  37 #include <sys/var.h>
  38 #include <sys/signal.h>
  39 #include <sys/time.h>
  40 #include <sys/sysconfig.h>
  41 #include <sys/resource.h>
  42 #include <sys/ulimit.h>
  43 #include <sys/unistd.h>
  44 #include <sys/debug.h>
  45 #include <sys/cpuvar.h>
 
 
 154                         mutex_exit(&curproc->p_lock);
 155                         return ((uint_t)sigqsz_max);
 156                 }
 157 
 158         case _CONFIG_SIGRT_MIN:
 159                 return (_SIGRTMIN);
 160 
 161         case _CONFIG_SIGRT_MAX:
 162                 return (_SIGRTMAX);
 163 
 164         case _CONFIG_TIMER_MAX:
 165                 return (timer_max);
 166 
 167         case _CONFIG_PHYS_PAGES:
 168                 /*
 169                  * If the non-global zone has a phys. memory cap, use that.
 170                  * We always report the system-wide value for the global zone,
 171                  * even though rcapd can be used on the global zone too.
 172                  */
 173                 if (!INGLOBALZONE(curproc) &&
 174                     curproc->p_zone->zone_phys_mem_ctl != UINT64_MAX)
 175                         return (MIN(btop(curproc->p_zone->zone_phys_mem_ctl),
 176                             physinstalled));
 177 
 178                 return (physinstalled);
 179 
 180         case _CONFIG_AVPHYS_PAGES:
 181                 /*
 182                  * If the non-global zone has a phys. memory cap, use
 183                  * the phys. memory cap - zone's current rss.  We always
 184                  * report the system-wide value for the global zone, even
 185                  * though rcapd can be used on the global zone too.
 186                  */
 187                 if (!INGLOBALZONE(curproc) &&
 188                     curproc->p_zone->zone_phys_mem_ctl != UINT64_MAX) {
 189                         pgcnt_t cap, rss, free;
 190                         vmusage_t in_use;
 191                         size_t cnt = 1;
 192 
 193                         cap = btop(curproc->p_zone->zone_phys_mem_ctl);
 194                         if (cap > physinstalled)
 195                                 return (freemem);
 196 
 197                         if (vm_getusage(VMUSAGE_ZONE, 1, &in_use, &cnt,
 198                             FKIOCTL) != 0)
 199                                 in_use.vmu_rss_all = 0;
 200                         rss = btop(in_use.vmu_rss_all);
 201                         /*
 202                          * Because rcapd implements a soft cap, it is possible
 203                          * for rss to be temporarily over the cap.
 204                          */
 205                         if (cap > rss)
 206                                 free = cap - rss;
 207                         else
 208                                 free = 0;
 209                         return (MIN(free, freemem));
 210                 }
 211 
 212                 return (freemem);
 213 
 |