summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-10-29 14:16:20 +0530
committerAmar Tumballi <amarts@redhat.com>2018-11-01 02:38:39 +0000
commit7fac81aeab5805fb2bd719d7489636633bb5e32a (patch)
tree793a81e96849918fec893a5c78ba83ff8e703d79
parent7150c51ad75ccba22045a35fc31e5037612d1ad4 (diff)
mem-pool: change the values to 64bits
total_allocs of certain type of variables can be 4billion in a single day depending on load. So, 32 bits for that is not enough. Also, size_t is good variable size for one allocation, but the sum of allocations, should be 64bits to make sure we don't overflow the variable. Updates: bz#1639599 Change-Id: If3b19687f94425e913a0201ae5d73661eda51f06 Signed-off-by: Amar Tumballi <amarts@redhat.com>
-rw-r--r--libglusterfs/src/mem-pool.c1
-rw-r--r--libglusterfs/src/mem-pool.h6
-rw-r--r--libglusterfs/src/monitoring.c5
-rw-r--r--libglusterfs/src/statedump.c7
4 files changed, 9 insertions, 10 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index ad433d4af2d..caf8bf2fa0c 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -342,6 +342,7 @@ __gf_free(void *free_ptr)
LOCK(&mem_acct->rec[header->type].lock);
{
+ GF_ASSERT(mem_acct->rec[header->type].size >= header->size);
mem_acct->rec[header->type].size -= header->size;
mem_acct->rec[header->type].num_allocs--;
/* If all the instances are freed up then ensure typestr is set
diff --git a/libglusterfs/src/mem-pool.h b/libglusterfs/src/mem-pool.h
index b163458c488..af6b4decd2c 100644
--- a/libglusterfs/src/mem-pool.h
+++ b/libglusterfs/src/mem-pool.h
@@ -40,10 +40,10 @@
struct mem_acct_rec {
const char *typestr;
- size_t size;
- size_t max_size;
+ uint64_t size;
+ uint64_t max_size;
+ uint64_t total_allocs;
uint32_t num_allocs;
- uint32_t total_allocs;
uint32_t max_num_allocs;
gf_lock_t lock;
#ifdef DEBUG
diff --git a/libglusterfs/src/monitoring.c b/libglusterfs/src/monitoring.c
index b0d0766599a..5f11827b187 100644
--- a/libglusterfs/src/monitoring.c
+++ b/libglusterfs/src/monitoring.c
@@ -34,10 +34,7 @@ dump_mem_acct_details(xlator_t *xl, int fd)
mem_rec = &xl->mem_acct->rec[i];
if (mem_rec->num_allocs == 0)
continue;
- dprintf(fd,
- "# %s, %" GF_PRI_SIZET ", %u, %" GF_PRI_SIZET
- ", %u,"
- " %u\n",
+ dprintf(fd, "# %s, %" PRIu64 ", %u, %" PRIu64 ", %u, %" PRIu64 "\n",
mem_rec->typestr, mem_rec->size, mem_rec->num_allocs,
mem_rec->max_size, mem_rec->max_num_allocs,
mem_rec->total_allocs);
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index be928a375d8..d0701e53a84 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -221,12 +221,13 @@ gf_proc_dump_xlator_mem_info(xlator_t *xl)
gf_proc_dump_add_section("%s.%s - usage-type %s memusage", xl->type,
xl->name, xl->mem_acct->rec[i].typestr);
- gf_proc_dump_write("size", "%u", xl->mem_acct->rec[i].size);
+ gf_proc_dump_write("size", "%" PRIu64, xl->mem_acct->rec[i].size);
gf_proc_dump_write("num_allocs", "%u", xl->mem_acct->rec[i].num_allocs);
- gf_proc_dump_write("max_size", "%u", xl->mem_acct->rec[i].max_size);
+ gf_proc_dump_write("max_size", "%" PRIu64,
+ xl->mem_acct->rec[i].max_size);
gf_proc_dump_write("max_num_allocs", "%u",
xl->mem_acct->rec[i].max_num_allocs);
- gf_proc_dump_write("total_allocs", "%u",
+ gf_proc_dump_write("total_allocs", "%" PRIu64,
xl->mem_acct->rec[i].total_allocs);
}