summaryrefslogtreecommitdiffstats
path: root/src/common/MemoryModel.cc
diff options
context:
space:
mode:
authorXiaoxi Chen <xiaoxchen@ebay.com>2017-02-16 08:16:00 +0100
committerXiaoxi Chen <xiaoxchen@ebay.com>2017-02-22 16:36:20 +0100
commit22ca3aa7172d05df99f41c3ac245e6a2f0e49b3d (patch)
tree1d9dfda61fb9baf0d82ae7f234721a91e3082ce2 /src/common/MemoryModel.cc
parentMerge pull request #13235 from liewegas/wip-pg-split-interval (diff)
downloadceph-22ca3aa7172d05df99f41c3ac245e6a2f0e49b3d.tar.xz
ceph-22ca3aa7172d05df99f41c3ac245e6a2f0e49b3d.zip
common/MemoryModel: Bump int to long and drop mallinfo
mallinfo(3) doesnt have 64bit compatible version so when malloc size > 4GB, either wrapped value or a negtive value returned, which is really misleading. Also bump up all int to long to prevent overflow oneday we have > 2TB memory. Signed-off-by: Xiaoxi Chen <xiaoxchen@ebay.com>
Diffstat (limited to 'src/common/MemoryModel.cc')
-rw-r--r--src/common/MemoryModel.cc26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/common/MemoryModel.cc b/src/common/MemoryModel.cc
index 92442b21944..99bb1ca35c6 100644
--- a/src/common/MemoryModel.cc
+++ b/src/common/MemoryModel.cc
@@ -26,23 +26,22 @@ void MemoryModel::_sample(snap *psnap)
ldout(cct, 0) << "check_memory_usage unable to open /proc/self/status" << dendl;
return;
}
-
while (!f.eof()) {
string line;
getline(f, line);
if (strncmp(line.c_str(), "VmSize:", 7) == 0)
- psnap->size = atoi(line.c_str() + 7);
+ psnap->size = atol(line.c_str() + 7);
else if (strncmp(line.c_str(), "VmRSS:", 6) == 0)
- psnap->rss = atoi(line.c_str() + 7);
+ psnap->rss = atol(line.c_str() + 7);
else if (strncmp(line.c_str(), "VmHWM:", 6) == 0)
- psnap->hwm = atoi(line.c_str() + 7);
+ psnap->hwm = atol(line.c_str() + 7);
else if (strncmp(line.c_str(), "VmLib:", 6) == 0)
- psnap->lib = atoi(line.c_str() + 7);
+ psnap->lib = atol(line.c_str() + 7);
else if (strncmp(line.c_str(), "VmPeak:", 7) == 0)
- psnap->peak = atoi(line.c_str() + 7);
+ psnap->peak = atol(line.c_str() + 7);
else if (strncmp(line.c_str(), "VmData:", 7) == 0)
- psnap->data = atoi(line.c_str() + 7);
+ psnap->data = atol(line.c_str() + 7);
}
f.close();
@@ -52,7 +51,7 @@ void MemoryModel::_sample(snap *psnap)
return;
}
- int heap = 0;
+ long heap = 0;
while (f.is_open() && !f.eof()) {
string line;
getline(f, line);
@@ -83,7 +82,7 @@ void MemoryModel::_sample(snap *psnap)
if (*end)
end++;
- int size = ae - as;
+ long size = ae - as;
//ldout(cct, 0) << "size " << size << " mode is '" << mode << "' end is '" << end << "'" << dendl;
/*
@@ -95,13 +94,4 @@ void MemoryModel::_sample(snap *psnap)
psnap->heap = heap >> 10;
- // ...
-#if defined(HAVE_MALLINFO)
- struct mallinfo mi = mallinfo();
-
- psnap->malloc = mi.uordblks >> 10;
- psnap->mmap = mi.hblks >> 10;
-#else
-#warning "mallinfo not implemented"
-#endif
}