From 56048baeb4ec3ff82a6acd24a4279db2bebbc9ae Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Thu, 28 May 2015 15:03:58 -0700 Subject: [PATCH] Clarify relationship between stats.resident and stats.mapped. --- doc/jemalloc.xml.in | 10 ++++++---- src/base.c | 2 ++ test/unit/stats.c | 10 +++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in index 123fb3a2..bb15ae4f 100644 --- a/doc/jemalloc.xml.in +++ b/doc/jemalloc.xml.in @@ -1964,10 +1964,12 @@ malloc_conf = "xmalloc:true";]]> [] Total number of bytes in active chunks mapped by the - allocator. This is a multiple of the chunk size, and is at least as - large as stats.resident. This - does not include inactive chunks. + allocator. This is a multiple of the chunk size, and is larger than + stats.active. + This does not include inactive chunks, even those that contain unused + dirty pages, which means that there is no strict ordering between this + and stats.resident. diff --git a/src/base.c b/src/base.c index 1a9b829a..3ab46ec8 100644 --- a/src/base.c +++ b/src/base.c @@ -132,6 +132,8 @@ base_stats_get(size_t *allocated, size_t *resident, size_t *mapped) { malloc_mutex_lock(&base_mtx); + assert(base_allocated <= base_resident); + assert(base_resident <= base_mapped); *allocated = base_allocated; *resident = base_resident; *mapped = base_mapped; diff --git a/test/unit/stats.c b/test/unit/stats.c index 10999670..81ef0b72 100644 --- a/test/unit/stats.c +++ b/test/unit/stats.c @@ -3,7 +3,7 @@ TEST_BEGIN(test_stats_summary) { size_t *cactive; - size_t sz, allocated, active, mapped; + size_t sz, allocated, active, resident, mapped; int expected = config_stats ? 0 : ENOENT; sz = sizeof(cactive); @@ -15,6 +15,8 @@ TEST_BEGIN(test_stats_summary) expected, "Unexpected mallctl() result"); assert_d_eq(mallctl("stats.active", &active, &sz, NULL, 0), expected, "Unexpected mallctl() result"); + assert_d_eq(mallctl("stats.resident", &resident, &sz, NULL, 0), + expected, "Unexpected mallctl() result"); assert_d_eq(mallctl("stats.mapped", &mapped, &sz, NULL, 0), expected, "Unexpected mallctl() result"); @@ -23,8 +25,10 @@ TEST_BEGIN(test_stats_summary) "active should be no larger than cactive"); assert_zu_le(allocated, active, "allocated should be no larger than active"); - assert_zu_le(active, mapped, - "active should be no larger than mapped"); + assert_zu_lt(active, resident, + "active should be less than resident"); + assert_zu_lt(active, mapped, + "active should be less than mapped"); } } TEST_END