1*efd4c9b6SSteve Lawrence /* 2*efd4c9b6SSteve Lawrence * CDDL HEADER START 3*efd4c9b6SSteve Lawrence * 4*efd4c9b6SSteve Lawrence * The contents of this file are subject to the terms of the 5*efd4c9b6SSteve Lawrence * Common Development and Distribution License (the "License"). 6*efd4c9b6SSteve Lawrence * You may not use this file except in compliance with the License. 7*efd4c9b6SSteve Lawrence * 8*efd4c9b6SSteve Lawrence * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*efd4c9b6SSteve Lawrence * or http://www.opensolaris.org/os/licensing. 10*efd4c9b6SSteve Lawrence * See the License for the specific language governing permissions 11*efd4c9b6SSteve Lawrence * and limitations under the License. 12*efd4c9b6SSteve Lawrence * 13*efd4c9b6SSteve Lawrence * When distributing Covered Code, include this CDDL HEADER in each 14*efd4c9b6SSteve Lawrence * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*efd4c9b6SSteve Lawrence * If applicable, add the following below this CDDL HEADER, with the 16*efd4c9b6SSteve Lawrence * fields enclosed by brackets "[]" replaced with your own identifying 17*efd4c9b6SSteve Lawrence * information: Portions Copyright [yyyy] [name of copyright owner] 18*efd4c9b6SSteve Lawrence * 19*efd4c9b6SSteve Lawrence * CDDL HEADER END 20*efd4c9b6SSteve Lawrence */ 21*efd4c9b6SSteve Lawrence 22*efd4c9b6SSteve Lawrence /* 23*efd4c9b6SSteve Lawrence * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24*efd4c9b6SSteve Lawrence */ 25*efd4c9b6SSteve Lawrence 26*efd4c9b6SSteve Lawrence #ifndef _ZONESTAT_IMPL_H 27*efd4c9b6SSteve Lawrence #define _ZONESTAT_IMPL_H 28*efd4c9b6SSteve Lawrence 29*efd4c9b6SSteve Lawrence #include <zonestat.h> 30*efd4c9b6SSteve Lawrence #include <sys/list.h> 31*efd4c9b6SSteve Lawrence #include <sys/priv_const.h> 32*efd4c9b6SSteve Lawrence 33*efd4c9b6SSteve Lawrence #ifdef __cplusplus 34*efd4c9b6SSteve Lawrence extern "C" { 35*efd4c9b6SSteve Lawrence 36*efd4c9b6SSteve Lawrence #endif 37*efd4c9b6SSteve Lawrence 38*efd4c9b6SSteve Lawrence #define ZS_VERSION 1 39*efd4c9b6SSteve Lawrence 40*efd4c9b6SSteve Lawrence #define ZS_PSET_DEFAULT PS_NONE 41*efd4c9b6SSteve Lawrence #define ZS_PSET_MULTI PS_MYID 42*efd4c9b6SSteve Lawrence #define ZS_PSET_ERROR PS_QUERY 43*efd4c9b6SSteve Lawrence 44*efd4c9b6SSteve Lawrence #define ZS_DOOR_PATH "/etc/svc/volatile/zonestat_door" 45*efd4c9b6SSteve Lawrence 46*efd4c9b6SSteve Lawrence #define ZSD_CMD_READ 1 47*efd4c9b6SSteve Lawrence #define ZSD_CMD_CONNECT 2 48*efd4c9b6SSteve Lawrence #define ZSD_CMD_NEW_ZONE 3 49*efd4c9b6SSteve Lawrence 50*efd4c9b6SSteve Lawrence /* The following read commands are unimplemented */ 51*efd4c9b6SSteve Lawrence #define ZSD_CMD_READ_TIME 3 52*efd4c9b6SSteve Lawrence #define ZSD_CMD_READ_SET 4 53*efd4c9b6SSteve Lawrence #define ZSD_CMD_READ_SET_TIME 5 54*efd4c9b6SSteve Lawrence 55*efd4c9b6SSteve Lawrence #define ZSD_STATUS_OK 0 56*efd4c9b6SSteve Lawrence #define ZSD_STATUS_VERSION_MISMATCH 1 57*efd4c9b6SSteve Lawrence #define ZSD_STATUS_PERMISSION 2 58*efd4c9b6SSteve Lawrence #define ZSD_STATUS_INTERNAL_ERROR 3 59*efd4c9b6SSteve Lawrence 60*efd4c9b6SSteve Lawrence #define TIMESTRUC_ADD_NANOSEC(ts, nsec) \ 61*efd4c9b6SSteve Lawrence { \ 62*efd4c9b6SSteve Lawrence (ts).tv_sec += (time_t)((nsec) / NANOSEC); \ 63*efd4c9b6SSteve Lawrence (ts).tv_nsec += (long)((nsec) % NANOSEC); \ 64*efd4c9b6SSteve Lawrence if ((ts).tv_nsec > NANOSEC) { \ 65*efd4c9b6SSteve Lawrence (ts).tv_sec += (ts).tv_nsec / NANOSEC; \ 66*efd4c9b6SSteve Lawrence (ts).tv_nsec = (ts).tv_nsec % NANOSEC; \ 67*efd4c9b6SSteve Lawrence } \ 68*efd4c9b6SSteve Lawrence } 69*efd4c9b6SSteve Lawrence 70*efd4c9b6SSteve Lawrence #define TIMESTRUC_ADD_TIMESTRUC(ts, add) \ 71*efd4c9b6SSteve Lawrence { \ 72*efd4c9b6SSteve Lawrence (ts).tv_sec += (add).tv_sec; \ 73*efd4c9b6SSteve Lawrence (ts).tv_nsec += (add).tv_nsec; \ 74*efd4c9b6SSteve Lawrence if ((ts).tv_nsec > NANOSEC) { \ 75*efd4c9b6SSteve Lawrence (ts).tv_sec += (ts).tv_nsec / NANOSEC; \ 76*efd4c9b6SSteve Lawrence (ts).tv_nsec = (ts).tv_nsec % NANOSEC; \ 77*efd4c9b6SSteve Lawrence } \ 78*efd4c9b6SSteve Lawrence } 79*efd4c9b6SSteve Lawrence 80*efd4c9b6SSteve Lawrence #define TIMESTRUC_DELTA(delta, new, old) \ 81*efd4c9b6SSteve Lawrence { \ 82*efd4c9b6SSteve Lawrence (delta).tv_sec = (new).tv_sec - (old).tv_sec; \ 83*efd4c9b6SSteve Lawrence (delta).tv_nsec = (new).tv_nsec - (old).tv_nsec;\ 84*efd4c9b6SSteve Lawrence if ((delta).tv_nsec < 0) { \ 85*efd4c9b6SSteve Lawrence delta.tv_nsec += NANOSEC; \ 86*efd4c9b6SSteve Lawrence delta.tv_sec -= 1; \ 87*efd4c9b6SSteve Lawrence } \ 88*efd4c9b6SSteve Lawrence if ((delta).tv_sec < 0) { \ 89*efd4c9b6SSteve Lawrence delta.tv_sec = 0; \ 90*efd4c9b6SSteve Lawrence delta.tv_nsec = 0; \ 91*efd4c9b6SSteve Lawrence } \ 92*efd4c9b6SSteve Lawrence } 93*efd4c9b6SSteve Lawrence 94*efd4c9b6SSteve Lawrence typedef struct zs_system { 95*efd4c9b6SSteve Lawrence 96*efd4c9b6SSteve Lawrence uint64_t zss_ram_total; 97*efd4c9b6SSteve Lawrence uint64_t zss_ram_kern; 98*efd4c9b6SSteve Lawrence uint64_t zss_ram_zones; 99*efd4c9b6SSteve Lawrence 100*efd4c9b6SSteve Lawrence uint64_t zss_locked_kern; 101*efd4c9b6SSteve Lawrence uint64_t zss_locked_zones; 102*efd4c9b6SSteve Lawrence 103*efd4c9b6SSteve Lawrence uint64_t zss_vm_total; 104*efd4c9b6SSteve Lawrence uint64_t zss_vm_kern; 105*efd4c9b6SSteve Lawrence uint64_t zss_vm_zones; 106*efd4c9b6SSteve Lawrence 107*efd4c9b6SSteve Lawrence uint64_t zss_swap_total; 108*efd4c9b6SSteve Lawrence uint64_t zss_swap_used; 109*efd4c9b6SSteve Lawrence 110*efd4c9b6SSteve Lawrence timestruc_t zss_cpu_total_time; 111*efd4c9b6SSteve Lawrence timestruc_t zss_cpu_usage_kern; 112*efd4c9b6SSteve Lawrence timestruc_t zss_cpu_usage_zones; 113*efd4c9b6SSteve Lawrence 114*efd4c9b6SSteve Lawrence uint64_t zss_processes_max; 115*efd4c9b6SSteve Lawrence uint64_t zss_lwps_max; 116*efd4c9b6SSteve Lawrence uint64_t zss_shm_max; 117*efd4c9b6SSteve Lawrence uint64_t zss_shmids_max; 118*efd4c9b6SSteve Lawrence uint64_t zss_semids_max; 119*efd4c9b6SSteve Lawrence uint64_t zss_msgids_max; 120*efd4c9b6SSteve Lawrence uint64_t zss_lofi_max; 121*efd4c9b6SSteve Lawrence 122*efd4c9b6SSteve Lawrence uint64_t zss_processes; 123*efd4c9b6SSteve Lawrence uint64_t zss_lwps; 124*efd4c9b6SSteve Lawrence uint64_t zss_shm; 125*efd4c9b6SSteve Lawrence uint64_t zss_shmids; 126*efd4c9b6SSteve Lawrence uint64_t zss_semids; 127*efd4c9b6SSteve Lawrence uint64_t zss_msgids; 128*efd4c9b6SSteve Lawrence uint64_t zss_lofi; 129*efd4c9b6SSteve Lawrence 130*efd4c9b6SSteve Lawrence uint64_t zss_ncpus; 131*efd4c9b6SSteve Lawrence uint64_t zss_ncpus_online; 132*efd4c9b6SSteve Lawrence 133*efd4c9b6SSteve Lawrence } zs_system_t; 134*efd4c9b6SSteve Lawrence 135*efd4c9b6SSteve Lawrence struct zs_pset_zone { 136*efd4c9b6SSteve Lawrence 137*efd4c9b6SSteve Lawrence list_node_t zspz_next; 138*efd4c9b6SSteve Lawrence struct zs_pset *zspz_pset; 139*efd4c9b6SSteve Lawrence struct zs_zone *zspz_zone; 140*efd4c9b6SSteve Lawrence zoneid_t zspz_zoneid; 141*efd4c9b6SSteve Lawrence time_t zspz_start; 142*efd4c9b6SSteve Lawrence hrtime_t zspz_hrstart; 143*efd4c9b6SSteve Lawrence uint_t zspz_intervals; 144*efd4c9b6SSteve Lawrence 145*efd4c9b6SSteve Lawrence uint64_t zspz_cpu_shares; 146*efd4c9b6SSteve Lawrence uint_t zspz_scheds; 147*efd4c9b6SSteve Lawrence 148*efd4c9b6SSteve Lawrence timestruc_t zspz_cpu_usage; 149*efd4c9b6SSteve Lawrence 150*efd4c9b6SSteve Lawrence }; 151*efd4c9b6SSteve Lawrence 152*efd4c9b6SSteve Lawrence struct zs_ctl { 153*efd4c9b6SSteve Lawrence int zsctl_door; 154*efd4c9b6SSteve Lawrence uint64_t zsctl_gen; 155*efd4c9b6SSteve Lawrence zs_usage_t *zsctl_start; 156*efd4c9b6SSteve Lawrence }; 157*efd4c9b6SSteve Lawrence 158*efd4c9b6SSteve Lawrence struct zs_zone { 159*efd4c9b6SSteve Lawrence list_node_t zsz_next; 160*efd4c9b6SSteve Lawrence struct zs_system *zsz_system; 161*efd4c9b6SSteve Lawrence char zsz_name[ZS_ZONENAME_MAX]; 162*efd4c9b6SSteve Lawrence char zsz_pool[ZS_POOLNAME_MAX]; 163*efd4c9b6SSteve Lawrence char zsz_pset[ZS_PSETNAME_MAX]; 164*efd4c9b6SSteve Lawrence zoneid_t zsz_id; 165*efd4c9b6SSteve Lawrence uint_t zsz_cputype; 166*efd4c9b6SSteve Lawrence uint_t zsz_iptype; 167*efd4c9b6SSteve Lawrence time_t zsz_start; 168*efd4c9b6SSteve Lawrence hrtime_t zsz_hrstart; 169*efd4c9b6SSteve Lawrence uint_t zsz_intervals; 170*efd4c9b6SSteve Lawrence 171*efd4c9b6SSteve Lawrence uint_t zsz_scheds; 172*efd4c9b6SSteve Lawrence uint64_t zsz_cpu_shares; 173*efd4c9b6SSteve Lawrence uint64_t zsz_cpu_cap; 174*efd4c9b6SSteve Lawrence uint64_t zsz_ram_cap; 175*efd4c9b6SSteve Lawrence uint64_t zsz_vm_cap; 176*efd4c9b6SSteve Lawrence uint64_t zsz_locked_cap; 177*efd4c9b6SSteve Lawrence 178*efd4c9b6SSteve Lawrence uint64_t zsz_cpus_online; 179*efd4c9b6SSteve Lawrence timestruc_t zsz_cpu_usage; 180*efd4c9b6SSteve Lawrence timestruc_t zsz_pset_time; 181*efd4c9b6SSteve Lawrence timestruc_t zsz_cap_time; 182*efd4c9b6SSteve Lawrence timestruc_t zsz_share_time; 183*efd4c9b6SSteve Lawrence 184*efd4c9b6SSteve Lawrence uint64_t zsz_usage_ram; 185*efd4c9b6SSteve Lawrence uint64_t zsz_usage_locked; 186*efd4c9b6SSteve Lawrence uint64_t zsz_usage_vm; 187*efd4c9b6SSteve Lawrence 188*efd4c9b6SSteve Lawrence uint64_t zsz_processes_cap; 189*efd4c9b6SSteve Lawrence uint64_t zsz_lwps_cap; 190*efd4c9b6SSteve Lawrence uint64_t zsz_shm_cap; 191*efd4c9b6SSteve Lawrence uint64_t zsz_shmids_cap; 192*efd4c9b6SSteve Lawrence uint64_t zsz_semids_cap; 193*efd4c9b6SSteve Lawrence uint64_t zsz_msgids_cap; 194*efd4c9b6SSteve Lawrence uint64_t zsz_lofi_cap; 195*efd4c9b6SSteve Lawrence 196*efd4c9b6SSteve Lawrence uint64_t zsz_processes; 197*efd4c9b6SSteve Lawrence uint64_t zsz_lwps; 198*efd4c9b6SSteve Lawrence uint64_t zsz_shm; 199*efd4c9b6SSteve Lawrence uint64_t zsz_shmids; 200*efd4c9b6SSteve Lawrence uint64_t zsz_semids; 201*efd4c9b6SSteve Lawrence uint64_t zsz_msgids; 202*efd4c9b6SSteve Lawrence uint64_t zsz_lofi; 203*efd4c9b6SSteve Lawrence 204*efd4c9b6SSteve Lawrence }; 205*efd4c9b6SSteve Lawrence 206*efd4c9b6SSteve Lawrence struct zs_pset { 207*efd4c9b6SSteve Lawrence list_node_t zsp_next; 208*efd4c9b6SSteve Lawrence char zsp_name[ZS_PSETNAME_MAX]; 209*efd4c9b6SSteve Lawrence psetid_t zsp_id; 210*efd4c9b6SSteve Lawrence uint_t zsp_cputype; 211*efd4c9b6SSteve Lawrence time_t zsp_start; 212*efd4c9b6SSteve Lawrence hrtime_t zsp_hrstart; 213*efd4c9b6SSteve Lawrence uint_t zsp_intervals; 214*efd4c9b6SSteve Lawrence 215*efd4c9b6SSteve Lawrence uint64_t zsp_online; 216*efd4c9b6SSteve Lawrence uint64_t zsp_size; 217*efd4c9b6SSteve Lawrence uint64_t zsp_min; 218*efd4c9b6SSteve Lawrence uint64_t zsp_max; 219*efd4c9b6SSteve Lawrence int64_t zsp_importance; 220*efd4c9b6SSteve Lawrence 221*efd4c9b6SSteve Lawrence uint_t zsp_scheds; 222*efd4c9b6SSteve Lawrence uint64_t zsp_cpu_shares; 223*efd4c9b6SSteve Lawrence timestruc_t zsp_total_time; 224*efd4c9b6SSteve Lawrence timestruc_t zsp_usage_kern; 225*efd4c9b6SSteve Lawrence timestruc_t zsp_usage_zones; 226*efd4c9b6SSteve Lawrence 227*efd4c9b6SSteve Lawrence uint_t zsp_nusage; 228*efd4c9b6SSteve Lawrence list_t zsp_usage_list; 229*efd4c9b6SSteve Lawrence }; 230*efd4c9b6SSteve Lawrence 231*efd4c9b6SSteve Lawrence struct zs_usage { 232*efd4c9b6SSteve Lawrence time_t zsu_start; 233*efd4c9b6SSteve Lawrence hrtime_t zsu_hrstart; 234*efd4c9b6SSteve Lawrence time_t zsu_time; 235*efd4c9b6SSteve Lawrence hrtime_t zsu_hrtime; 236*efd4c9b6SSteve Lawrence uint64_t zsu_size; 237*efd4c9b6SSteve Lawrence uint_t zsu_intervals; 238*efd4c9b6SSteve Lawrence uint64_t zsu_gen; 239*efd4c9b6SSteve Lawrence boolean_t zsu_mmap; 240*efd4c9b6SSteve Lawrence uint_t zsu_nzones; 241*efd4c9b6SSteve Lawrence uint_t zsu_npsets; 242*efd4c9b6SSteve Lawrence zs_system_t *zsu_system; 243*efd4c9b6SSteve Lawrence list_t zsu_zone_list; 244*efd4c9b6SSteve Lawrence list_t zsu_pset_list; 245*efd4c9b6SSteve Lawrence }; 246*efd4c9b6SSteve Lawrence 247*efd4c9b6SSteve Lawrence struct zs_usage_set { 248*efd4c9b6SSteve Lawrence struct zs_usage *zsus_total; 249*efd4c9b6SSteve Lawrence struct zs_usage *zsus_avg; 250*efd4c9b6SSteve Lawrence struct zs_usage *zsus_high; 251*efd4c9b6SSteve Lawrence uint_t zsus_count; 252*efd4c9b6SSteve Lawrence }; 253*efd4c9b6SSteve Lawrence 254*efd4c9b6SSteve Lawrence struct zs_property { 255*efd4c9b6SSteve Lawrence int zsp_type; 256*efd4c9b6SSteve Lawrence int zsp_id; 257*efd4c9b6SSteve Lawrence union zsp_value_union { 258*efd4c9b6SSteve Lawrence char zsv_string[ZS_PSETNAME_MAX]; 259*efd4c9b6SSteve Lawrence timestruc_t zsv_ts; 260*efd4c9b6SSteve Lawrence double zsv_double; 261*efd4c9b6SSteve Lawrence uint64_t zsv_uint64; 262*efd4c9b6SSteve Lawrence int64_t zsv_int64; 263*efd4c9b6SSteve Lawrence uint_t zsv_uint; 264*efd4c9b6SSteve Lawrence int zsv_int; 265*efd4c9b6SSteve Lawrence } zsp_v; 266*efd4c9b6SSteve Lawrence }; 267*efd4c9b6SSteve Lawrence 268*efd4c9b6SSteve Lawrence typedef struct zs_usage_cache { 269*efd4c9b6SSteve Lawrence int zsuc_ref; 270*efd4c9b6SSteve Lawrence uint_t zsuc_size; 271*efd4c9b6SSteve Lawrence uint64_t zsuc_gen; 272*efd4c9b6SSteve Lawrence zs_usage_t *zsuc_usage; 273*efd4c9b6SSteve Lawrence } zs_usage_cache_t; 274*efd4c9b6SSteve Lawrence 275*efd4c9b6SSteve Lawrence 276*efd4c9b6SSteve Lawrence #ifdef __cplusplus 277*efd4c9b6SSteve Lawrence } 278*efd4c9b6SSteve Lawrence #endif 279*efd4c9b6SSteve Lawrence 280*efd4c9b6SSteve Lawrence #endif /* _ZONESTAT_IMPL_H */ 281