From c96cb9fc28e4358c5d7246ce77b676113a63ce85 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sun, 6 Aug 2017 17:21:51 +0200 Subject: statedump: add support for dumping basic mem-pool info With all the new 'struct mem_pool' infrastructure in place, it is now possible to fetch details about the memory pools that a glusterfs_ctx_t uses. This only captures the information from 'struct mem_pool', and not from the global 'struct mem_pool_shared' or the pool_sweeper thread. The current details help with detecting memory leaks. Updates: #307 Change-Id: Idbc5ba136df50863e1e380b448061509896f2c23 Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/18076 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi --- libglusterfs/src/statedump.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c index 697ddc3b7ba..a2000b158e6 100644 --- a/libglusterfs/src/statedump.c +++ b/libglusterfs/src/statedump.c @@ -376,11 +376,11 @@ gf_proc_dump_mem_info_to_dict (dict_t *dict) void gf_proc_dump_mempool_info (glusterfs_ctx_t *ctx) { -#if defined(OLD_MEM_POOLS) struct mem_pool *pool = NULL; gf_proc_dump_add_section ("mempool"); +#if defined(OLD_MEM_POOLS) list_for_each_entry (pool, &ctx->mempool_list, global_list) { gf_proc_dump_write ("-----", "-----"); gf_proc_dump_write ("pool-name", "%s", pool->name); @@ -395,6 +395,24 @@ gf_proc_dump_mempool_info (glusterfs_ctx_t *ctx) gf_proc_dump_write ("cur-stdalloc", "%d", pool->curr_stdalloc); gf_proc_dump_write ("max-stdalloc", "%d", pool->max_stdalloc); } +#else + LOCK (&ctx->lock); + { + list_for_each_entry (pool, &ctx->mempool_list, owner) { + int64_t active = GF_ATOMIC_GET (pool->active); + + gf_proc_dump_write ("-----", "-----"); + gf_proc_dump_write ("pool-name", "%s", pool->name); + gf_proc_dump_write ("active-count", "%"GF_PRI_ATOMIC, active); + gf_proc_dump_write ("sizeof-type", "%d", pool->sizeof_type); + gf_proc_dump_write ("padded-sizeof", "%lu", 1 << pool->pool->power_of_two); + gf_proc_dump_write ("size", "%lu", (1 << pool->pool->power_of_two) * active); + gf_proc_dump_write ("shared-pool", "%p", pool->pool); + } + } + UNLOCK (&ctx->lock); + + /* TODO: details of (struct mem_pool_shared) pool->pool */ #endif } -- cgit