summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libglusterfs/src/mem-pool.c5
-rw-r--r--libglusterfs/src/mem-pool.h3
-rw-r--r--libglusterfs/src/statedump.c4
3 files changed, 11 insertions, 1 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 66b45c0d669..328c8071e29 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -698,6 +698,7 @@ mem_pool_new_fn (glusterfs_ctx_t *ctx, unsigned long sizeof_type,
new->count = count;
new->name = name;
new->pool = pool;
+ GF_ATOMIC_INIT (new->active, 0);
INIT_LIST_HEAD (&new->owner);
LOCK (&ctx->lock);
@@ -834,6 +835,8 @@ mem_get (struct mem_pool *mem_pool)
retval->pool_list = pool_list;
retval->power_of_two = mem_pool->pool->power_of_two;
+ GF_ATOMIC_INC (mem_pool->active);
+
return retval + 1;
#endif /* GF_DISABLE_MEMPOOL */
}
@@ -863,6 +866,8 @@ mem_put (void *ptr)
pool_list = hdr->pool_list;
pt_pool = &pool_list->pools[hdr->power_of_two-POOL_SMALLEST];
+ GF_ATOMIC_DEC (hdr->pool->active);
+
(void) pthread_spin_lock (&pool_list->lock);
hdr->magic = GF_MEM_INVALID_MAGIC;
hdr->next = pt_pool->hot_list;
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index ecf2abe9245..ff5d183b16d 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -209,8 +209,9 @@ out:
struct mem_pool {
/* object size, without pooled_obj_hdr_t */
unsigned long sizeof_type;
- unsigned long count;
+ unsigned long count; /* requested pool size (unused) */
char *name;
+ gf_atomic_t active; /* current allocations */
struct list_head owner; /* glusterfs_ctx_t->mempool_list */
glusterfs_ctx_t *ctx; /* take ctx->lock when updating owner */
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 67c46998d63..a2000b158e6 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -399,10 +399,14 @@ gf_proc_dump_mempool_info (glusterfs_ctx_t *ctx)
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);
}
}