From f568b9c967356d076be0c5f390558595db5be11e Mon Sep 17 00:00:00 2001 From: rwatson Date: Thu, 20 Oct 2005 16:39:33 +0000 Subject: Add a "show uma" command to DDB, which prints out the current stats for available UMA zones. Quite useful for post-mortem debugging of memory leaks without a dump device configured on a panicked box. MFC after: 2 weeks --- sys/vm/uma_core.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index a15c453..714e5a3 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -57,7 +57,9 @@ __FBSDID("$FreeBSD$"); #define UMA_DEBUG_ALLOC_1 1 */ +#include "opt_ddb.h" #include "opt_param.h" + #include #include #include @@ -86,6 +88,8 @@ __FBSDID("$FreeBSD$"); #include +#include + /* * This is the zone and keg from which all zones are spawned. The idea is that * even the zone & keg heads are allocated from the allocator, so we use the @@ -3039,3 +3043,35 @@ out: free(buffer, M_TEMP); return (error); } + +#ifdef DDB +DB_SHOW_COMMAND(uma, db_show_uma) +{ + u_int64_t allocs, frees; + uma_bucket_t bucket; + uma_keg_t kz; + uma_zone_t z; + int cachefree; + + db_printf("%18s %12s %12s %12s %8s\n", "Zone", "Allocs", "Frees", + "Used", "Cache"); + LIST_FOREACH(kz, &uma_kegs, uk_link) { + LIST_FOREACH(z, &kz->uk_zones, uz_link) { + if (kz->uk_flags & UMA_ZFLAG_INTERNAL) { + allocs = z->uz_allocs; + frees = z->uz_frees; + cachefree = 0; + } else + uma_zone_sumstat(z, &cachefree, &allocs, + &frees); + if (!((kz->uk_flags & UMA_ZONE_SECONDARY) && + (LIST_FIRST(&kz->uk_zones) != z))) + cachefree += kz->uk_free; + LIST_FOREACH(bucket, &z->uz_full_bucket, ub_link) + cachefree += bucket->ub_cnt; + db_printf("%18s %12llu %12llu %12llu %8d\n", z->uz_name, + allocs, frees, allocs - frees, cachefree); + } + } +} +#endif -- cgit v1.1