From 3f374960e665d4f11bc668dd7d6436d00b3f0548 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sat, 11 Feb 2006 18:44:37 +0000 Subject: Read all_cpus variable out of kmem, and validate CPUs against the all_cpus cpu mask before looking at the cache entries for the CPU. For systems with sparse CPU id arrays, this skips otherwise uninitialized cache structures. MFC after: 3 days --- lib/libmemstat/memstat_uma.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/libmemstat') diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c index 911c0996f3d3..924b7c252b0f 100644 --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -52,6 +52,8 @@ static struct nlist namelist[] = { { .n_name = "_uma_kegs" }, #define X_MP_MAXID 1 { .n_name = "_mp_maxid" }, +#define X_ALL_CPUS 2 + { .n_name = "_all_cpus" }, { .n_name = "" }, }; @@ -309,6 +311,7 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) struct uma_keg *kzp, kz; int hint_dontsearch, i, mp_maxid, ret; char name[MEMTYPE_MAXNAME]; + __cpumask_t all_cpus; kvm_t *kvm; kvm = (kvm_t *)kvm_handle; @@ -332,6 +335,11 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) list->mtl_error = ret; return (-1); } + ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0); + if (ret != 0) { + list->mtl_error = ret; + return (-1); + } for (kzp = LIST_FIRST(&uma_kegs); kzp != NULL; kzp = LIST_NEXT(&kz, uk_link)) { ret = kread(kvm, kzp, &kz, sizeof(kz), 0); @@ -378,6 +386,8 @@ memstat_kvm_uma(struct memory_type_list *list, void *kvm_handle) if (kz.uk_flags & UMA_ZFLAG_INTERNAL) goto skip_percpu; for (i = 0; i < mp_maxid + 1; i++) { + if ((all_cpus & (1 << i)) == 0) + continue; ucp = &uz.uz_cpu[i]; mtp->mt_numallocs += ucp->uc_allocs; mtp->mt_numfrees += ucp->uc_frees; -- cgit v1.3