From f2bd39faa0c1b2bd0d9d4c189088c7110bff928e Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 10 Jun 2011 13:00:59 -0700 Subject: [PATCH] common/MemoryModel: de-globalize Signed-off-by: Colin McCabe --- src/common/MemoryModel.cc | 15 ++++++++++----- src/common/MemoryModel.h | 4 ++++ src/mds/MDCache.cc | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/common/MemoryModel.cc b/src/common/MemoryModel.cc index c17a06a07c9ac..ffbf2ccb1e043 100644 --- a/src/common/MemoryModel.cc +++ b/src/common/MemoryModel.cc @@ -6,13 +6,18 @@ #include +MemoryModel::MemoryModel(CephContext *cct_) + : cct(cct_) +{ +} + void MemoryModel::_sample(snap *psnap) { ifstream f; f.open("/proc/self/status"); if (!f.is_open()) { - dout(0) << "check_memory_usage unable to open /proc/self/status" << dendl; + ldout(cct, 0) << "check_memory_usage unable to open /proc/self/status" << dendl; return; } @@ -37,7 +42,7 @@ void MemoryModel::_sample(snap *psnap) f.open("/proc/self/maps"); if (!f.is_open()) { - dout(0) << "check_memory_usage unable to open /proc/self/maps" << dendl; + ldout(cct, 0) << "check_memory_usage unable to open /proc/self/maps" << dendl; return; } @@ -45,7 +50,7 @@ void MemoryModel::_sample(snap *psnap) while (f.is_open() && !f.eof()) { string line; getline(f, line); - //dout(0) << "line is " << line << dendl; + //ldout(cct, 0) << "line is " << line << dendl; const char *start = line.c_str(); const char *dash = start; @@ -59,7 +64,7 @@ void MemoryModel::_sample(snap *psnap) unsigned long long as = strtoll(start, 0, 16); unsigned long long ae = strtoll(dash+1, 0, 16); - //dout(0) << std::hex << as << " to " << ae << std::dec << dendl; + //ldout(cct, 0) << std::hex << as << " to " << ae << std::dec << dendl; end++; const char *mode = end; @@ -73,7 +78,7 @@ void MemoryModel::_sample(snap *psnap) end++; int size = ae - as; - //dout(0) << "size " << size << " mode is '" << mode << "' end is '" << end << "'" << dendl; + //ldout(cct, 0) << "size " << size << " mode is '" << mode << "' end is '" << end << "'" << dendl; /* * anything 'rw' and anon is assumed to be heap. diff --git a/src/common/MemoryModel.h b/src/common/MemoryModel.h index 53c29604c7618..fc1e12939ecd4 100644 --- a/src/common/MemoryModel.h +++ b/src/common/MemoryModel.h @@ -15,6 +15,8 @@ #ifndef CEPH_MEMORYMODEL_H #define CEPH_MEMORYMODEL_H +class CephContext; + class MemoryModel { public: struct snap { @@ -33,9 +35,11 @@ public: } last; private: + CephContext *cct; void _sample(snap *p); public: + MemoryModel(CephContext *cct); void sample(snap *p = 0) { _sample(&last); if (p) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 64b80ff274ba6..7e301bea8ea49 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -5928,7 +5928,7 @@ void MDCache::trim_client_leases() void MDCache::check_memory_usage() { - static MemoryModel mm; + static MemoryModel mm(&g_ceph_context); static MemoryModel::snap last; mm.sample(&last); static MemoryModel::snap baseline = last; -- 2.39.5