Lines Matching refs:zone
72 #include <sys/zone.h>
77 #include <zone.h>
95 * new zone is booted. This is used to fattach the zsd_server door
96 * into the new zone.
103 * If the client is in a non-global zone, the utilization data will
104 * be filtered to only show the given zone. The usage by all other zones
109 * current utilization data for each running zone. This includes
111 * of each zone, such as their configured limits, and which processor
156 /* Used to store a zone's usage of a pset */
164 boolean_t zsu_found; /* zone bound at end of interval */
165 boolean_t zsu_active; /* zone was bound during interval */
166 boolean_t zsu_new; /* zone newly bound in this interval */
167 boolean_t zsu_deleted; /* zone was unbound in this interval */
169 time_t zsu_start; /* time when zone was found in pset */
170 hrtime_t zsu_hrstart; /* time when zone was found in pset */
204 /* Individual zone usages of pset */
250 /* Used to describe an individual zone and its utilization */
267 boolean_t zsz_new; /* zone booted during this interval */
284 timestruc_t zsz_pset_time; /* time of all psets zone is bound to */
312 * to their zone. As processes exit, their extended accounting records are
314 * zone.
317 * accounting record will be charged to its zone.
739 * Attach the zsd_server to a zone. Called for each zone when zonestatd
740 * starts, and for each newly booted zone when zoneadmd contacts the zsd_server
742 * Zone_enter is used to avoid reaching into zone to fattach door.
797 zsd_warn(gettext("Cannot entering zone"));
803 zsd_warn(gettext("Internal error entering zone: %d"), zid);
813 zsd_zone_t *zone;
815 for (zone = list_head(&ctl->zsctl_zones); zone != NULL;
816 zone = list_next(&ctl->zsctl_zones, zone)) {
817 if (strcmp(zone->zsz_name, zonename) == 0) {
819 zone->zsz_id = zoneid;
820 return (zone);
829 zsd_zone_t *zone;
831 for (zone = list_head(&ctl->zsctl_zones); zone != NULL;
832 zone = list_next(&ctl->zsctl_zones, zone)) {
833 if (zone->zsz_id == zoneid)
834 return (zone);
842 zsd_zone_t *zone;
844 if ((zone = (zsd_zone_t *)calloc(1, sizeof (zsd_zone_t))) == NULL)
847 (void) strlcpy(zone->zsz_name, zonename, sizeof (zone->zsz_name));
848 zone->zsz_id = zoneid;
849 zone->zsz_found = B_FALSE;
852 * Allocate as deleted so if not found in first pass, zone is deleted
853 * from list. This can happen if zone is returned by zone_list, but
854 * exits before first attempt to fetch zone details.
856 zone->zsz_start = g_now;
857 zone->zsz_hrstart = g_hrnow;
858 zone->zsz_deleted = B_TRUE;
860 zone->zsz_cpu_shares = ZS_LIMIT_NONE;
861 zone->zsz_cpu_cap = ZS_LIMIT_NONE;
862 zone->zsz_ram_cap = ZS_LIMIT_NONE;
863 zone->zsz_locked_cap = ZS_LIMIT_NONE;
864 zone->zsz_vm_cap = ZS_LIMIT_NONE;
866 zone->zsz_processes_cap = ZS_LIMIT_NONE;
867 zone->zsz_lwps_cap = ZS_LIMIT_NONE;
868 zone->zsz_shm_cap = ZS_LIMIT_NONE;
869 zone->zsz_shmids_cap = ZS_LIMIT_NONE;
870 zone->zsz_semids_cap = ZS_LIMIT_NONE;
871 zone->zsz_msgids_cap = ZS_LIMIT_NONE;
872 zone->zsz_lofi_cap = ZS_LIMIT_NONE;
876 return (zone);
882 zsd_zone_t *zone, *tmp;
884 if ((zone = zsd_lookup_zone(ctl, zonename, zoneid)) != NULL)
885 return (zone);
887 if ((zone = zsd_allocate_zone(ctl, zonename, zoneid)) == NULL)
895 list_insert_before(&ctl->zsctl_zones, tmp, zone);
896 return (zone);
901 * be marked as existing. If a zone is not found, then it must have
908 zsd_zone_t *zone;
910 for (zone = list_head(&ctl->zsctl_zones); zone != NULL;
911 zone = list_next(&ctl->zsctl_zones, zone)) {
912 zone->zsz_found = B_FALSE;
917 * Mark each zone as not using pset. If processes are found using the
918 * pset, the zone will remain bound to the pset. If none of a zones
919 * processes are bound to the pset, the zone's usage of the pset will
984 * A zone's process was found using a pset. Charge the process to the pset and
985 * the per-zone data for the pset.
990 zsd_zone_t *zone = usage->zsu_zone;
1011 zone->zsz_empty = B_FALSE;
1014 /* Detect zone's pset id, and if it is bound to multiple psets */
1015 if (zone->zsz_psetid == ZS_PSET_ERROR)
1016 zone->zsz_psetid = pset->zsp_id;
1017 else if (zone->zsz_psetid != pset->zsp_id)
1018 zone->zsz_psetid = ZS_PSET_MULTI;
1022 zone->zsz_scheds |= sched;
1035 /* Add cpu time for a process to a pset, zone, and system totals */
1040 zsd_zone_t *zone = usage->zsu_zone;
1045 TIMESTRUC_ADD_TIMESTRUC(zone->zsz_cpu_usage, *delta);
1086 zsd_zone_t *zone;
1118 zone = usage->zsu_zone;
1120 zone->zsz_cpu_shares != ZS_SHARES_UNLIMITED &&
1121 zone->zsz_cpu_shares != 0) {
1122 zone = usage->zsu_zone;
1123 usage->zsu_cpu_shares = zone->zsz_cpu_shares;
1124 pset->zsp_cpu_shares += zone->zsz_cpu_shares;
1132 /* A zone has been found. Update its information */
1134 zsd_mark_zone_found(zsd_ctl_t *ctl, zsd_zone_t *zone, uint64_t cpu_shares,
1145 assert(zone->zsz_found == B_FALSE);
1148 * Mark zone as exists, and new if it did not exist in previous
1151 zone->zsz_found = B_TRUE;
1152 zone->zsz_empty = B_TRUE;
1153 zone->zsz_deleted = B_FALSE;
1156 * Zone is new. Assume zone's properties are the same over entire
1159 if (zone->zsz_active == B_FALSE)
1160 zone->zsz_new = B_TRUE;
1162 zone->zsz_new = B_FALSE;
1164 (void) strlcpy(zone->zsz_pool, poolname, sizeof (zone->zsz_pool));
1165 (void) strlcpy(zone->zsz_pset, psetname, sizeof (zone->zsz_pset));
1166 zone->zsz_default_sched = sched;
1169 zone->zsz_scheds = 0;
1172 zone->zsz_cpus_online = 0;
1174 zone->zsz_cputype = cputype;
1175 zone->zsz_iptype = iptype;
1176 zone->zsz_psetid = ZS_PSET_ERROR;
1177 zone->zsz_cpu_cap = cpu_cap;
1178 zone->zsz_cpu_shares = cpu_shares;
1179 zone->zsz_ram_cap = ram_cap;
1180 zone->zsz_locked_cap = locked_cap;
1181 zone->zsz_vm_cap = vm_cap;
1182 zone->zsz_processes_cap = processes_cap;
1183 zone->zsz_processes = processes;
1184 zone->zsz_lwps_cap = lwps_cap;
1185 zone->zsz_lwps = lwps;
1186 zone->zsz_shm_cap = shm_cap;
1187 zone->zsz_shm = shm;
1188 zone->zsz_shmids_cap = shmids_cap;
1189 zone->zsz_shmids = shmids;
1190 zone->zsz_semids_cap = semids_cap;
1191 zone->zsz_semids = semids;
1192 zone->zsz_msgids_cap = msgids_cap;
1193 zone->zsz_msgids = msgids;
1194 zone->zsz_lofi_cap = lofi_cap;
1195 zone->zsz_lofi = lofi;
1204 zone->zsz_active = B_TRUE;
1212 zsd_zone_t *zone, *tmp;
1215 * Mark zone as not existing, or delete if it did not exist in
1218 zone = list_head(&ctl->zsctl_zones);
1219 while (zone != NULL) {
1220 if (zone->zsz_found == B_FALSE) {
1221 zone->zsz_empty = B_TRUE;
1222 if (zone->zsz_deleted == B_TRUE) {
1227 tmp = zone;
1228 zone = list_next(&ctl->zsctl_zones, zone);
1234 zone->zsz_new = B_FALSE;
1235 zone->zsz_deleted = B_TRUE;
1236 zone->zsz_active = B_TRUE;
1239 zone = list_next(&ctl->zsctl_zones, zone);
1453 zsd_lookup_usage(zsd_pset_t *pset, zsd_zone_t *zone)
1459 if (usage->zsu_zone == zone)
1466 zsd_allocate_pset_usage(zsd_ctl_t *ctl, zsd_pset_t *pset, zsd_zone_t *zone)
1475 usage->zsu_zone = zone;
1476 usage->zsu_zoneid = zone->zsz_id;
1483 * a zone, the usage will not be deleted until at least the next
1500 zsd_lookup_insert_usage(zsd_ctl_t *ctl, zsd_pset_t *pset, zsd_zone_t *zone)
1504 if ((usage = zsd_lookup_usage(pset, zone))
1508 if ((usage = zsd_allocate_pset_usage(ctl, pset, zone)) == NULL)
1512 while (tmp != NULL && strcmp(zone->zsz_name, tmp->zsu_zone->zsz_name)
2037 * Fetch the current pool and pset name for the given zone.
2040 zsd_get_zone_pool_pset(zsd_ctl_t *ctl, zsd_zone_t *zone,
2056 ret = zone_getattr(zone->zsz_id, ZONE_ATTR_POOLID,
2196 * Fetch the limit information for a zone. This uses zone_enter() as the
2197 * getrctl(2) system call only returns rctl information for the zone of
2201 zsd_get_zone_caps(zsd_ctl_t *ctl, zsd_zone_t *zone, uint64_t *cpu_shares,
2240 /* Get the ram cap first since it is a zone attr */
2241 ret = zone_getattr(zone->zsz_id, ZONE_ATTR_PHYS_MCAP,
2246 /* Get the zone's default scheduling class */
2247 ret = zone_getattr(zone->zsz_id, ZONE_ATTR_SCHED_CLASS,
2254 /* rctl caps must be fetched from within the zone */
2275 if (zone->zsz_id != getzoneid()) {
2276 if (zone_enter(zone->zsz_id) < 0) {
2282 /* Get caps for zone, and write them to zonestatd parent. */
2283 vals[i++] = zsd_get_zone_rctl_limit("zone.cpu-shares");
2284 vals[i++] = zsd_get_zone_rctl_limit("zone.cpu-cap");
2285 vals[i++] = zsd_get_zone_rctl_limit("zone.max-locked-memory");
2286 vals[i++] = zsd_get_zone_rctl_limit("zone.max-swap");
2287 vals[i++] = zsd_get_zone_rctl_limit("zone.max-processes");
2288 vals[i++] = zsd_get_zone_rctl_usage("zone.max-processes");
2289 vals[i++] = zsd_get_zone_rctl_limit("zone.max-lwps");
2290 vals[i++] = zsd_get_zone_rctl_usage("zone.max-lwps");
2291 vals[i++] = zsd_get_zone_rctl_limit("zone.max-shm-memory");
2292 vals[i++] = zsd_get_zone_rctl_usage("zone.max-shm-memory");
2293 vals[i++] = zsd_get_zone_rctl_limit("zone.max-shm-ids");
2294 vals[i++] = zsd_get_zone_rctl_usage("zone.max-shm-ids");
2295 vals[i++] = zsd_get_zone_rctl_limit("zone.max-sem-ids");
2296 vals[i++] = zsd_get_zone_rctl_usage("zone.max-sem-ids");
2297 vals[i++] = zsd_get_zone_rctl_limit("zone.max-msg-ids");
2298 vals[i++] = zsd_get_zone_rctl_usage("zone.max-msg-ids");
2299 vals[i++] = zsd_get_zone_rctl_limit("zone.max-lofi");
2300 vals[i++] = zsd_get_zone_rctl_usage("zone.max-lofi");
2320 /* Read cap from child in zone */
2378 zsd_zone_t *zone;
2421 /* Could not allocate to get new zone list. Give up */
2435 zone = zsd_lookup_insert_zone(ctl, zonename,
2448 zsd_get_zone_pool_pset(ctl, zone, poolname, sizeof (poolname),
2451 if (zsd_get_zone_caps(ctl, zone, &cpu_shares, &cpu_cap,
2458 zsd_mark_zone_found(ctl, zone, cpu_shares, cpu_cap, ram_cap,
2614 * Walk /proc and charge each process to its zone and processor set.
2626 zsd_zone_t *zone, *prev_zone;
2668 /* Walk all processes and compute each zone's usage on each pset. */
2696 /* Get the zone and pset this process is running in */
2697 zone = zsd_lookup_zone_byid(ctl, zoneid);
2698 if (zone == NULL)
2703 usage = zsd_lookup_insert_usage(ctl, pset, zone);
2708 * Get the usage of the previous zone and pset if they were
2724 prev_zone = zone;
2782 zone = NULL;
2877 zone = zsd_lookup_zone(ctl,
2927 * Try to identify the zone and pset to which this
2930 if (zone == NULL)
2935 proc->zspr_zoneid = zone->zsz_id;
2948 * zone before using most recent known value.
2954 * If no parent in the zone is found, use the zone's default
2961 } else if (pproc->zspr_zoneid == zone->zsz_id &&
2982 /* Add the zone's usage to the pset */
2983 usage = zsd_lookup_insert_usage(ctl, pset, zone);
3030 * Parent in different zone. Save process and
3031 * use zone's default pset and sched below
3049 zone = zsd_lookup_zone_byid(ctl,
3051 if (zone == NULL) {
3067 /* Add the zone's usage to the pset */
3068 usage = zsd_lookup_insert_usage(ctl, pset, zone);
3087 * Process has never been seen. Using zone info to
3093 zone = zsd_lookup_zone_byid(ctl, proc->zspr_zoneid);
3094 if (zone == NULL)
3096 if (zone->zsz_psetid != ZS_PSET_ERROR &&
3097 zone->zsz_psetid != ZS_PSET_MULTI) {
3098 prev_psetid = zone->zsz_psetid;
3101 pset = zsd_lookup_pset(ctl, zone->zsz_pset, -1);
3108 sched = zone->zsz_scheds;
3111 * only scheduling class in the zone.
3117 * in the zone, use zone's default scheduling class for
3121 sched = zone->zsz_default_sched;
3123 /* Add the zone's usage to the pset */
3124 usage = zsd_lookup_insert_usage(ctl, pset, zone);
3244 zsd_zone_t *zone;
3434 zone = zsd_lookup_zone_byid(ctl, vmusage[i].vmu_id);
3435 if (zone != NULL)
3436 zone->zsz_usage_ram = vmusage[i].vmu_rss_all;
3445 * equals the total zone ram usage;
3455 for (zone = list_head(&ctl->zsctl_zones); zone != NULL;
3456 zone = list_next(&ctl->zsctl_zones, zone)) {
3458 /* If zone halted during interval, show memory usage as none */
3459 if (zone->zsz_active == B_FALSE ||
3460 zone->zsz_deleted == B_TRUE) {
3461 zone->zsz_usage_ram = 0;
3462 zone->zsz_usage_vm = 0;
3463 zone->zsz_usage_locked = 0;
3468 if (zone->zsz_usage_ram > phys_zones_credit) {
3469 zone->zsz_usage_ram -= phys_zones_credit;
3473 * Get zone's swap usage. Since zone could have halted,
3476 zone->zsz_usage_vm = 0;
3478 "swapresv_zone_%d", zone->zsz_id);
3481 zone->zsz_id, kstat_name);
3488 zone->zsz_usage_vm = knp->value.ui64;
3493 * Get zone's locked usage. Since zone could have halted,
3496 zone->zsz_usage_locked = 0;
3498 "lockedmem_zone_%d", zone->zsz_id);
3501 zone->zsz_id, kstat_name);
3508 zone->zsz_usage_locked = knp->value.ui64;
3512 * zone's locked usage at its ram usage.
3514 if (zone->zsz_usage_locked >
3515 zone->zsz_usage_ram)
3516 zone->zsz_usage_locked =
3517 zone->zsz_usage_ram;
3519 zone->zsz_usage_locked;
3557 * time to each zone using the processor set. This tracks the maximum
3558 * amount of cpu time that a zone could have used.
3564 zsd_zone_t *zone;
3613 /* kernel time in pset is total time minus zone time */
3629 zone = usage->zsu_zone;
3635 * to give to the zone
3642 TIMESTRUC_ADD_NANOSEC(zone->zsz_share_time,
3645 /* Add pset time to each zone using pset */
3646 TIMESTRUC_ADD_TIMESTRUC(zone->zsz_pset_time, delta);
3648 zone->zsz_cpus_online += pset->zsp_online;
3653 for (zone = list_head(&ctl->zsctl_zones); zone != NULL;
3654 zone = list_next(&ctl->zsctl_zones, zone)) {
3656 /* update cpu cap tracking if the zone has a cpu cap */
3657 if (zone->zsz_cpu_cap != ZS_LIMIT_NONE) {
3661 elapsed *= zone->zsz_cpu_cap;
3663 TIMESTRUC_ADD_NANOSEC(zone->zsz_cap_time, elapsed);
3673 /* kernel time in pset is total time minus zone time */
3703 zs_zone_t *zone = NULL;
3783 zone = (zs_zone_t *)next;
3785 list_link_init(&zone->zsz_next);
3786 zone->zsz_system = NULL;
3788 (void) strlcpy(zone->zsz_name, dzone->zsz_name,
3789 sizeof (zone->zsz_name));
3790 (void) strlcpy(zone->zsz_pool, dzone->zsz_pool,
3791 sizeof (zone->zsz_pool));
3792 (void) strlcpy(zone->zsz_pset, dzone->zsz_pset,
3793 sizeof (zone->zsz_pset));
3794 zone->zsz_id = dzone->zsz_id;
3795 zone->zsz_cputype = dzone->zsz_cputype;
3796 zone->zsz_iptype = dzone->zsz_iptype;
3797 zone->zsz_start = dzone->zsz_start;
3798 zone->zsz_hrstart = dzone->zsz_hrstart;
3799 zone->zsz_scheds = dzone->zsz_scheds;
3800 zone->zsz_cpu_shares = dzone->zsz_cpu_shares;
3801 zone->zsz_cpu_cap = dzone->zsz_cpu_cap;
3802 zone->zsz_ram_cap = dzone->zsz_ram_cap;
3803 zone->zsz_vm_cap = dzone->zsz_vm_cap;
3804 zone->zsz_locked_cap = dzone->zsz_locked_cap;
3805 zone->zsz_cpu_usage = dzone->zsz_cpu_usage;
3806 zone->zsz_cpus_online = dzone->zsz_cpus_online;
3807 zone->zsz_pset_time = dzone->zsz_pset_time;
3808 zone->zsz_cap_time = dzone->zsz_cap_time;
3809 zone->zsz_share_time = dzone->zsz_share_time;
3810 zone->zsz_usage_ram = dzone->zsz_usage_ram;
3811 zone->zsz_usage_locked = dzone->zsz_usage_locked;
3812 zone->zsz_usage_vm = dzone->zsz_usage_vm;
3814 zone->zsz_processes_cap = dzone->zsz_processes_cap;
3815 zone->zsz_lwps_cap = dzone->zsz_lwps_cap;
3816 zone->zsz_shm_cap = dzone->zsz_shm_cap;
3817 zone->zsz_shmids_cap = dzone->zsz_shmids_cap;
3818 zone->zsz_semids_cap = dzone->zsz_semids_cap;
3819 zone->zsz_msgids_cap = dzone->zsz_msgids_cap;
3820 zone->zsz_lofi_cap = dzone->zsz_lofi_cap;
3822 zone->zsz_processes = dzone->zsz_processes;
3823 zone->zsz_lwps = dzone->zsz_lwps;
3824 zone->zsz_shm = dzone->zsz_shm;
3825 zone->zsz_shmids = dzone->zsz_shmids;
3826 zone->zsz_semids = dzone->zsz_semids;
3827 zone->zsz_msgids = dzone->zsz_msgids;
3828 zone->zsz_lofi = dzone->zsz_lofi;
3921 zsd_zone_t *zone;
3942 while ((zone = list_head(&ctl->zsctl_zones)) != NULL) {
3943 list_remove(&ctl->zsctl_zones, zone);
3944 free(zone);
4002 * Pset usages must be deleted first as they point to zone and
4203 system->zss_processes_max = zsd_get_system_rctl("zone.max-processes");
4204 system->zss_lwps_max = zsd_get_system_rctl("zone.max-lwps");
4205 system->zss_shm_max = zsd_get_system_rctl("zone.max-shm-memory");
4206 system->zss_shmids_max = zsd_get_system_rctl("zone.max-shm-ids");
4207 system->zss_semids_max = zsd_get_system_rctl("zone.max-sem-ids");
4208 system->zss_msgids_max = zsd_get_system_rctl("zone.max-msg-ids");
4209 system->zss_lofi_max = zsd_get_system_rctl("zone.max-lofi");
4214 zsd_warn(gettext("Reading zone statistics failed"));
4224 /* Copy utilization data to buffer, filtering data if non-global zone. */
4231 zs_zone_t *zone, *czone;
4239 /* Privileged users in the global zone get everything */
4275 zone = (zs_zone_t *)(start + size);
4278 /* Find the matching zone */
4281 *zone = *czone;
4288 sys->zss_ram_kern += (sys->zss_ram_zones - zone->zsz_usage_ram);
4289 sys->zss_ram_zones = zone->zsz_usage_ram;
4291 sys->zss_vm_kern += (sys->zss_vm_zones - zone->zsz_usage_vm);
4292 sys->zss_vm_zones = zone->zsz_usage_vm;
4295 zone->zsz_usage_locked);
4296 sys->zss_locked_zones = zone->zsz_usage_locked;
4298 TIMESTRUC_DELTA(delta, sys->zss_cpu_usage_zones, zone->zsz_cpu_usage);
4300 sys->zss_cpu_usage_zones = zone->zsz_cpu_usage;
4408 /* Respond to zoneadmd informing zonestatd of a new zone */
4508 /* Filter out results if caller is non-global zone */
4621 "Unable to open zone statistics"));
4628 "Unable to read zone statistics"));
4791 zsd_error(gettext("Must be run from global zone only"));