memstat_uma.c (155542) | memstat_uma.c (155547) |
---|---|
1/*- 2 * Copyright (c) 2005 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2005 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/lib/libmemstat/memstat_uma.c 155542 2006-02-11 16:54:00Z rwatson $ | 26 * $FreeBSD: head/lib/libmemstat/memstat_uma.c 155547 2006-02-11 18:44:37Z rwatson $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/sysctl.h> 31 32#define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ 33#include <vm/vm.h> 34#include <vm/vm_page.h> --- 12 unchanged lines hidden (view full) --- 47#include "memstat.h" 48#include "memstat_internal.h" 49 50static struct nlist namelist[] = { 51#define X_UMA_KEGS 0 52 { .n_name = "_uma_kegs" }, 53#define X_MP_MAXID 1 54 { .n_name = "_mp_maxid" }, | 27 */ 28 29#include <sys/param.h> 30#include <sys/sysctl.h> 31 32#define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ 33#include <vm/vm.h> 34#include <vm/vm_page.h> --- 12 unchanged lines hidden (view full) --- 47#include "memstat.h" 48#include "memstat_internal.h" 49 50static struct nlist namelist[] = { 51#define X_UMA_KEGS 0 52 { .n_name = "_uma_kegs" }, 53#define X_MP_MAXID 1 54 { .n_name = "_mp_maxid" }, |
55#define X_ALL_CPUS 2 56 { .n_name = "_all_cpus" }, |
|
55 { .n_name = "" }, 56}; 57 58/* 59 * Extract uma(9) statistics from the running kernel, and store all memory 60 * type information in the passed list. For each type, check the list for an 61 * existing entry with the right name/allocator -- if present, update that 62 * entry. Otherwise, add a new entry. On error, the entire list will be --- 241 unchanged lines hidden (view full) --- 304 LIST_HEAD(, uma_keg) uma_kegs; 305 struct memory_type *mtp; 306 struct uma_bucket *ubp, ub; 307 struct uma_cache *ucp; 308 struct uma_zone *uzp, uz; 309 struct uma_keg *kzp, kz; 310 int hint_dontsearch, i, mp_maxid, ret; 311 char name[MEMTYPE_MAXNAME]; | 57 { .n_name = "" }, 58}; 59 60/* 61 * Extract uma(9) statistics from the running kernel, and store all memory 62 * type information in the passed list. For each type, check the list for an 63 * existing entry with the right name/allocator -- if present, update that 64 * entry. Otherwise, add a new entry. On error, the entire list will be --- 241 unchanged lines hidden (view full) --- 306 LIST_HEAD(, uma_keg) uma_kegs; 307 struct memory_type *mtp; 308 struct uma_bucket *ubp, ub; 309 struct uma_cache *ucp; 310 struct uma_zone *uzp, uz; 311 struct uma_keg *kzp, kz; 312 int hint_dontsearch, i, mp_maxid, ret; 313 char name[MEMTYPE_MAXNAME]; |
314 __cpumask_t all_cpus; |
|
312 kvm_t *kvm; 313 314 kvm = (kvm_t *)kvm_handle; 315 hint_dontsearch = LIST_EMPTY(&list->mtl_list); 316 if (kvm_nlist(kvm, namelist) != 0) { 317 list->mtl_error = MEMSTAT_ERROR_KVM; 318 return (-1); 319 } --- 7 unchanged lines hidden (view full) --- 327 list->mtl_error = ret; 328 return (-1); 329 } 330 ret = kread_symbol(kvm, X_UMA_KEGS, &uma_kegs, sizeof(uma_kegs), 0); 331 if (ret != 0) { 332 list->mtl_error = ret; 333 return (-1); 334 } | 315 kvm_t *kvm; 316 317 kvm = (kvm_t *)kvm_handle; 318 hint_dontsearch = LIST_EMPTY(&list->mtl_list); 319 if (kvm_nlist(kvm, namelist) != 0) { 320 list->mtl_error = MEMSTAT_ERROR_KVM; 321 return (-1); 322 } --- 7 unchanged lines hidden (view full) --- 330 list->mtl_error = ret; 331 return (-1); 332 } 333 ret = kread_symbol(kvm, X_UMA_KEGS, &uma_kegs, sizeof(uma_kegs), 0); 334 if (ret != 0) { 335 list->mtl_error = ret; 336 return (-1); 337 } |
338 ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0); 339 if (ret != 0) { 340 list->mtl_error = ret; 341 return (-1); 342 } |
|
335 for (kzp = LIST_FIRST(&uma_kegs); kzp != NULL; kzp = 336 LIST_NEXT(&kz, uk_link)) { 337 ret = kread(kvm, kzp, &kz, sizeof(kz), 0); 338 if (ret != 0) { 339 _memstat_mtl_empty(list); 340 list->mtl_error = ret; 341 return (-1); 342 } --- 30 unchanged lines hidden (view full) --- 373 */ 374 _memstat_mt_reset_stats(mtp); 375 mtp->mt_numallocs = uz.uz_allocs; 376 mtp->mt_numfrees = uz.uz_frees; 377 mtp->mt_failures = uz.uz_fails; 378 if (kz.uk_flags & UMA_ZFLAG_INTERNAL) 379 goto skip_percpu; 380 for (i = 0; i < mp_maxid + 1; i++) { | 343 for (kzp = LIST_FIRST(&uma_kegs); kzp != NULL; kzp = 344 LIST_NEXT(&kz, uk_link)) { 345 ret = kread(kvm, kzp, &kz, sizeof(kz), 0); 346 if (ret != 0) { 347 _memstat_mtl_empty(list); 348 list->mtl_error = ret; 349 return (-1); 350 } --- 30 unchanged lines hidden (view full) --- 381 */ 382 _memstat_mt_reset_stats(mtp); 383 mtp->mt_numallocs = uz.uz_allocs; 384 mtp->mt_numfrees = uz.uz_frees; 385 mtp->mt_failures = uz.uz_fails; 386 if (kz.uk_flags & UMA_ZFLAG_INTERNAL) 387 goto skip_percpu; 388 for (i = 0; i < mp_maxid + 1; i++) { |
389 if ((all_cpus & (1 << i)) == 0) 390 continue; |
|
381 ucp = &uz.uz_cpu[i]; 382 mtp->mt_numallocs += ucp->uc_allocs; 383 mtp->mt_numfrees += ucp->uc_frees; 384 385 if (ucp->uc_allocbucket != NULL) { 386 ret = kread(kvm, ucp->uc_allocbucket, 387 &ub, sizeof(ub), 0); 388 if (ret != 0) { --- 47 unchanged lines hidden --- | 391 ucp = &uz.uz_cpu[i]; 392 mtp->mt_numallocs += ucp->uc_allocs; 393 mtp->mt_numfrees += ucp->uc_frees; 394 395 if (ucp->uc_allocbucket != NULL) { 396 ret = kread(kvm, ucp->uc_allocbucket, 397 &ub, sizeof(ub), 0); 398 if (ret != 0) { --- 47 unchanged lines hidden --- |