4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
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>
37 #include <sys/signal.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>
46 #include <sys/timer.h>
48 #include <sys/vm_usage.h>
50 extern rctl_hndl_t rc_process_sigqueue
;
58 * if it is not handled in mach_sysconfig either
62 return (mach_sysconfig(which
)); /* `uname -i`/os */
65 return ((long)hz
); /* clock frequency per second */
67 case _CONFIG_PROF_TCK
:
68 return ((long)hz
); /* profiling clock freq per sec */
72 * Maximum number of supplementary groups.
76 case _CONFIG_OPEN_FILES
:
78 * Maximum number of open files (soft limit).
82 mutex_enter(&curproc
->p_lock
);
83 fd_ctl
= rctl_enforced_value(
84 rctlproc_legacy
[RLIMIT_NOFILE
], curproc
->p_rctls
,
86 mutex_exit(&curproc
->p_lock
);
87 return ((ulong_t
)fd_ctl
);
90 case _CONFIG_CHILD_MAX
:
92 * Maximum number of processes.
96 case _CONFIG_POSIX_VER
:
97 return (_POSIX_VERSION
); /* current POSIX version */
99 case _CONFIG_PAGESIZE
:
102 case _CONFIG_XOPEN_VER
:
103 return (_XOPEN_VERSION
); /* current XOPEN version */
105 case _CONFIG_NPROC_CONF
:
106 return (zone_ncpus_get(curproc
->p_zone
));
108 case _CONFIG_NPROC_ONLN
:
109 return (zone_ncpus_online_get(curproc
->p_zone
));
111 case _CONFIG_NPROC_MAX
:
114 case _CONFIG_STACK_PROT
:
115 return (curproc
->p_stkprot
& ~PROT_USER
);
117 case _CONFIG_AIO_LISTIO_MAX
:
118 return (_AIO_LISTIO_MAX
);
120 case _CONFIG_AIO_MAX
:
123 case _CONFIG_AIO_PRIO_DELTA_MAX
:
126 case _CONFIG_DELAYTIMER_MAX
:
129 case _CONFIG_MQ_OPEN_MAX
:
130 return (_MQ_OPEN_MAX
);
132 case _CONFIG_MQ_PRIO_MAX
:
133 return (_MQ_PRIO_MAX
);
135 case _CONFIG_RTSIG_MAX
:
136 return (_SIGRTMAX
- _SIGRTMIN
+ 1);
138 case _CONFIG_SEM_NSEMS_MAX
:
139 return (_SEM_NSEMS_MAX
);
141 case _CONFIG_SEM_VALUE_MAX
:
142 return (_SEM_VALUE_MAX
);
144 case _CONFIG_SIGQUEUE_MAX
:
146 * Maximum number of outstanding queued signals.
150 mutex_enter(&curproc
->p_lock
);
151 sigqsz_max
= rctl_enforced_value(rc_process_sigqueue
,
152 curproc
->p_rctls
, curproc
);
153 mutex_exit(&curproc
->p_lock
);
154 return ((uint_t
)sigqsz_max
);
157 case _CONFIG_SIGRT_MIN
:
160 case _CONFIG_SIGRT_MAX
:
163 case _CONFIG_TIMER_MAX
:
166 case _CONFIG_PHYS_PAGES
:
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.
172 if (!INGLOBALZONE(curproc
) &&
173 curproc
->p_zone
->zone_phys_mcap
!= 0)
174 return (MIN(btop(curproc
->p_zone
->zone_phys_mcap
),
177 return (physinstalled
);
179 case _CONFIG_AVPHYS_PAGES
:
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.
186 if (!INGLOBALZONE(curproc
) &&
187 curproc
->p_zone
->zone_phys_mcap
!= 0) {
188 pgcnt_t cap
, rss
, free
;
192 cap
= btop(curproc
->p_zone
->zone_phys_mcap
);
193 if (cap
> physinstalled
)
196 if (vm_getusage(VMUSAGE_ZONE
, 1, &in_use
, &cnt
,
198 in_use
.vmu_rss_all
= 0;
199 rss
= btop(in_use
.vmu_rss_all
);
201 * Because rcapd implements a soft cap, it is possible
202 * for rss to be temporarily over the cap.
208 return (MIN(free
, freemem
));
216 case _CONFIG_CPUID_MAX
:
219 case _CONFIG_EPHID_MAX
:
222 case _CONFIG_SYMLOOP_MAX
:
223 return (MAXSYMLINKS
);