summaryrefslogtreecommitdiffstats
path: root/sys/vm/uma_core.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-10-20 16:39:33 +0000
committerrwatson <rwatson@FreeBSD.org>2005-10-20 16:39:33 +0000
commitf568b9c967356d076be0c5f390558595db5be11e (patch)
treeeb69a5ef4acc886e7d784da8a8938a6a4a64fad0 /sys/vm/uma_core.c
parent9630baabc406b07c0c96712aa759eb91d98c420d (diff)
downloadFreeBSD-src-f568b9c967356d076be0c5f390558595db5be11e.zip
FreeBSD-src-f568b9c967356d076be0c5f390558595db5be11e.tar.gz
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
Diffstat (limited to 'sys/vm/uma_core.c')
-rw-r--r--sys/vm/uma_core.c36
1 files changed, 36 insertions, 0 deletions
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 <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -86,6 +88,8 @@ __FBSDID("$FreeBSD$");
#include <machine/vmparam.h>
+#include <ddb/ddb.h>
+
/*
* 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
OpenPOWER on IntegriCloud