summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/syscall/sysconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/uts/common/syscall/sysconfig.c')
-rw-r--r--usr/src/uts/common/syscall/sysconfig.c51
1 files changed, 20 insertions, 31 deletions
diff --git a/usr/src/uts/common/syscall/sysconfig.c b/usr/src/uts/common/syscall/sysconfig.c
index 03f2fabe13..e09f4e85a2 100644
--- a/usr/src/uts/common/syscall/sysconfig.c
+++ b/usr/src/uts/common/syscall/sysconfig.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2017 Joyent, Inc.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -111,6 +112,9 @@ sysconfig(int which)
case _CONFIG_NPROC_MAX:
return (max_ncpus);
+ case _CONFIG_NPROC_NCPU:
+ return (NCPU); /* Private sysconfig for direct NCPU access */
+
case _CONFIG_STACK_PROT:
return (curproc->p_stkprot & ~PROT_USER);
@@ -167,44 +171,29 @@ sysconfig(int which)
/*
* If the non-global zone has a phys. memory cap, use that.
* We always report the system-wide value for the global zone,
- * even though rcapd can be used on the global zone too.
+ * even though memory capping can be used on the global zone
+ * too.
*/
- if (!INGLOBALZONE(curproc) &&
- curproc->p_zone->zone_phys_mcap != 0)
- return (MIN(btop(curproc->p_zone->zone_phys_mcap),
- physinstalled));
+ if (!INGLOBALZONE(curproc)) {
+ pgcnt_t cap, free;
+
+ zone_get_physmem_data(curzone->zone_id, &cap, &free);
+ return (MIN(cap, physinstalled));
+ }
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 the non-global zone has a phys. memory cap, use its
+ * free value. We always report the system-wide value for the
+ * global zone, even though memory capping can be used on the
+ * global zone too.
*/
- if (!INGLOBALZONE(curproc) &&
- curproc->p_zone->zone_phys_mcap != 0) {
- pgcnt_t cap, rss, free;
- vmusage_t in_use;
- size_t cnt = 1;
-
- cap = btop(curproc->p_zone->zone_phys_mcap);
- 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
- free = 0;
+ if (!INGLOBALZONE(curproc)) {
+ pgcnt_t cap, free;
+
+ zone_get_physmem_data(curzone->zone_id, &cap, &free);
return (MIN(free, freemem));
}