summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2014-03-29 06:48:52 -0700
committerAnand Avati <avati@redhat.com>2014-05-05 17:27:51 -0700
commit71ad38b3f86bdb0c4e9120b58ff451a6711ead9d (patch)
tree1db90401f545efdefdbf0ca89c92f7337cd1a4cc /libglusterfs/src
parent9021be1fc1a9460438ce74dc5df091834a0bdae0 (diff)
mem-accounting: store type string and print in meta
Change-Id: Ied1de473c72967110b54f033768f7ac60bf66edc BUG: 1089216 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.org/7541 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/mem-pool.c16
-rw-r--r--libglusterfs/src/mem-pool.h9
-rw-r--r--libglusterfs/src/statedump.c1
3 files changed, 15 insertions, 11 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index c5ff58f4f1b..b233995b0b1 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -39,8 +39,8 @@ gf_mem_acct_enable_set (void *data)
}
int
-gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
- size_t size, uint32_t type)
+gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr, size_t size,
+ uint32_t type, const char *typestr)
{
char *ptr = NULL;
@@ -58,6 +58,8 @@ gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
LOCK(&xl->mem_acct.rec[type].lock);
{
+ if (!xl->mem_acct.rec[type].typestr)
+ xl->mem_acct.rec[type].typestr = typestr;
xl->mem_acct.rec[type].size += size;
xl->mem_acct.rec[type].num_allocs++;
xl->mem_acct.rec[type].total_allocs++;
@@ -87,7 +89,7 @@ gf_mem_set_acct_info (xlator_t *xl, char **alloc_ptr,
void *
-__gf_calloc (size_t nmemb, size_t size, uint32_t type)
+__gf_calloc (size_t nmemb, size_t size, uint32_t type, const char *typestr)
{
size_t tot_size = 0;
size_t req_size = 0;
@@ -108,13 +110,13 @@ __gf_calloc (size_t nmemb, size_t size, uint32_t type)
gf_msg_nomem ("", GF_LOG_ALERT, tot_size);
return NULL;
}
- gf_mem_set_acct_info (xl, &ptr, req_size, type);
+ gf_mem_set_acct_info (xl, &ptr, req_size, type, typestr);
return (void *)ptr;
}
void *
-__gf_malloc (size_t size, uint32_t type)
+__gf_malloc (size_t size, uint32_t type, const char *typestr)
{
size_t tot_size = 0;
char *ptr = NULL;
@@ -132,7 +134,7 @@ __gf_malloc (size_t size, uint32_t type)
gf_msg_nomem ("", GF_LOG_ALERT, tot_size);
return NULL;
}
- gf_mem_set_acct_info (xl, &ptr, size, type);
+ gf_mem_set_acct_info (xl, &ptr, size, type, typestr);
return (void *)ptr;
}
@@ -174,7 +176,7 @@ __gf_realloc (void *ptr, size_t size)
* about the casting to and forth from void ** to
* char **.
*/
- gf_mem_set_acct_info (xl, &new_ptr, size, type);
+ gf_mem_set_acct_info (xl, &new_ptr, size, type, NULL);
return (void *)new_ptr;
}
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index 9ffeef4da30..a6adb6cc8c2 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -40,6 +40,7 @@ struct mem_acct {
};
struct mem_acct_rec {
+ const char *typestr;
size_t size;
size_t max_size;
uint32_t num_allocs;
@@ -50,10 +51,10 @@ struct mem_acct_rec {
void *
-__gf_calloc (size_t cnt, size_t size, uint32_t type);
+__gf_calloc (size_t cnt, size_t size, uint32_t type, const char *typestr);
void *
-__gf_malloc (size_t size, uint32_t type);
+__gf_malloc (size_t size, uint32_t type, const char *typestr);
void *
__gf_realloc (void *ptr, size_t size);
@@ -114,9 +115,9 @@ void* __gf_default_realloc (void *oldptr, size_t size)
ptr = (void *)0xeeeeeeee; \
}
-#define GF_CALLOC(nmemb, size, type) __gf_calloc (nmemb, size, type)
+#define GF_CALLOC(nmemb, size, type) __gf_calloc (nmemb, size, type, #type)
-#define GF_MALLOC(size, type) __gf_malloc (size, type)
+#define GF_MALLOC(size, type) __gf_malloc (size, type, #type)
#define GF_REALLOC(ptr, size) __gf_realloc (ptr, size)
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 5b41e86791a..f9e8a0c1ba4 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -238,6 +238,7 @@ gf_proc_dump_xlator_mem_info (xlator_t *xl)
gf_proc_dump_add_section ("%s.%s - usage-type %d memusage",
xl->type, xl->name, i);
+ gf_proc_dump_write ("type", "%s", xl->mem_acct.rec[i].typestr);
gf_proc_dump_write ("size", "%u", xl->mem_acct.rec[i].size);
gf_proc_dump_write ("num_allocs", "%u",
xl->mem_acct.rec[i].num_allocs);