3 *
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.
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 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2015 Joyent, Inc. All rights reserved.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
26 */
27
28 #ifndef _SYS_ZONE_H
29 #define _SYS_ZONE_H
30
31 #include <sys/types.h>
32 #include <sys/mutex.h>
33 #include <sys/param.h>
34 #include <sys/rctl.h>
35 #include <sys/ipc_rctl.h>
36 #include <sys/pset.h>
37 #include <sys/tsol/label.h>
38 #include <sys/cred.h>
39 #include <sys/netstack.h>
40 #include <sys/uadmin.h>
41 #include <sys/ksynch.h>
42 #include <sys/socket_impl.h>
43 #include <sys/secflags.h>
44 #include <netinet/in.h>
45
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49
50 /*
51 * NOTE
52 *
53 * The contents of this file are private to the implementation of
54 * Solaris and are subject to change at any time without notice.
55 * Applications and drivers using these interfaces may fail to
56 * run on future releases.
57 */
58
59 /* Available both in kernel and for user space */
60
61 /* zone id restrictions and special ids */
62 #define MAX_ZONEID 9999
63 #define MIN_USERZONEID 1 /* lowest user-creatable zone ID */
64 #define MIN_ZONEID 0 /* minimum zone ID on system */
313
314 typedef struct zone_net_data {
315 int zn_type;
316 int zn_len;
317 datalink_id_t zn_linkid;
318 uint8_t zn_val[1];
319 } zone_net_data_t;
320
321
322 #ifdef _KERNEL
323
324 /*
325 * We need to protect the definition of 'list_t' from userland applications and
326 * libraries which may be defining ther own versions.
327 */
328 #include <sys/list.h>
329 #include <sys/loadavg.h>
330
331 #define GLOBAL_ZONEUNIQID 0 /* uniqid of the global zone */
332
333 struct pool;
334 struct brand;
335
336 /*
337 * Each of these constants identifies a kernel subsystem that acquires and
338 * releases zone references. Each subsystem that invokes
339 * zone_hold_ref() and zone_rele_ref() should specify the
340 * zone_ref_subsys_t constant associated with the subsystem. Tracked holds
341 * help users and developers quickly identify subsystems that stall zone
342 * shutdowns indefinitely.
343 *
344 * NOTE: You must modify zone_ref_subsys_names in usr/src/uts/common/os/zone.c
345 * when you modify this enumeration.
346 */
347 typedef enum zone_ref_subsys {
348 ZONE_REF_NFS, /* NFS */
349 ZONE_REF_NFSV4, /* NFSv4 */
350 ZONE_REF_SMBFS, /* SMBFS */
351 ZONE_REF_MNTFS, /* MNTFS */
352 ZONE_REF_LOFI, /* LOFI devices */
567
568 char *zone_fs_allowed;
569 rctl_qty_t zone_nprocs; /* number of processes in the zone */
570 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
571 /* zone_rctls->rcs_lock */
572 kstat_t *zone_nprocs_kstat;
573
574 kmutex_t zone_mcap_lock; /* protects mcap statistics */
575 kstat_t *zone_mcap_ksp;
576 zone_mcap_kstat_t *zone_mcap_stats;
577 uint64_t zone_pgpgin; /* pages paged in */
578 uint64_t zone_anonpgin; /* anon pages paged in */
579 uint64_t zone_execpgin; /* exec pages paged in */
580 uint64_t zone_fspgin; /* fs pages paged in */
581 uint64_t zone_anon_alloc_fail; /* cnt of anon alloc fails */
582
583 psecflags_t zone_secflags; /* default zone security-flags */
584
585 /*
586 * Misc. kstats and counters for zone cpu-usage aggregation.
587 * The zone_Xtime values are the sum of the micro-state accounting
588 * values for all threads that are running or have run in the zone.
589 * This is tracked in msacct.c as threads change state.
590 * The zone_stime is the sum of the LMS_SYSTEM times.
591 * The zone_utime is the sum of the LMS_USER times.
592 * The zone_wtime is the sum of the LMS_WAIT_CPU times.
593 * As with per-thread micro-state accounting values, these values are
594 * not scaled to nanosecs. The scaling is done by the
595 * zone_misc_kstat_update function when kstats are requested.
596 */
597 kmutex_t zone_misc_lock; /* protects misc statistics */
598 kstat_t *zone_misc_ksp;
599 zone_misc_kstat_t *zone_misc_stats;
600 uint64_t zone_stime; /* total system time */
601 uint64_t zone_utime; /* total user time */
602 uint64_t zone_wtime; /* total time waiting in runq */
603 /* fork-fail kstat tracking */
604 uint32_t zone_ffcap; /* hit an rctl cap */
605 uint32_t zone_ffnoproc; /* get proc/lwp error */
606 uint32_t zone_ffnomem; /* as_dup/memory error */
607 uint32_t zone_ffmisc; /* misc. other error */
608
609 uint32_t zone_nested_intp; /* nested interp. kstat */
610
611 struct loadavg_s zone_loadavg; /* loadavg for this zone */
612 uint64_t zone_hp_avenrun[3]; /* high-precision avenrun */
613 int zone_avenrun[3]; /* FSCALED avg. run queue len */
614
615 /*
616 * FSS stats updated once per second by fss_decay_usage.
617 */
618 uint32_t zone_fss_gen; /* FSS generation cntr */
619 uint64_t zone_run_ticks; /* tot # of ticks running */
620
621 /*
622 * DTrace-private per-zone state
|
3 *
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.
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 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2018 Joyent, Inc.
24 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
25 * Copyright 2014 Igor Kozhukhov <ikozhukhov@gmail.com>.
26 */
27
28 #ifndef _SYS_ZONE_H
29 #define _SYS_ZONE_H
30
31 #include <sys/types.h>
32 #include <sys/mutex.h>
33 #include <sys/param.h>
34 #include <sys/rctl.h>
35 #include <sys/ipc_rctl.h>
36 #include <sys/pset.h>
37 #include <sys/tsol/label.h>
38 #include <sys/cred.h>
39 #include <sys/netstack.h>
40 #include <sys/uadmin.h>
41 #include <sys/ksynch.h>
42 #include <sys/socket_impl.h>
43 #include <sys/secflags.h>
44 #include <netinet/in.h>
45 #include <sys/cpu_uarray.h>
46
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50
51 /*
52 * NOTE
53 *
54 * The contents of this file are private to the implementation of
55 * Solaris and are subject to change at any time without notice.
56 * Applications and drivers using these interfaces may fail to
57 * run on future releases.
58 */
59
60 /* Available both in kernel and for user space */
61
62 /* zone id restrictions and special ids */
63 #define MAX_ZONEID 9999
64 #define MIN_USERZONEID 1 /* lowest user-creatable zone ID */
65 #define MIN_ZONEID 0 /* minimum zone ID on system */
314
315 typedef struct zone_net_data {
316 int zn_type;
317 int zn_len;
318 datalink_id_t zn_linkid;
319 uint8_t zn_val[1];
320 } zone_net_data_t;
321
322
323 #ifdef _KERNEL
324
325 /*
326 * We need to protect the definition of 'list_t' from userland applications and
327 * libraries which may be defining ther own versions.
328 */
329 #include <sys/list.h>
330 #include <sys/loadavg.h>
331
332 #define GLOBAL_ZONEUNIQID 0 /* uniqid of the global zone */
333
334 /*
335 * Indexes into ->zone_ustate array, summing the micro state of all threads in a
336 * particular zone.
337 */
338 #define ZONE_USTATE_STIME (0)
339 #define ZONE_USTATE_UTIME (1)
340 #define ZONE_USTATE_WTIME (2)
341 #define ZONE_USTATE_MAX (3)
342
343 struct pool;
344 struct brand;
345
346 /*
347 * Each of these constants identifies a kernel subsystem that acquires and
348 * releases zone references. Each subsystem that invokes
349 * zone_hold_ref() and zone_rele_ref() should specify the
350 * zone_ref_subsys_t constant associated with the subsystem. Tracked holds
351 * help users and developers quickly identify subsystems that stall zone
352 * shutdowns indefinitely.
353 *
354 * NOTE: You must modify zone_ref_subsys_names in usr/src/uts/common/os/zone.c
355 * when you modify this enumeration.
356 */
357 typedef enum zone_ref_subsys {
358 ZONE_REF_NFS, /* NFS */
359 ZONE_REF_NFSV4, /* NFSv4 */
360 ZONE_REF_SMBFS, /* SMBFS */
361 ZONE_REF_MNTFS, /* MNTFS */
362 ZONE_REF_LOFI, /* LOFI devices */
577
578 char *zone_fs_allowed;
579 rctl_qty_t zone_nprocs; /* number of processes in the zone */
580 rctl_qty_t zone_nprocs_ctl; /* current limit protected by */
581 /* zone_rctls->rcs_lock */
582 kstat_t *zone_nprocs_kstat;
583
584 kmutex_t zone_mcap_lock; /* protects mcap statistics */
585 kstat_t *zone_mcap_ksp;
586 zone_mcap_kstat_t *zone_mcap_stats;
587 uint64_t zone_pgpgin; /* pages paged in */
588 uint64_t zone_anonpgin; /* anon pages paged in */
589 uint64_t zone_execpgin; /* exec pages paged in */
590 uint64_t zone_fspgin; /* fs pages paged in */
591 uint64_t zone_anon_alloc_fail; /* cnt of anon alloc fails */
592
593 psecflags_t zone_secflags; /* default zone security-flags */
594
595 /*
596 * Misc. kstats and counters for zone cpu-usage aggregation.
597 */
598 kmutex_t zone_misc_lock; /* protects misc statistics */
599 kstat_t *zone_misc_ksp;
600 zone_misc_kstat_t *zone_misc_stats;
601 /* Accumulated microstate for all threads in this zone. */
602 cpu_uarray_t *zone_ustate;
603 /* fork-fail kstat tracking */
604 uint32_t zone_ffcap; /* hit an rctl cap */
605 uint32_t zone_ffnoproc; /* get proc/lwp error */
606 uint32_t zone_ffnomem; /* as_dup/memory error */
607 uint32_t zone_ffmisc; /* misc. other error */
608
609 uint32_t zone_nested_intp; /* nested interp. kstat */
610
611 struct loadavg_s zone_loadavg; /* loadavg for this zone */
612 uint64_t zone_hp_avenrun[3]; /* high-precision avenrun */
613 int zone_avenrun[3]; /* FSCALED avg. run queue len */
614
615 /*
616 * FSS stats updated once per second by fss_decay_usage.
617 */
618 uint32_t zone_fss_gen; /* FSS generation cntr */
619 uint64_t zone_run_ticks; /* tot # of ticks running */
620
621 /*
622 * DTrace-private per-zone state
|