Lines Matching refs:ctl

811 zsd_lookup_zone(zsd_ctl_t *ctl, char *zonename, zoneid_t zoneid)  in zsd_lookup_zone()  argument
815 for (zone = list_head(&ctl->zsctl_zones); zone != NULL; in zsd_lookup_zone()
816 zone = list_next(&ctl->zsctl_zones, zone)) { in zsd_lookup_zone()
827 zsd_lookup_zone_byid(zsd_ctl_t *ctl, zoneid_t zoneid) in zsd_lookup_zone_byid() argument
831 for (zone = list_head(&ctl->zsctl_zones); zone != NULL; in zsd_lookup_zone_byid()
832 zone = list_next(&ctl->zsctl_zones, zone)) { in zsd_lookup_zone_byid()
840 zsd_allocate_zone(zsd_ctl_t *ctl, char *zonename, zoneid_t zoneid) in zsd_allocate_zone() argument
874 ctl->zsctl_nzones++; in zsd_allocate_zone()
880 zsd_lookup_insert_zone(zsd_ctl_t *ctl, char *zonename, zoneid_t zoneid) in zsd_lookup_insert_zone() argument
884 if ((zone = zsd_lookup_zone(ctl, zonename, zoneid)) != NULL) in zsd_lookup_insert_zone()
887 if ((zone = zsd_allocate_zone(ctl, zonename, zoneid)) == NULL) in zsd_lookup_insert_zone()
891 tmp = list_head(&ctl->zsctl_zones); in zsd_lookup_insert_zone()
893 tmp = list_next(&ctl->zsctl_zones, tmp); in zsd_lookup_insert_zone()
895 list_insert_before(&ctl->zsctl_zones, tmp, zone); in zsd_lookup_insert_zone()
905 zsd_mark_zones_start(zsd_ctl_t *ctl) in zsd_mark_zones_start() argument
910 for (zone = list_head(&ctl->zsctl_zones); zone != NULL; in zsd_mark_zones_start()
911 zone = list_next(&ctl->zsctl_zones, zone)) { in zsd_mark_zones_start()
941 zsd_mark_psets_start(zsd_ctl_t *ctl) in zsd_mark_psets_start() argument
945 for (pset = list_head(&ctl->zsctl_psets); pset != NULL; in zsd_mark_psets_start()
946 pset = list_next(&ctl->zsctl_psets, pset)) { in zsd_mark_psets_start()
1037 zsd_add_usage(zsd_ctl_t *ctl, zsd_pset_usage_t *usage, timestruc_t *delta) in zsd_add_usage() argument
1039 zsd_system_t *system = ctl->zsctl_system; in zsd_add_usage()
1051 zsd_mark_psets_end(zsd_ctl_t *ctl) in zsd_mark_psets_end() argument
1059 pset = list_head(&ctl->zsctl_psets); in zsd_mark_psets_end()
1065 pset = list_next(&ctl->zsctl_psets, pset); in zsd_mark_psets_end()
1066 list_remove(&ctl->zsctl_psets, tmp); in zsd_mark_psets_end()
1068 ctl->zsctl_npsets--; in zsd_mark_psets_end()
1077 pset = list_next(&ctl->zsctl_psets, pset); in zsd_mark_psets_end()
1083 zsd_mark_pset_usages_end(zsd_ctl_t *ctl) in zsd_mark_pset_usages_end() argument
1093 for (pset = list_head(&ctl->zsctl_psets); pset != NULL; in zsd_mark_pset_usages_end()
1094 pset = list_next(&ctl->zsctl_psets, pset)) { in zsd_mark_pset_usages_end()
1110 ctl->zsctl_npset_usages--; in zsd_mark_pset_usages_end()
1134 zsd_mark_zone_found(zsd_ctl_t *ctl, zsd_zone_t *zone, uint64_t cpu_shares, in zsd_mark_zone_found() argument
1143 zsd_system_t *sys = ctl->zsctl_system; in zsd_mark_zone_found()
1210 zsd_mark_zones_end(zsd_ctl_t *ctl) in zsd_mark_zones_end() argument
1218 zone = list_head(&ctl->zsctl_zones); in zsd_mark_zones_end()
1228 zone = list_next(&ctl->zsctl_zones, zone); in zsd_mark_zones_end()
1229 list_remove(&ctl->zsctl_zones, tmp); in zsd_mark_zones_end()
1231 ctl->zsctl_nzones--; in zsd_mark_zones_end()
1239 zone = list_next(&ctl->zsctl_zones, zone); in zsd_mark_zones_end()
1252 zsd_mark_cpus_start(zsd_ctl_t *ctl, boolean_t roll) in zsd_mark_cpus_start() argument
1260 for (cpu = list_head(&ctl->zsctl_cpus); cpu != NULL; in zsd_mark_cpus_start()
1261 cpu = list_next(&ctl->zsctl_cpus, cpu)) { in zsd_mark_cpus_start()
1278 zsd_lookup_insert_cpu(zsd_ctl_t *ctl, processorid_t cpuid) in zsd_lookup_insert_cpu() argument
1282 assert(cpuid < ctl->zsctl_maxcpuid); in zsd_lookup_insert_cpu()
1283 cpu = &(ctl->zsctl_cpu_array[cpuid]); in zsd_lookup_insert_cpu()
1288 list_insert_tail(&ctl->zsctl_cpus, cpu); in zsd_lookup_insert_cpu()
1333 zsd_mark_cpus_end(zsd_ctl_t *ctl) in zsd_mark_cpus_end() argument
1339 cpu = list_head(&ctl->zsctl_cpus); in zsd_mark_cpus_end()
1347 cpu = list_next(&ctl->zsctl_cpus, cpu); in zsd_mark_cpus_end()
1348 list_remove(&ctl->zsctl_cpus, tmp); in zsd_mark_cpus_end()
1370 cpu = list_next(&ctl->zsctl_cpus, cpu); in zsd_mark_cpus_end()
1376 zsd_lookup_pset_byid(zsd_ctl_t *ctl, psetid_t psetid) in zsd_lookup_pset_byid() argument
1380 for (pset = list_head(&ctl->zsctl_psets); pset != NULL; in zsd_lookup_pset_byid()
1381 pset = list_next(&ctl->zsctl_psets, pset)) { in zsd_lookup_pset_byid()
1389 zsd_lookup_pset(zsd_ctl_t *ctl, char *psetname, psetid_t psetid) in zsd_lookup_pset() argument
1393 for (pset = list_head(&ctl->zsctl_psets); pset != NULL; in zsd_lookup_pset()
1394 pset = list_next(&ctl->zsctl_psets, pset)) { in zsd_lookup_pset()
1405 zsd_allocate_pset(zsd_ctl_t *ctl, char *psetname, psetid_t psetid) in zsd_allocate_pset() argument
1426 ctl->zsctl_npsets++; in zsd_allocate_pset()
1432 zsd_lookup_insert_pset(zsd_ctl_t *ctl, char *psetname, psetid_t psetid) in zsd_lookup_insert_pset() argument
1436 if ((pset = zsd_lookup_pset(ctl, psetname, psetid)) != NULL) in zsd_lookup_insert_pset()
1439 if ((pset = zsd_allocate_pset(ctl, psetname, psetid)) == NULL) in zsd_lookup_insert_pset()
1443 tmp = list_head(&ctl->zsctl_psets); in zsd_lookup_insert_pset()
1445 tmp = list_next(&ctl->zsctl_psets, tmp); in zsd_lookup_insert_pset()
1447 list_insert_before(&ctl->zsctl_psets, tmp, pset); in zsd_lookup_insert_pset()
1466 zsd_allocate_pset_usage(zsd_ctl_t *ctl, zsd_pset_t *pset, zsd_zone_t *zone) in zsd_allocate_pset_usage() argument
1493 ctl->zsctl_npset_usages++; in zsd_allocate_pset_usage()
1500 zsd_lookup_insert_usage(zsd_ctl_t *ctl, zsd_pset_t *pset, zsd_zone_t *zone) in zsd_lookup_insert_usage() argument
1508 if ((usage = zsd_allocate_pset_usage(ctl, pset, zone)) == NULL) in zsd_lookup_insert_usage()
1521 zsd_refresh_system(zsd_ctl_t *ctl) in zsd_refresh_system() argument
1523 zsd_system_t *system = ctl->zsctl_system; in zsd_refresh_system()
1538 zsd_update_cpu_stats(zsd_ctl_t *ctl, zsd_cpu_t *cpu) in zsd_update_cpu_stats() argument
1549 sys = ctl->zsctl_system; in zsd_update_cpu_stats()
1556 kstat = kstat_lookup(ctl->zsctl_kstat_ctl, "cpu", cpuid, "sys"); in zsd_update_cpu_stats()
1560 kid = kstat_read(ctl->zsctl_kstat_ctl, kstat, NULL); in zsd_update_cpu_stats()
1634 (pset_prev = zsd_lookup_pset_byid(ctl, in zsd_update_cpu_stats()
1667 zsd_get_pool_pset(zsd_ctl_t *ctl, psetid_t psetid, char *psetname, in zsd_get_pool_pset() argument
1673 pool_conf_t *conf = ctl->zsctl_pool_conf; in zsd_get_pool_pset()
1674 pool_value_t **vals = ctl->zsctl_pool_vals; in zsd_get_pool_pset()
1684 if (ctl->zsctl_pool_status == POOL_DISABLED) { in zsd_get_pool_pset()
1690 old = num = ctl->zsctl_cpu_ncache; in zsd_get_pool_pset()
1692 ctl->zsctl_cpu_cache); in zsd_get_pool_pset()
1703 ctl->zsctl_cpu_cache, num * in zsd_get_pool_pset()
1705 ctl->zsctl_cpu_ncache = num; in zsd_get_pool_pset()
1706 ctl->zsctl_cpu_cache = cache; in zsd_get_pool_pset()
1818 if (num > ctl->zsctl_cpu_ncache) { in zsd_get_pool_pset()
1820 ctl->zsctl_cpu_cache, num * in zsd_get_pool_pset()
1822 ctl->zsctl_cpu_ncache = num; in zsd_get_pool_pset()
1823 ctl->zsctl_cpu_cache = cache; in zsd_get_pool_pset()
1851 ctl->zsctl_cpu_cache[i] = (psetid_t)int64; in zsd_get_pool_pset()
1874 zsd_refresh_psets(zsd_ctl_t *ctl) in zsd_refresh_psets() argument
1895 system = ctl->zsctl_system; in zsd_refresh_psets()
1902 conf = ctl->zsctl_pool_conf; in zsd_refresh_psets()
1903 vals = ctl->zsctl_pool_vals; in zsd_refresh_psets()
1907 if (ctl->zsctl_pool_status == POOL_DISABLED) { in zsd_refresh_psets()
1908 if (pool_conf_open(ctl->zsctl_pool_conf, in zsd_refresh_psets()
1910 ctl->zsctl_pool_status = POOL_ENABLED; in zsd_refresh_psets()
1911 ctl->zsctl_pool_changed = POU_PSET; in zsd_refresh_psets()
1914 ctl->zsctl_pool_changed = 0; in zsd_refresh_psets()
1915 ret = pool_conf_update(ctl->zsctl_pool_conf, in zsd_refresh_psets()
1916 &(ctl->zsctl_pool_changed)); in zsd_refresh_psets()
1919 (void) pool_conf_close(ctl->zsctl_pool_conf); in zsd_refresh_psets()
1920 ctl->zsctl_pool_status = POOL_DISABLED; in zsd_refresh_psets()
1941 if (num > ctl->zsctl_pset_ncache) { in zsd_refresh_psets()
1942 if ((cache = (psetid_t *)realloc(ctl->zsctl_pset_cache, in zsd_refresh_psets()
1946 ctl->zsctl_pset_ncache = num; in zsd_refresh_psets()
1947 ctl->zsctl_pset_cache = cache; in zsd_refresh_psets()
1957 ctl->zsctl_pset_cache[i] = (int)sys_id; in zsd_refresh_psets()
1962 if (ctl->zsctl_pool_status == POOL_ENABLED) { in zsd_refresh_psets()
1963 (void) pool_conf_close(ctl->zsctl_pool_conf); in zsd_refresh_psets()
1964 ctl->zsctl_pool_status = POOL_DISABLED; in zsd_refresh_psets()
1968 old = num = ctl->zsctl_pset_ncache; in zsd_refresh_psets()
1969 (void) pset_list(ctl->zsctl_pset_cache, &num); in zsd_refresh_psets()
1973 if ((cache = (psetid_t *)realloc(ctl->zsctl_pset_cache, in zsd_refresh_psets()
1975 ctl->zsctl_pset_ncache = num + 1; in zsd_refresh_psets()
1976 ctl->zsctl_pset_cache = cache; in zsd_refresh_psets()
1986 ctl->zsctl_pset_cache[num] = ctl->zsctl_pset_cache[0]; in zsd_refresh_psets()
1987 ctl->zsctl_pset_cache[0] = ZS_PSET_DEFAULT; in zsd_refresh_psets()
1991 zsd_mark_cpus_start(ctl, roll_cpus); in zsd_refresh_psets()
1992 zsd_mark_psets_start(ctl); in zsd_refresh_psets()
1999 sys_id = ctl->zsctl_pset_cache[i]; in zsd_refresh_psets()
2000 if (zsd_get_pool_pset(ctl, sys_id, psetname, sizeof (psetname), in zsd_refresh_psets()
2013 pset = zsd_lookup_insert_pset(ctl, psetname, in zsd_refresh_psets()
2014 ctl->zsctl_pset_cache[i]); in zsd_refresh_psets()
2022 cpuid = ctl->zsctl_cpu_cache[j]; in zsd_refresh_psets()
2023 cpu = zsd_lookup_insert_cpu(ctl, cpuid); in zsd_refresh_psets()
2040 zsd_get_zone_pool_pset(zsd_ctl_t *ctl, zsd_zone_t *zone, in zsd_get_zone_pool_pset() argument
2048 pool_conf_t *conf = ctl->zsctl_pool_conf; in zsd_get_zone_pool_pset()
2050 pool_value_t **vals = ctl->zsctl_pool_vals; in zsd_get_zone_pool_pset()
2072 if (ctl->zsctl_pool_status == POOL_DISABLED) in zsd_get_zone_pool_pset()
2201 zsd_get_zone_caps(zsd_ctl_t *ctl, zsd_zone_t *zone, uint64_t *cpu_shares, in zsd_get_zone_caps() argument
2213 zsd_system_t *sys = ctl->zsctl_system; in zsd_get_zone_caps()
2376 zsd_refresh_zones(zsd_ctl_t *ctl) in zsd_refresh_zones() argument
2412 old = num = ctl->zsctl_zone_ncache; in zsd_refresh_zones()
2413 (void) zone_list(ctl->zsctl_zone_cache, &num); in zsd_refresh_zones()
2416 if ((cache = (zoneid_t *)realloc(ctl->zsctl_zone_cache, in zsd_refresh_zones()
2418 ctl->zsctl_zone_ncache = num; in zsd_refresh_zones()
2419 ctl->zsctl_zone_cache = cache; in zsd_refresh_zones()
2426 zsd_mark_zones_start(ctl); in zsd_refresh_zones()
2430 ret = getzonenamebyid(ctl->zsctl_zone_cache[i], in zsd_refresh_zones()
2435 zone = zsd_lookup_insert_zone(ctl, zonename, in zsd_refresh_zones()
2436 ctl->zsctl_zone_cache[i]); in zsd_refresh_zones()
2438 ret = zone_getattr(ctl->zsctl_zone_cache[i], ZONE_ATTR_FLAGS, in zsd_refresh_zones()
2448 zsd_get_zone_pool_pset(ctl, zone, poolname, sizeof (poolname), in zsd_refresh_zones()
2451 if (zsd_get_zone_caps(ctl, zone, &cpu_shares, &cpu_cap, in zsd_refresh_zones()
2458 zsd_mark_zone_found(ctl, zone, cpu_shares, cpu_cap, ram_cap, in zsd_refresh_zones()
2468 zsd_get_proc_info(zsd_ctl_t *ctl, psinfo_t *psinfo, psetid_t *psetid, in zsd_get_proc_info() argument
2476 proc = &(ctl->zsctl_proc_array[psinfo->pr_pid]); in zsd_get_proc_info()
2523 zsd_open_exacct(zsd_ctl_t *ctl, boolean_t init) in zsd_open_exacct() argument
2537 fd = &ctl->zsctl_proc_fd; in zsd_open_exacct()
2538 eaf = &ctl->zsctl_proc_eaf; in zsd_open_exacct()
2539 stat = &ctl->zsctl_proc_stat; in zsd_open_exacct()
2540 open = &ctl->zsctl_proc_open; in zsd_open_exacct()
2543 fd = &ctl->zsctl_proc_fd_next; in zsd_open_exacct()
2544 eaf = &ctl->zsctl_proc_eaf_next; in zsd_open_exacct()
2545 stat = &ctl->zsctl_proc_stat_next; in zsd_open_exacct()
2546 open = &ctl->zsctl_proc_open_next; in zsd_open_exacct()
2618 zsd_refresh_procs(zsd_ctl_t *ctl, boolean_t init) in zsd_refresh_procs() argument
2646 ret = zsd_open_exacct(ctl, init); in zsd_refresh_procs()
2664 dent = ctl->zsctl_procfs_dent; in zsd_refresh_procs()
2666 (void) memset(dent, 0, ctl->zsctl_procfs_dent_size); in zsd_refresh_procs()
2688 zsd_get_proc_info(ctl, &psinfo, &psetid, &prev_psetid, in zsd_refresh_procs()
2697 zone = zsd_lookup_zone_byid(ctl, zoneid); in zsd_refresh_procs()
2700 pset = zsd_lookup_pset_byid(ctl, psetid); in zsd_refresh_procs()
2703 usage = zsd_lookup_insert_usage(ctl, pset, zone); in zsd_refresh_procs()
2712 prev_zone = zsd_lookup_zone_byid(ctl, prev_zoneid); in zsd_refresh_procs()
2717 prev_pset = zsd_lookup_pset_byid(ctl, prev_psetid); in zsd_refresh_procs()
2728 prev_usage = zsd_lookup_insert_usage(ctl, prev_pset, in zsd_refresh_procs()
2748 zsd_add_usage(ctl, usage, &delta); in zsd_refresh_procs()
2750 zsd_add_usage(ctl, usage, &d1); in zsd_refresh_procs()
2751 zsd_add_usage(ctl, prev_usage, &d2); in zsd_refresh_procs()
2785 ret = ea_get_object(&ctl->zsctl_proc_eaf, &object); in zsd_refresh_procs()
2796 stat = &(ctl->zsctl_proc_stat); in zsd_refresh_procs()
2797 stat_next = &(ctl->zsctl_proc_stat_next); in zsd_refresh_procs()
2805 ea_clear(&ctl->zsctl_proc_eaf); in zsd_refresh_procs()
2812 (void) ea_close(&ctl->zsctl_proc_eaf); in zsd_refresh_procs()
2814 ctl->zsctl_proc_fd = in zsd_refresh_procs()
2815 ctl->zsctl_proc_fd_next; in zsd_refresh_procs()
2816 ctl->zsctl_proc_eaf = in zsd_refresh_procs()
2817 ctl->zsctl_proc_eaf_next; in zsd_refresh_procs()
2818 ctl->zsctl_proc_stat = in zsd_refresh_procs()
2819 ctl->zsctl_proc_stat_next; in zsd_refresh_procs()
2821 ctl->zsctl_proc_fd_next = -1; in zsd_refresh_procs()
2822 ctl->zsctl_proc_open_next = 0; in zsd_refresh_procs()
2843 ret = ea_get_object(&ctl->zsctl_proc_eaf, in zsd_refresh_procs()
2863 proc = &(ctl->zsctl_proc_array[pid]); in zsd_refresh_procs()
2873 pproc = &(ctl->zsctl_proc_array[ppid]); in zsd_refresh_procs()
2877 zone = zsd_lookup_zone(ctl, in zsd_refresh_procs()
2959 pset = zsd_lookup_pset_byid(ctl, prev_psetid); in zsd_refresh_procs()
2964 pset = zsd_lookup_pset_byid(ctl, prev_psetid); in zsd_refresh_procs()
2983 usage = zsd_lookup_insert_usage(ctl, pset, zone); in zsd_refresh_procs()
2995 zsd_add_usage(ctl, usage, &delta); in zsd_refresh_procs()
3005 if (ctl->zsctl_proc_open_next) { in zsd_refresh_procs()
3007 &ctl->zsctl_proc_eaf_next); in zsd_refresh_procs()
3008 ctl->zsctl_proc_open_next = 0; in zsd_refresh_procs()
3009 ctl->zsctl_proc_fd_next = -1; in zsd_refresh_procs()
3027 pproc = &(ctl->zsctl_proc_array[next->zspr_ppid]); in zsd_refresh_procs()
3049 zone = zsd_lookup_zone_byid(ctl, in zsd_refresh_procs()
3058 pset = zsd_lookup_pset_byid(ctl, in zsd_refresh_procs()
3068 usage = zsd_lookup_insert_usage(ctl, pset, zone); in zsd_refresh_procs()
3077 zsd_add_usage(ctl, usage, &proc->zspr_usage); in zsd_refresh_procs()
3093 zone = zsd_lookup_zone_byid(ctl, proc->zspr_zoneid); in zsd_refresh_procs()
3099 pset = zsd_lookup_pset_byid(ctl, prev_psetid); in zsd_refresh_procs()
3101 pset = zsd_lookup_pset(ctl, zone->zsz_pset, -1); in zsd_refresh_procs()
3124 usage = zsd_lookup_insert_usage(ctl, pset, zone); in zsd_refresh_procs()
3129 zsd_add_usage(ctl, usage, &proc->zspr_usage); in zsd_refresh_procs()
3142 if (ctl->zsctl_proc_open_next) { in zsd_refresh_procs()
3143 (void) ea_close(&ctl->zsctl_proc_eaf_next); in zsd_refresh_procs()
3144 ctl->zsctl_proc_open_next = 0; in zsd_refresh_procs()
3145 ctl->zsctl_proc_fd_next = -1; in zsd_refresh_procs()
3156 zsd_getvmusage(zsd_ctl_t *ctl, uint_t flags, time_t age, zsd_vmusage64_t *buf, in zsd_getvmusage() argument
3165 if (ctl->zsctl_kern_bits == 32) { in zsd_getvmusage()
3211 zsd_refresh_memory(zsd_ctl_t *ctl, boolean_t init) in zsd_refresh_memory() argument
3255 sys = ctl->zsctl_system; in zsd_refresh_memory()
3268 if (num_swap_devices > ctl->zsctl_swap_cache_num) { in zsd_refresh_memory()
3272 if (ctl->zsctl_swap_cache != NULL) in zsd_refresh_memory()
3273 free(ctl->zsctl_swap_cache); in zsd_refresh_memory()
3296 ctl->zsctl_swap_cache = swt; in zsd_refresh_memory()
3297 ctl->zsctl_swap_cache_size = swt_size; in zsd_refresh_memory()
3298 ctl->zsctl_swap_cache_num = num_swap_devices; in zsd_refresh_memory()
3300 num_swap_devices = swapctl(SC_LIST, ctl->zsctl_swap_cache); in zsd_refresh_memory()
3316 swent = ctl->zsctl_swap_cache->swt_ent; in zsd_refresh_memory()
3321 disk_swap_total *= ctl->zsctl_pagesize; in zsd_refresh_memory()
3322 disk_swap_used *= ctl->zsctl_pagesize; in zsd_refresh_memory()
3331 kstat = kstat_lookup(ctl->zsctl_kstat_ctl, "unix", 0, "system_pages"); in zsd_refresh_memory()
3335 kid = kstat_read(ctl->zsctl_kstat_ctl, kstat, NULL); in zsd_refresh_memory()
3364 physmem *= ctl->zsctl_pagesize; in zsd_refresh_memory()
3365 pp_kernel *= ctl->zsctl_pagesize; in zsd_refresh_memory()
3370 kstat = kstat_lookup(ctl->zsctl_kstat_ctl, "zfs", 0, "arcstats"); in zsd_refresh_memory()
3372 kid = kstat_read(ctl->zsctl_kstat_ctl, kstat, NULL); in zsd_refresh_memory()
3388 vmusage = ctl->zsctl_vmusage_cache; in zsd_refresh_memory()
3389 num_vmusage = ctl->zsctl_vmusage_cache_num; in zsd_refresh_memory()
3391 ret = zsd_getvmusage(ctl, VMUSAGE_SYSTEM | VMUSAGE_ALL_ZONES, 0, in zsd_refresh_memory()
3404 if (num_vmusage > ctl->zsctl_vmusage_cache_num) { in zsd_refresh_memory()
3408 if (ctl->zsctl_vmusage_cache != NULL) in zsd_refresh_memory()
3409 free(ctl->zsctl_vmusage_cache); in zsd_refresh_memory()
3417 ctl->zsctl_vmusage_cache = vmusage; in zsd_refresh_memory()
3418 ctl->zsctl_vmusage_cache_num = num_vmusage; in zsd_refresh_memory()
3434 zone = zsd_lookup_zone_byid(ctl, vmusage[i].vmu_id); in zsd_refresh_memory()
3455 for (zone = list_head(&ctl->zsctl_zones); zone != NULL; in zsd_refresh_memory()
3456 zone = list_next(&ctl->zsctl_zones, zone)) { in zsd_refresh_memory()
3480 kstat = kstat_lookup(ctl->zsctl_kstat_ctl, "caps", in zsd_refresh_memory()
3483 kid = kstat_read(ctl->zsctl_kstat_ctl, kstat, NULL); in zsd_refresh_memory()
3500 kstat = kstat_lookup(ctl->zsctl_kstat_ctl, "caps", in zsd_refresh_memory()
3503 kid = kstat_read(ctl->zsctl_kstat_ctl, kstat, NULL); in zsd_refresh_memory()
3525 sysconf(_SC_PHYS_PAGES) * ctl->zsctl_pagesize; in zsd_refresh_memory()
3528 * ctl->zsctl_pagesize; in zsd_refresh_memory()
3550 vm_free = (ani.ani_max - ani.ani_resv) * ctl->zsctl_pagesize; in zsd_refresh_memory()
3561 zsd_refresh_cpu_stats(zsd_ctl_t *ctl, boolean_t init) in zsd_refresh_cpu_stats() argument
3574 cpu_next = list_head(&ctl->zsctl_cpus); in zsd_refresh_cpu_stats()
3577 cpu_next = list_next(&ctl->zsctl_cpus, cpu); in zsd_refresh_cpu_stats()
3578 zsd_update_cpu_stats(ctl, cpu); in zsd_refresh_cpu_stats()
3584 ctl->zsctl_hrtime = hrtime; in zsd_refresh_cpu_stats()
3585 ctl->zsctl_hrtime_prev = hrtime; in zsd_refresh_cpu_stats()
3589 ctl->zsctl_hrtime_prev = ctl->zsctl_hrtime; in zsd_refresh_cpu_stats()
3590 ctl->zsctl_hrtime = hrtime; in zsd_refresh_cpu_stats()
3591 if ((hrtime = hrtime - ctl->zsctl_hrtime_prev) > 0) in zsd_refresh_cpu_stats()
3592 TIMESTRUC_ADD_NANOSEC(ctl->zsctl_hrtime_total, hrtime); in zsd_refresh_cpu_stats()
3599 for (pset = list_head(&ctl->zsctl_psets); pset != NULL; in zsd_refresh_cpu_stats()
3600 pset = list_next(&ctl->zsctl_psets, pset)) { in zsd_refresh_cpu_stats()
3653 for (zone = list_head(&ctl->zsctl_zones); zone != NULL; in zsd_refresh_cpu_stats()
3654 zone = list_next(&ctl->zsctl_zones, zone)) { in zsd_refresh_cpu_stats()
3660 elapsed = ctl->zsctl_hrtime - ctl->zsctl_hrtime_prev; in zsd_refresh_cpu_stats()
3666 sys = ctl->zsctl_system; in zsd_refresh_cpu_stats()
3695 zsd_usage_cache_update(zsd_ctl_t *ctl) in zsd_usage_cache_update() argument
3717 sizeof (zs_zone_t) * ctl->zsctl_nzones + in zsd_usage_cache_update()
3718 sizeof (zs_pset_t) * ctl->zsctl_npsets + in zsd_usage_cache_update()
3719 sizeof (zs_pset_zone_t) * ctl->zsctl_npset_usages; in zsd_usage_cache_update()
3738 usage->zsu_nzones = ctl->zsctl_nzones; in zsd_usage_cache_update()
3739 usage->zsu_npsets = ctl->zsctl_npsets; in zsd_usage_cache_update()
3745 dsys = ctl->zsctl_system; in zsd_usage_cache_update()
3779 for (i = 0, dzone = list_head(&ctl->zsctl_zones); in zsd_usage_cache_update()
3780 i < ctl->zsctl_nzones; in zsd_usage_cache_update()
3781 i++, dzone = list_next(&ctl->zsctl_zones, dzone)) { in zsd_usage_cache_update()
3831 for (i = 0, dpset = list_head(&ctl->zsctl_psets); in zsd_usage_cache_update()
3832 i < ctl->zsctl_npsets; in zsd_usage_cache_update()
3833 i++, dpset = list_next(&ctl->zsctl_psets, dpset)) { in zsd_usage_cache_update()
3919 zsd_close(zsd_ctl_t *ctl) in zsd_close() argument
3927 if (ctl->zsctl_kstat_ctl) { in zsd_close()
3928 (void) kstat_close(ctl->zsctl_kstat_ctl); in zsd_close()
3929 ctl->zsctl_kstat_ctl = NULL; in zsd_close()
3931 if (ctl->zsctl_proc_open) { in zsd_close()
3932 (void) ea_close(&ctl->zsctl_proc_eaf); in zsd_close()
3933 ctl->zsctl_proc_open = 0; in zsd_close()
3934 ctl->zsctl_proc_fd = -1; in zsd_close()
3936 if (ctl->zsctl_pool_conf) { in zsd_close()
3937 if (ctl->zsctl_pool_status == POOL_ENABLED) in zsd_close()
3938 (void) pool_conf_close(ctl->zsctl_pool_conf); in zsd_close()
3939 ctl->zsctl_pool_status = POOL_DISABLED; in zsd_close()
3942 while ((zone = list_head(&ctl->zsctl_zones)) != NULL) { in zsd_close()
3943 list_remove(&ctl->zsctl_zones, zone); in zsd_close()
3945 ctl->zsctl_nzones--; in zsd_close()
3948 while ((pset = list_head(&ctl->zsctl_psets)) != NULL) { in zsd_close()
3952 ctl->zsctl_npset_usages--; in zsd_close()
3955 list_remove(&ctl->zsctl_psets, pset); in zsd_close()
3957 ctl->zsctl_npsets--; in zsd_close()
3961 while (cpu = list_head(&ctl->zsctl_cpus)) { in zsd_close()
3962 list_remove(&ctl->zsctl_cpus, cpu); in zsd_close()
3971 assert(ctl->zsctl_npset_usages == 0); in zsd_close()
3972 assert(ctl->zsctl_npsets == 0); in zsd_close()
3973 assert(ctl->zsctl_nzones == 0); in zsd_close()
3982 zsd_read(zsd_ctl_t *ctl, boolean_t init, boolean_t do_memory) in zsd_read() argument
3984 (void) kstat_chain_update(ctl->zsctl_kstat_ctl); in zsd_read()
3985 (void) gettimeofday(&(ctl->zsctl_timeofday), NULL); in zsd_read()
3987 zsd_refresh_system(ctl); in zsd_read()
3994 zsd_refresh_memory(ctl, init); in zsd_read()
3995 zsd_refresh_zones(ctl); in zsd_read()
3996 zsd_refresh_psets(ctl); in zsd_read()
3997 zsd_refresh_procs(ctl, init); in zsd_read()
3998 zsd_refresh_cpu_stats(ctl, init); in zsd_read()
4005 zsd_mark_pset_usages_end(ctl); in zsd_read()
4006 zsd_mark_psets_end(ctl); in zsd_read()
4007 zsd_mark_cpus_end(ctl); in zsd_read()
4008 zsd_mark_zones_end(ctl); in zsd_read()
4013 zsd_usage_cache_update(ctl); in zsd_read()
4051 zsd_open(zsd_ctl_t *ctl) in zsd_open() argument
4063 if (ctl == NULL && (ctl = (zsd_ctl_t *)calloc(1, in zsd_open()
4069 ctl->zsctl_proc_fd = -1; in zsd_open()
4072 if (ctl->zsctl_kstat_ctl == NULL && in zsd_open()
4073 (ctl->zsctl_kstat_ctl = kstat_open()) == NULL) { in zsd_open()
4086 ctl->zsctl_proc_fd = -1; in zsd_open()
4087 ctl->zsctl_proc_fd_next = -1; in zsd_open()
4088 ctl->zsctl_proc_open = 0; in zsd_open()
4089 ctl->zsctl_proc_open_next = 0; in zsd_open()
4095 if (ctl->zsctl_system == NULL && (ctl->zsctl_system = (zsd_system_t *) in zsd_open()
4102 system = ctl->zsctl_system; in zsd_open()
4106 ctl->zsctl_kern_bits = 32; in zsd_open()
4108 ctl->zsctl_kern_bits = 64; in zsd_open()
4109 ctl->zsctl_pagesize = sysconf(_SC_PAGESIZE); in zsd_open()
4112 ctl->zsctl_maxcpuid = size; in zsd_open()
4113 if (ctl->zsctl_cpu_array == NULL && (ctl->zsctl_cpu_array = in zsd_open()
4119 for (i = 0; i <= ctl->zsctl_maxcpuid; i++) { in zsd_open()
4120 ctl->zsctl_cpu_array[i].zsc_id = i; in zsd_open()
4121 ctl->zsctl_cpu_array[i].zsc_allocated = B_FALSE; in zsd_open()
4122 ctl->zsctl_cpu_array[i].zsc_psetid = ZS_PSET_ERROR; in zsd_open()
4123 ctl->zsctl_cpu_array[i].zsc_psetid_prev = ZS_PSET_ERROR; in zsd_open()
4133 ctl->zsctl_maxproc = size; in zsd_open()
4134 if (ctl->zsctl_proc_array == NULL && in zsd_open()
4135 (ctl->zsctl_proc_array = (zsd_proc_t *)calloc(size, in zsd_open()
4141 for (i = 0; i <= ctl->zsctl_maxproc; i++) { in zsd_open()
4142 list_link_init(&(ctl->zsctl_proc_array[i].zspr_next)); in zsd_open()
4143 ctl->zsctl_proc_array[i].zspr_psetid = ZS_PSET_ERROR; in zsd_open()
4144 ctl->zsctl_proc_array[i].zspr_zoneid = -1; in zsd_open()
4145 ctl->zsctl_proc_array[i].zspr_usage.tv_sec = 0; in zsd_open()
4146 ctl->zsctl_proc_array[i].zspr_usage.tv_nsec = 0; in zsd_open()
4147 ctl->zsctl_proc_array[i].zspr_ppid = -1; in zsd_open()
4150 list_create(&ctl->zsctl_zones, sizeof (zsd_zone_t), in zsd_open()
4153 list_create(&ctl->zsctl_psets, sizeof (zsd_pset_t), in zsd_open()
4156 list_create(&ctl->zsctl_cpus, sizeof (zsd_cpu_t), in zsd_open()
4167 ctl->zsctl_procfs_dent_size = size; in zsd_open()
4168 if (ctl->zsctl_procfs_dent == NULL && in zsd_open()
4169 (ctl->zsctl_procfs_dent = (struct dirent *)calloc(1, size)) in zsd_open()
4176 if (ctl->zsctl_pool_conf == NULL && in zsd_open()
4177 (ctl->zsctl_pool_conf = pool_conf_alloc()) == NULL) { in zsd_open()
4182 ctl->zsctl_pool_status = POOL_DISABLED; in zsd_open()
4183 ctl->zsctl_pool_changed = 0; in zsd_open()
4185 if (ctl->zsctl_pool_vals[0] == NULL && in zsd_open()
4186 (ctl->zsctl_pool_vals[0] = pool_value_alloc()) == NULL) { in zsd_open()
4191 if (ctl->zsctl_pool_vals[1] == NULL && in zsd_open()
4192 (ctl->zsctl_pool_vals[1] = pool_value_alloc()) == NULL) { in zsd_open()
4197 ctl->zsctl_pool_vals[2] = NULL; in zsd_open()
4213 if (zsd_read(ctl, B_TRUE, B_FALSE) != 0) in zsd_open()
4216 return (ctl); in zsd_open()
4218 if (ctl) in zsd_open()
4219 zsd_close(ctl); in zsd_open()