Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/include/sys/zone_kstat.h
Real path: /usr/include/sys/zone_kstat.h
Zurück
/* * Copyright (c) 2015, 2021, Oracle and/or its affiliates. */ #ifndef _SYS_ZONE_KSTAT_H #define _SYS_ZONE_KSTAT_H #include <sys/kstat2.h> #include <sys/types.h> #include <sys/cpupart.h> #include <sys/procset.h> #include <sys/nvpair.h> #include <sys/exacct.h> #include <sys/time.h> #include <sys/list.h> #ifdef __cplusplus extern "C" { #endif #ifdef _KERNEL /* We often store non-negative integer id as string, so we define its length. */ #define ZONE_INT_STR_LEN (sizeof (BUILD_STRING(INT_MAX))) typedef struct l_pset_kstat { kstat2_t *lpk_stat; list_node_t lpk_next; } l_pset_kstat_t; typedef enum { ACCUM_ASSOC_NONE, ACCUM_ASSOC_ADD, ACCUM_ASSOC_ADD_RM } accum_assoc_state_t; /* * Brief summary of zone CPU sys kstat value layout. * * There are 3 groups of zone kstats: per-CPU kstat, accum kstat, and pset accum * kstat (all of them are zone specific). All these 3 kstats have their own * array of kstat2_named_t objects, and each kstat2_named_t object contains the * actual data for each kstat value. * * All 3 groups of kstats have a set of overlapping kstat values, which have * similar names, data types and metadata. We call these kstat values 'common' * and their (to be precise, kstat2_named_t and kstat2_md_t objects') array * indexes are defined in zks_index_cpu_cmn_t. Offsets for other kstat values, * which are kstat specific, are defined in zks_index_cpu_t, * zks_index_accum_t, and zks_index_pset_accum_t for per-CPU kstat, * accum kstat and pset accum kstat, respectively. * * For a given kstat, we access kstat2_named_t objects in it by these indexes. * In case when these indexes do not point to kstat2_named_t objects directly, * we often use some macros to convert indexes to actual kstat2_named_t objects. */ /* * Offsets, kstat2 names and metadata for 'common' CPU sys kstat values. We do * not have counters for CPU idle state there as we have them for the global CPU * stats since it does not make sense to assign idle time fractions to specific * non-global zones. These kstat values will be used in slightly different way * in per-CPU kstats by using suffix in ZKS_CPU_CMN_NAME() and ZKS_CPU_CMN_MD(). * The argument suffix in both macros must be a string literal. */ /* index for common CPU sys kstat values */ typedef enum { ZKI_CPU_CMN_INVALID = -1, ZKI_CPU_CMN_CPU_TICKS_USER, ZKI_CPU_CMN_CPU_TICKS_KERNEL, ZKI_CPU_CMN_CPU_NSEC_USER, ZKI_CPU_CMN_CPU_NSEC_KERNEL, ZKI_CPU_CMN_SYSCALL, ZKI_CPU_CMN_SYSREAD, ZKI_CPU_CMN_SYSWRITE, ZKI_CPU_CMN_SYSFORK, ZKI_CPU_CMN_SYSVFORK, ZKI_CPU_CMN_SYSEXEC, ZKI_CPU_CMN_SYSSPAWN, ZKI_CPU_CMN_READCH, ZKI_CPU_CMN_WRITECH, ZKI_CPU_CMN_MSG, ZKI_CPU_CMN_SEMA, ZKI_CPU_CMN_NAMEI, ZKI_CPU_CMN_PROCOVF, ZKI_CPU_CMN_MAX } zks_index_cpu_cmn_t; /* common CPU sys kstat names */ #define ZKS_CPU_CMN_NAME(suffix) \ { {"cpu_ticks_user" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"cpu_ticks_kernel" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"cpu_nsec_user" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"cpu_nsec_kernel" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"syscall" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sysread" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"syswrite" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sysfork" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sysvfork" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sysexec" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sysspawn" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"readch" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"writech" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"msg" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"sema" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"namei" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE }, \ { {"procovf" suffix}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE } /* common CPU sys kstat metadata */ #define ZKS_CPU_CMN_MD(suffix) \ /* cpu_ticks_user */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total user ticks" suffix, KSTAT_DATA_UINT64 }, \ /* cpu_ticks_kernel */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total kernel ticks" suffix, KSTAT_DATA_UINT64 }, \ /* cpu_nsec_user */ \ { KSTAT2_NVMT_T_ACC, KSTAT2_NVMF_FRACT, KSTAT2_SCALE_NS_TO_SEC, \ "total user time" suffix, KSTAT_DATA_UINT64 }, \ /* cpu_nsec_kernel */ \ { KSTAT2_NVMT_T_ACC, KSTAT2_NVMF_FRACT, KSTAT2_SCALE_NS_TO_SEC, \ "total kernel time" suffix, KSTAT_DATA_UINT64 }, \ /* syscall */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total system calls" suffix, KSTAT_DATA_UINT64 }, \ /* sysread */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total read(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* syswrite */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total write(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* sysfork */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total fork(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* sysvfork */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total vfork(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* sysexec */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total exec(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* sysspawn */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total spawn(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* readch */ \ { KSTAT2_NVMT_BYTES, KSTAT2_NVMF_NONE, 1UL, \ "bytes read by all read(2) system calls" suffix, \ KSTAT_DATA_UINT64 }, \ /* writech */ \ { KSTAT2_NVMT_BYTES, KSTAT2_NVMF_NONE, 1UL, \ "bytes written by all write(2) system calls" suffix, \ KSTAT_DATA_UINT64 }, \ /* msg */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total msgrcv(2) and msgsnd(2) system calls" suffix, \ KSTAT_DATA_UINT64 }, \ /* sema */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "total semop(2) system calls" suffix, KSTAT_DATA_UINT64 }, \ /* namei */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "pathname lookups" suffix, KSTAT_DATA_UINT64 }, \ /* procovf */ \ { KSTAT2_NVMT_CNT, KSTAT2_NVMF_NONE, 1UL, \ "proc table overflows" suffix, KSTAT_DATA_UINT64 } /* * A per-CPU kstat consists of 3 kinds of kstat values. First ZKI_CPU_CMN_MAX * kstat values are 'total' kstat values, a copy of 'common' kstat values * defined above, which provide data since the zone boot. After that, next * ZKI_CPU_CMN_MAX kstat values are another copy of 'common' kstat values, with * "_cur" appended to their names. They are called 'current' kstat values and * zeroed out on relevant CPU events. After that, other kstat values follow, * which are indexed by indexes defined in zks_index_cpu_t. */ /* * index for per-CPU-specific kstat values that comes after 'total' and * 'current' kstat values. */ typedef enum { ZKI_CPU_INVALID = -1, ZKI_CPU_ZONEID, ZKI_CPU_ZONENAME, ZKI_CPU_CPUID, ZKI_CPU_MAX } zks_index_cpu_t; /* * We have 2 copies of 'common' kstat values, so nelem is computed as * follows. */ #define ZKS_CPU_NELEM (2 * ZKI_CPU_CMN_MAX + ZKI_CPU_MAX) /* * macro to get 'total' and 'current' CPU sys kstat2_named_t objects. Note that * 'total' kstat values come first, and 'current' kstat values comes next. */ #define ZKS_CPU_TOT_KN(kn, index) (&(kn)[(index)]) #define ZKS_CPU_CUR_KN(kn, index) (&(kn)[ZKI_CPU_CMN_MAX + (index)]) /* * macro to get per-CPU-specific kstat2_named_t object. They follow after both * 'total' and 'current' kstat values, so the beginning index is * 2 * ZKI_CPU_CMN_MAX. */ #define ZKS_CPU_KN(kn, index) (&(kn)[2 * ZKI_CPU_CMN_MAX + (index)]) /* * accum and pset accum kstats are structured in similar way. They store CPU sys * data of zone-level or zone-pset-level which are not captured by per-CPU * 'current' kstat values. These kstats first have a copy of 'common' kstat * values, and after that, they have their own kstat values, which are indexed * by indexes defined in zks_index_accum_t/zks_index_pset_accum_t. */ typedef enum { ZKI_ACCUM_INVALID = -1, ZKI_ACCUM_ZONENAME, ZKI_ACCUM_GEN_NUM, ZKI_ACCUM_ZONEID, ZKI_ACCUM_MAX } zks_index_accum_t; #define ZKS_ACCUM_NELEM (ZKI_CPU_CMN_MAX + ZKI_ACCUM_MAX) #define ZKS_ACCUM_KN(kn, index) (&(kn)[ZKI_CPU_CMN_MAX + (index)]) typedef enum { ZKI_PSET_ACCUM_INVALID = -1, ZKI_PSET_ACCUM_ZONENAME, ZKI_PSET_ACCUM_GEN_NUM, ZKI_PSET_ACCUM_PSETID, ZKI_PSET_ACCUM_ZONEID, ZKI_PSET_ACCUM_MAX } zks_index_pset_accum_t; #define ZKS_PSET_ACCUM_NELEM (ZKI_CPU_CMN_MAX + ZKI_PSET_ACCUM_MAX) #define ZKS_PSET_ACCUM_KN(kn, index) (&(kn)[ZKI_CPU_CMN_MAX + (index)]) /* * Brief outline of zones memory kstats * * There are 2 types of zones memory kstat. One is for usages of each memory * type, and the other is for caps of each memory type. There are 3 types of * memory: physical, virtual, locked. In addition to that, we keep zone id and * brand for informational purposes. * * For both kstats for usage/cap, their data for template is identical, only * except the description string. */ /* Index for zones memory kstats */ typedef enum { ZKI_MEM_INVALID = -1, ZKI_MEM_LOCKED, ZKI_MEM_PHYSICAL, ZKI_MEM_VIRTUAL, ZKI_MEM_BRAND, ZKI_MEM_ZONEID, ZKI_MEM_PAGESIZE, ZKI_MEM_MAX } zks_index_mem_t; /* * Macros for kstat2_named_t and kstat2_md_t objects for zones memory kstats. * Note that kstat2_named_t objects are same for both usage and cap kstats. */ #define ZKS_MEM_NAME(mem) \ { { #mem }, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE } #define ZKS_MEM_USAGE_MD(mem) \ { KSTAT2_NVMT_BYTES, KSTAT2_NVMF_NONE, 1UL, \ "amount of " #mem " memory in use", KSTAT1_DATA_NONE } #define ZKS_MEM_CAP_MD(mem) \ { KSTAT2_NVMT_BYTES, KSTAT2_NVMF_LIMIT, 1UL, \ "limit of " #mem " memory usage", KSTAT1_DATA_NONE } #define ZKS_MEM_LOCKED_NAME ZKS_MEM_NAME(locked) #define ZKS_MEM_LOCKED_USAGE_MD ZKS_MEM_USAGE_MD(locked) #define ZKS_MEM_LOCKED_CAP_MD ZKS_MEM_CAP_MD(locked) #define ZKS_MEM_PHYSICAL_NAME ZKS_MEM_NAME(physical) #define ZKS_MEM_PHYSICAL_USAGE_MD ZKS_MEM_USAGE_MD(physical) #define ZKS_MEM_PHYSICAL_CAP_MD ZKS_MEM_CAP_MD(physical) #define ZKS_MEM_VIRTUAL_NAME ZKS_MEM_NAME(virtual) #define ZKS_MEM_VIRTUAL_USAGE_MD ZKS_MEM_USAGE_MD(virtual) #define ZKS_MEM_VIRTUAL_CAP_MD ZKS_MEM_CAP_MD(virtual) #define ZKS_MEM_PAGESIZE_NAME \ { {"pagesize"}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE } #define ZKS_MEM_PAGESIZE_USAGE_MD \ { KSTAT2_NVMT_BYTES, KSTAT2_NVMF_NONE, 1UL, \ "size of the page", KSTAT1_DATA_NONE } /* kstat names and metadata for commonly used kstat values. */ /* * Some kstat1 values will not be converted to kstat2. In this case, we use * following metadata. */ #define ZKS_UNUSED_MD(kstat1_data_type) \ { KSTAT2_NVMT_UNK, KSTAT2_NVMF_NONE, 1UL, "UNUSED", (kstat1_data_type) } /* * zoneid: In some cases, zoneid is not visible in kstat v1 since it is already * available as instance. So we do not hard-code kstat1_data_type here. */ #define ZKS_ZONEID_NAME \ { {"zoneid"}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE } #define ZKS_ZONEID_MD(kstat1_data_type) \ { KSTAT2_NVMT_ID, KSTAT2_NVMF_IMMUT, 1UL, "zone id", \ (kstat1_data_type) } /* * zonename: Note that zonename is not published in kstat2 since zonename is * part of kstat2 name scheme of zone CPU sys kstat. Although not specified in * metadata, zonename is immutable just as zoneid. */ #define ZKS_ZONENAME_NAME \ { {"zonename"}, KSTAT2_NVVT_STR, _KSTAT2_NVF_V1ONLY } #define ZKS_ZONENAME_MD \ ZKS_UNUSED_MD(KSTAT_DATA_STRING) /* gen_num */ #define ZKS_GEN_NUM_NAME \ { {"gen_num"}, KSTAT2_NVVT_INT, KSTAT2_NVF_NONE } #define ZKS_GEN_NUM_MD \ { KSTAT2_NVMT_ID, KSTAT2_NVMF_NONE, 1UL, "generation number", \ KSTAT_DATA_UINT64 } #define ZKS_BRAND_NAME \ { {"brand"}, KSTAT2_NVVT_STR, KSTAT2_NVF_NONE } #define ZKS_BRAND_MD \ { KSTAT2_NVMT_ID, KSTAT2_NVMF_IMMUT, 1UL, "zone's brand name", \ KSTAT1_DATA_NONE } /* * Accumulated kstat related functions (for zone accum and zone-pset accum * kstats). */ extern void accum_zpset_kstat_add(psetid_t, cpupart_t *, zone_t *); extern boolean_t accum_zpset_kstat_rm(int, cpupart_t *, zoneid_t, boolean_t); extern void accum_zpset_kstat_rm_all(zone_t *, psetid_t); extern accum_assoc_state_t accum_zpset_assoc_change(psetid_t, zoneid_t, zoneid_t *); extern void accum_zpset_data_add(cpu_t *); /* * Zone CPU stat related functions. */ extern void zcs_kstat_add_accum_counters(kstat2_named_t *, zone_cpu_stats_t *, hrtime_t *); extern void zcs_cpu_stats_clear(zone_t *, cpu_t *); extern void zcs_pset_add(zone_t *, psetid_t); extern void zcs_pset_remove(zone_t *, psetid_t); /* Zones' memory kstat related functions. */ extern void zks_mem_create(zone_t *); extern void zks_mem_clear(zone_t *); #endif /* _KERNEL */ #ifdef __cplusplus } #endif #endif /* _SYS_ZONE_KSTAT_H */