memstat_uma.c revision 209215
1147997Srwatson/*- 2155552Srwatson * Copyright (c) 2005-2006 Robert N. M. Watson 3147997Srwatson * All rights reserved. 4147997Srwatson * 5147997Srwatson * Redistribution and use in source and binary forms, with or without 6147997Srwatson * modification, are permitted provided that the following conditions 7147997Srwatson * are met: 8147997Srwatson * 1. Redistributions of source code must retain the above copyright 9147997Srwatson * notice, this list of conditions and the following disclaimer. 10147997Srwatson * 2. Redistributions in binary form must reproduce the above copyright 11147997Srwatson * notice, this list of conditions and the following disclaimer in the 12147997Srwatson * documentation and/or other materials provided with the distribution. 13147997Srwatson * 14147997Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15147997Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16147997Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17147997Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18147997Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19147997Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20147997Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21147997Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22147997Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23147997Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24147997Srwatson * SUCH DAMAGE. 25147997Srwatson * 26147997Srwatson * $FreeBSD: head/lib/libmemstat/memstat_uma.c 209215 2010-06-15 19:28:37Z sbruno $ 27147997Srwatson */ 28147997Srwatson 29147997Srwatson#include <sys/param.h> 30147997Srwatson#include <sys/sysctl.h> 31147997Srwatson 32148693Srwatson#define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ 33148627Srwatson#include <vm/vm.h> 34148627Srwatson#include <vm/vm_page.h> 35148627Srwatson 36147997Srwatson#include <vm/uma.h> 37148627Srwatson#include <vm/uma_int.h> 38147997Srwatson 39147997Srwatson#include <err.h> 40147997Srwatson#include <errno.h> 41148627Srwatson#include <kvm.h> 42148627Srwatson#include <nlist.h> 43155550Srwatson#include <stddef.h> 44147997Srwatson#include <stdio.h> 45147997Srwatson#include <stdlib.h> 46147997Srwatson#include <string.h> 47147997Srwatson 48147997Srwatson#include "memstat.h" 49147997Srwatson#include "memstat_internal.h" 50147997Srwatson 51148627Srwatsonstatic struct nlist namelist[] = { 52148627Srwatson#define X_UMA_KEGS 0 53148627Srwatson { .n_name = "_uma_kegs" }, 54148627Srwatson#define X_MP_MAXID 1 55148627Srwatson { .n_name = "_mp_maxid" }, 56155547Srwatson#define X_ALL_CPUS 2 57155547Srwatson { .n_name = "_all_cpus" }, 58148627Srwatson { .n_name = "" }, 59148627Srwatson}; 60148627Srwatson 61147997Srwatson/* 62147997Srwatson * Extract uma(9) statistics from the running kernel, and store all memory 63147997Srwatson * type information in the passed list. For each type, check the list for an 64147997Srwatson * existing entry with the right name/allocator -- if present, update that 65147997Srwatson * entry. Otherwise, add a new entry. On error, the entire list will be 66147997Srwatson * cleared, as entries will be in an inconsistent state. 67147997Srwatson * 68147997Srwatson * To reduce the level of work for a list that starts empty, we keep around a 69147997Srwatson * hint as to whether it was empty when we began, so we can avoid searching 70147997Srwatson * the list for entries to update. Updates are O(n^2) due to searching for 71147997Srwatson * each entry before adding it. 72147997Srwatson */ 73147997Srwatsonint 74147997Srwatsonmemstat_sysctl_uma(struct memory_type_list *list, int flags) 75147997Srwatson{ 76147997Srwatson struct uma_stream_header *ushp; 77147997Srwatson struct uma_type_header *uthp; 78147997Srwatson struct uma_percpu_stat *upsp; 79147997Srwatson struct memory_type *mtp; 80148357Srwatson int count, hint_dontsearch, i, j, maxcpus; 81147997Srwatson char *buffer, *p; 82147997Srwatson size_t size; 83147997Srwatson 84148357Srwatson hint_dontsearch = LIST_EMPTY(&list->mtl_list); 85147997Srwatson 86147997Srwatson /* 87147997Srwatson * Query the number of CPUs, number of malloc types so that we can 88147997Srwatson * guess an initial buffer size. We loop until we succeed or really 89147997Srwatson * fail. Note that the value of maxcpus we query using sysctl is not 90147997Srwatson * the version we use when processing the real data -- that is read 91147997Srwatson * from the header. 92147997Srwatson */ 93147997Srwatsonretry: 94147997Srwatson size = sizeof(maxcpus); 95147997Srwatson if (sysctlbyname("kern.smp.maxcpus", &maxcpus, &size, NULL, 0) < 0) { 96148357Srwatson if (errno == EACCES || errno == EPERM) 97148357Srwatson list->mtl_error = MEMSTAT_ERROR_PERMISSION; 98148357Srwatson else 99148357Srwatson list->mtl_error = MEMSTAT_ERROR_DATAERROR; 100147997Srwatson return (-1); 101147997Srwatson } 102147997Srwatson if (size != sizeof(maxcpus)) { 103148357Srwatson list->mtl_error = MEMSTAT_ERROR_DATAERROR; 104147997Srwatson return (-1); 105147997Srwatson } 106147997Srwatson 107147997Srwatson if (maxcpus > MEMSTAT_MAXCPU) { 108148357Srwatson list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; 109147997Srwatson return (-1); 110147997Srwatson } 111147997Srwatson 112147997Srwatson size = sizeof(count); 113147997Srwatson if (sysctlbyname("vm.zone_count", &count, &size, NULL, 0) < 0) { 114148357Srwatson if (errno == EACCES || errno == EPERM) 115148357Srwatson list->mtl_error = MEMSTAT_ERROR_PERMISSION; 116148357Srwatson else 117148357Srwatson list->mtl_error = MEMSTAT_ERROR_VERSION; 118147997Srwatson return (-1); 119147997Srwatson } 120147997Srwatson if (size != sizeof(count)) { 121148357Srwatson list->mtl_error = MEMSTAT_ERROR_DATAERROR; 122147997Srwatson return (-1); 123147997Srwatson } 124147997Srwatson 125147997Srwatson size = sizeof(*uthp) + count * (sizeof(*uthp) + sizeof(*upsp) * 126147997Srwatson maxcpus); 127147997Srwatson 128147997Srwatson buffer = malloc(size); 129147997Srwatson if (buffer == NULL) { 130148357Srwatson list->mtl_error = MEMSTAT_ERROR_NOMEMORY; 131147997Srwatson return (-1); 132147997Srwatson } 133147997Srwatson 134147997Srwatson if (sysctlbyname("vm.zone_stats", buffer, &size, NULL, 0) < 0) { 135147997Srwatson /* 136147997Srwatson * XXXRW: ENOMEM is an ambiguous return, we should bound the 137147997Srwatson * number of loops, perhaps. 138147997Srwatson */ 139147997Srwatson if (errno == ENOMEM) { 140147997Srwatson free(buffer); 141147997Srwatson goto retry; 142147997Srwatson } 143148357Srwatson if (errno == EACCES || errno == EPERM) 144148357Srwatson list->mtl_error = MEMSTAT_ERROR_PERMISSION; 145148357Srwatson else 146148357Srwatson list->mtl_error = MEMSTAT_ERROR_VERSION; 147147997Srwatson free(buffer); 148147997Srwatson return (-1); 149147997Srwatson } 150147997Srwatson 151147997Srwatson if (size == 0) { 152147997Srwatson free(buffer); 153147997Srwatson return (0); 154147997Srwatson } 155147997Srwatson 156147997Srwatson if (size < sizeof(*ushp)) { 157148357Srwatson list->mtl_error = MEMSTAT_ERROR_VERSION; 158147997Srwatson free(buffer); 159147997Srwatson return (-1); 160147997Srwatson } 161147997Srwatson p = buffer; 162147997Srwatson ushp = (struct uma_stream_header *)p; 163147997Srwatson p += sizeof(*ushp); 164147997Srwatson 165147997Srwatson if (ushp->ush_version != UMA_STREAM_VERSION) { 166148357Srwatson list->mtl_error = MEMSTAT_ERROR_VERSION; 167147997Srwatson free(buffer); 168147997Srwatson return (-1); 169147997Srwatson } 170147997Srwatson 171147997Srwatson if (ushp->ush_maxcpus > MEMSTAT_MAXCPU) { 172148357Srwatson list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; 173147997Srwatson free(buffer); 174147997Srwatson return (-1); 175147997Srwatson } 176147997Srwatson 177147997Srwatson /* 178147997Srwatson * For the remainder of this function, we are quite trusting about 179147997Srwatson * the layout of structures and sizes, since we've determined we have 180147997Srwatson * a matching version and acceptable CPU count. 181147997Srwatson */ 182147997Srwatson maxcpus = ushp->ush_maxcpus; 183147997Srwatson count = ushp->ush_count; 184147997Srwatson for (i = 0; i < count; i++) { 185147997Srwatson uthp = (struct uma_type_header *)p; 186147997Srwatson p += sizeof(*uthp); 187147997Srwatson 188147997Srwatson if (hint_dontsearch == 0) { 189147997Srwatson mtp = memstat_mtl_find(list, ALLOCATOR_UMA, 190147997Srwatson uthp->uth_name); 191147997Srwatson } else 192147997Srwatson mtp = NULL; 193147997Srwatson if (mtp == NULL) 194148354Srwatson mtp = _memstat_mt_allocate(list, ALLOCATOR_UMA, 195147997Srwatson uthp->uth_name); 196147997Srwatson if (mtp == NULL) { 197148619Srwatson _memstat_mtl_empty(list); 198147997Srwatson free(buffer); 199148357Srwatson list->mtl_error = MEMSTAT_ERROR_NOMEMORY; 200147997Srwatson return (-1); 201147997Srwatson } 202147997Srwatson 203147997Srwatson /* 204147997Srwatson * Reset the statistics on a current node. 205147997Srwatson */ 206148354Srwatson _memstat_mt_reset_stats(mtp); 207147997Srwatson 208148007Srwatson mtp->mt_numallocs = uthp->uth_allocs; 209148007Srwatson mtp->mt_numfrees = uthp->uth_frees; 210148071Srwatson mtp->mt_failures = uthp->uth_fails; 211209215Ssbruno mtp->mt_sleeps = uthp->uth_sleeps; 212148007Srwatson 213147997Srwatson for (j = 0; j < maxcpus; j++) { 214147997Srwatson upsp = (struct uma_percpu_stat *)p; 215147997Srwatson p += sizeof(*upsp); 216147997Srwatson 217147997Srwatson mtp->mt_percpu_cache[j].mtp_free = 218147997Srwatson upsp->ups_cache_free; 219147997Srwatson mtp->mt_free += upsp->ups_cache_free; 220147997Srwatson mtp->mt_numallocs += upsp->ups_allocs; 221147997Srwatson mtp->mt_numfrees += upsp->ups_frees; 222147997Srwatson } 223147997Srwatson 224147997Srwatson mtp->mt_size = uthp->uth_size; 225148007Srwatson mtp->mt_memalloced = mtp->mt_numallocs * uthp->uth_size; 226148007Srwatson mtp->mt_memfreed = mtp->mt_numfrees * uthp->uth_size; 227147997Srwatson mtp->mt_bytes = mtp->mt_memalloced - mtp->mt_memfreed; 228147997Srwatson mtp->mt_countlimit = uthp->uth_limit; 229147997Srwatson mtp->mt_byteslimit = uthp->uth_limit * uthp->uth_size; 230147997Srwatson 231147997Srwatson mtp->mt_count = mtp->mt_numallocs - mtp->mt_numfrees; 232148170Srwatson mtp->mt_zonefree = uthp->uth_zone_free; 233148381Srwatson 234148381Srwatson /* 235148381Srwatson * UMA secondary zones share a keg with the primary zone. To 236148381Srwatson * avoid double-reporting of free items, report keg free 237148381Srwatson * items only in the primary zone. 238148381Srwatson */ 239148381Srwatson if (!(uthp->uth_zone_flags & UTH_ZONE_SECONDARY)) { 240148619Srwatson mtp->mt_kegfree = uthp->uth_keg_free; 241148381Srwatson mtp->mt_free += mtp->mt_kegfree; 242148381Srwatson } 243147997Srwatson mtp->mt_free += mtp->mt_zonefree; 244147997Srwatson } 245147997Srwatson 246147997Srwatson free(buffer); 247147997Srwatson 248147997Srwatson return (0); 249147997Srwatson} 250148627Srwatson 251148627Srwatsonstatic int 252148627Srwatsonkread(kvm_t *kvm, void *kvm_pointer, void *address, size_t size, 253148627Srwatson size_t offset) 254148627Srwatson{ 255148627Srwatson ssize_t ret; 256148627Srwatson 257148627Srwatson ret = kvm_read(kvm, (unsigned long)kvm_pointer + offset, address, 258148627Srwatson size); 259148627Srwatson if (ret < 0) 260148627Srwatson return (MEMSTAT_ERROR_KVM); 261148627Srwatson if ((size_t)ret != size) 262148627Srwatson return (MEMSTAT_ERROR_KVM_SHORTREAD); 263148627Srwatson return (0); 264148627Srwatson} 265148627Srwatson 266148627Srwatsonstatic int 267148627Srwatsonkread_string(kvm_t *kvm, void *kvm_pointer, char *buffer, int buflen) 268148627Srwatson{ 269148627Srwatson ssize_t ret; 270148627Srwatson int i; 271148627Srwatson 272148627Srwatson for (i = 0; i < buflen; i++) { 273148627Srwatson ret = kvm_read(kvm, (unsigned long)kvm_pointer + i, 274148627Srwatson &(buffer[i]), sizeof(char)); 275148627Srwatson if (ret < 0) 276148627Srwatson return (MEMSTAT_ERROR_KVM); 277148627Srwatson if ((size_t)ret != sizeof(char)) 278148627Srwatson return (MEMSTAT_ERROR_KVM_SHORTREAD); 279148627Srwatson if (buffer[i] == '\0') 280148627Srwatson return (0); 281148627Srwatson } 282148627Srwatson /* Truncate. */ 283148627Srwatson buffer[i-1] = '\0'; 284148627Srwatson return (0); 285148627Srwatson} 286148627Srwatson 287148627Srwatsonstatic int 288148627Srwatsonkread_symbol(kvm_t *kvm, int index, void *address, size_t size, 289148627Srwatson size_t offset) 290148627Srwatson{ 291148627Srwatson ssize_t ret; 292148627Srwatson 293148627Srwatson ret = kvm_read(kvm, namelist[index].n_value + offset, address, size); 294148627Srwatson if (ret < 0) 295148627Srwatson return (MEMSTAT_ERROR_KVM); 296148627Srwatson if ((size_t)ret != size) 297148627Srwatson return (MEMSTAT_ERROR_KVM_SHORTREAD); 298148627Srwatson return (0); 299148627Srwatson} 300148627Srwatson 301148627Srwatson/* 302148627Srwatson * memstat_kvm_uma() is similar to memstat_sysctl_uma(), only it extracts 303148627Srwatson * UMA(9) statistics from a kernel core/memory file. 304148627Srwatson */ 305148627Srwatsonint 306148627Srwatsonmemstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) 307148627Srwatson{ 308154416Srwatson LIST_HEAD(, uma_keg) uma_kegs; 309148627Srwatson struct memory_type *mtp; 310148627Srwatson struct uma_bucket *ubp, ub; 311155550Srwatson struct uma_cache *ucp, *ucp_array; 312148627Srwatson struct uma_zone *uzp, uz; 313148627Srwatson struct uma_keg *kzp, kz; 314148627Srwatson int hint_dontsearch, i, mp_maxid, ret; 315148627Srwatson char name[MEMTYPE_MAXNAME]; 316155547Srwatson __cpumask_t all_cpus; 317148627Srwatson kvm_t *kvm; 318148627Srwatson 319148627Srwatson kvm = (kvm_t *)kvm_handle; 320148627Srwatson hint_dontsearch = LIST_EMPTY(&list->mtl_list); 321148627Srwatson if (kvm_nlist(kvm, namelist) != 0) { 322148627Srwatson list->mtl_error = MEMSTAT_ERROR_KVM; 323148627Srwatson return (-1); 324148627Srwatson } 325148627Srwatson if (namelist[X_UMA_KEGS].n_type == 0 || 326148627Srwatson namelist[X_UMA_KEGS].n_value == 0) { 327148627Srwatson list->mtl_error = MEMSTAT_ERROR_KVM_NOSYMBOL; 328148627Srwatson return (-1); 329148627Srwatson } 330148627Srwatson ret = kread_symbol(kvm, X_MP_MAXID, &mp_maxid, sizeof(mp_maxid), 0); 331148627Srwatson if (ret != 0) { 332148627Srwatson list->mtl_error = ret; 333148627Srwatson return (-1); 334148627Srwatson } 335148627Srwatson ret = kread_symbol(kvm, X_UMA_KEGS, &uma_kegs, sizeof(uma_kegs), 0); 336148627Srwatson if (ret != 0) { 337148627Srwatson list->mtl_error = ret; 338148627Srwatson return (-1); 339148627Srwatson } 340155547Srwatson ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0); 341155547Srwatson if (ret != 0) { 342155547Srwatson list->mtl_error = ret; 343155547Srwatson return (-1); 344155547Srwatson } 345155550Srwatson ucp_array = malloc(sizeof(struct uma_cache) * (mp_maxid + 1)); 346155550Srwatson if (ucp_array == NULL) { 347155550Srwatson list->mtl_error = MEMSTAT_ERROR_NOMEMORY; 348155550Srwatson return (-1); 349155550Srwatson } 350148627Srwatson for (kzp = LIST_FIRST(&uma_kegs); kzp != NULL; kzp = 351148627Srwatson LIST_NEXT(&kz, uk_link)) { 352148627Srwatson ret = kread(kvm, kzp, &kz, sizeof(kz), 0); 353148627Srwatson if (ret != 0) { 354155550Srwatson free(ucp_array); 355148627Srwatson _memstat_mtl_empty(list); 356148627Srwatson list->mtl_error = ret; 357148627Srwatson return (-1); 358148627Srwatson } 359148627Srwatson for (uzp = LIST_FIRST(&kz.uk_zones); uzp != NULL; uzp = 360148627Srwatson LIST_NEXT(&uz, uz_link)) { 361148627Srwatson ret = kread(kvm, uzp, &uz, sizeof(uz), 0); 362148627Srwatson if (ret != 0) { 363155550Srwatson free(ucp_array); 364148627Srwatson _memstat_mtl_empty(list); 365148627Srwatson list->mtl_error = ret; 366148627Srwatson return (-1); 367148627Srwatson } 368155550Srwatson ret = kread(kvm, uzp, ucp_array, 369155550Srwatson sizeof(struct uma_cache) * (mp_maxid + 1), 370155550Srwatson offsetof(struct uma_zone, uz_cpu[0])); 371155550Srwatson if (ret != 0) { 372155550Srwatson free(ucp_array); 373155550Srwatson _memstat_mtl_empty(list); 374155550Srwatson list->mtl_error = ret; 375155550Srwatson return (-1); 376155550Srwatson } 377148627Srwatson ret = kread_string(kvm, uz.uz_name, name, 378148627Srwatson MEMTYPE_MAXNAME); 379148627Srwatson if (ret != 0) { 380155550Srwatson free(ucp_array); 381148627Srwatson _memstat_mtl_empty(list); 382148627Srwatson list->mtl_error = ret; 383148627Srwatson return (-1); 384148627Srwatson } 385148627Srwatson if (hint_dontsearch == 0) { 386148627Srwatson mtp = memstat_mtl_find(list, ALLOCATOR_UMA, 387148627Srwatson name); 388148627Srwatson } else 389148627Srwatson mtp = NULL; 390148627Srwatson if (mtp == NULL) 391148627Srwatson mtp = _memstat_mt_allocate(list, ALLOCATOR_UMA, 392148627Srwatson name); 393148627Srwatson if (mtp == NULL) { 394155550Srwatson free(ucp_array); 395148627Srwatson _memstat_mtl_empty(list); 396148627Srwatson list->mtl_error = MEMSTAT_ERROR_NOMEMORY; 397148627Srwatson return (-1); 398148627Srwatson } 399148627Srwatson /* 400148627Srwatson * Reset the statistics on a current node. 401148627Srwatson */ 402148627Srwatson _memstat_mt_reset_stats(mtp); 403148627Srwatson mtp->mt_numallocs = uz.uz_allocs; 404148627Srwatson mtp->mt_numfrees = uz.uz_frees; 405148627Srwatson mtp->mt_failures = uz.uz_fails; 406209215Ssbruno mtp->mt_sleeps = uz.uz_sleeps; 407148627Srwatson if (kz.uk_flags & UMA_ZFLAG_INTERNAL) 408148627Srwatson goto skip_percpu; 409148627Srwatson for (i = 0; i < mp_maxid + 1; i++) { 410155547Srwatson if ((all_cpus & (1 << i)) == 0) 411155547Srwatson continue; 412155550Srwatson ucp = &ucp_array[i]; 413148627Srwatson mtp->mt_numallocs += ucp->uc_allocs; 414148627Srwatson mtp->mt_numfrees += ucp->uc_frees; 415148627Srwatson 416148627Srwatson if (ucp->uc_allocbucket != NULL) { 417148627Srwatson ret = kread(kvm, ucp->uc_allocbucket, 418148627Srwatson &ub, sizeof(ub), 0); 419148627Srwatson if (ret != 0) { 420155550Srwatson free(ucp_array); 421148627Srwatson _memstat_mtl_empty(list); 422155549Srwatson list->mtl_error = ret; 423148627Srwatson return (-1); 424148627Srwatson } 425148627Srwatson mtp->mt_free += ub.ub_cnt; 426148627Srwatson } 427148627Srwatson if (ucp->uc_freebucket != NULL) { 428148627Srwatson ret = kread(kvm, ucp->uc_freebucket, 429148627Srwatson &ub, sizeof(ub), 0); 430148627Srwatson if (ret != 0) { 431155550Srwatson free(ucp_array); 432148627Srwatson _memstat_mtl_empty(list); 433155549Srwatson list->mtl_error = ret; 434148627Srwatson return (-1); 435148627Srwatson } 436148627Srwatson mtp->mt_free += ub.ub_cnt; 437148627Srwatson } 438148627Srwatson } 439148627Srwatsonskip_percpu: 440148627Srwatson mtp->mt_size = kz.uk_size; 441148627Srwatson mtp->mt_memalloced = mtp->mt_numallocs * mtp->mt_size; 442148627Srwatson mtp->mt_memfreed = mtp->mt_numfrees * mtp->mt_size; 443155542Srwatson mtp->mt_bytes = mtp->mt_memalloced - mtp->mt_memfreed; 444148627Srwatson if (kz.uk_ppera > 1) 445148627Srwatson mtp->mt_countlimit = kz.uk_maxpages / 446148627Srwatson kz.uk_ipers; 447148627Srwatson else 448148627Srwatson mtp->mt_countlimit = kz.uk_maxpages * 449148627Srwatson kz.uk_ipers; 450148627Srwatson mtp->mt_byteslimit = mtp->mt_countlimit * mtp->mt_size; 451148627Srwatson mtp->mt_count = mtp->mt_numallocs - mtp->mt_numfrees; 452148627Srwatson for (ubp = LIST_FIRST(&uz.uz_full_bucket); ubp != 453148627Srwatson NULL; ubp = LIST_NEXT(&ub, ub_link)) { 454148627Srwatson ret = kread(kvm, ubp, &ub, sizeof(ub), 0); 455148627Srwatson mtp->mt_zonefree += ub.ub_cnt; 456148627Srwatson } 457148627Srwatson if (!((kz.uk_flags & UMA_ZONE_SECONDARY) && 458148627Srwatson LIST_FIRST(&kz.uk_zones) != uzp)) { 459148627Srwatson mtp->mt_kegfree = kz.uk_free; 460148627Srwatson mtp->mt_free += mtp->mt_kegfree; 461148627Srwatson } 462148627Srwatson mtp->mt_free += mtp->mt_zonefree; 463148627Srwatson } 464148627Srwatson } 465155550Srwatson free(ucp_array); 466148627Srwatson return (0); 467148627Srwatson} 468