changeset:   258513:ffbd5f5f46f1
user:        Guilherme Goncalves <guilherme.p.gonc@gmail.com>
date:        Thu Aug 20 10:05:29 2015 +0900
summary:     Bug 1125514 - Use jemalloc's metadata statistics to compute bookkeeping. r=glandium

--- mozilla/memory/build/mozjemalloc_compat.c~
+++ mozilla/memory/build/mozjemalloc_compat.c
@@ -66,6 +66,7 @@ jemalloc_stats_impl(jemalloc_stats_t *st
 {
   unsigned narenas;
   size_t active, allocated, mapped, page, pdirty;
+  size_t meta, ameta;
   size_t lg_chunk;
 
   // Refresh jemalloc's stats by updating its epoch, see ctl_refresh in
@@ -79,20 +80,19 @@ jemalloc_stats_impl(jemalloc_stats_t *st
   CTL_GET("stats.active", active);
   CTL_GET("stats.allocated", allocated);
   CTL_GET("stats.mapped", mapped);
+  CTL_GET("stats.metadata", meta);
   CTL_GET("opt.lg_chunk", lg_chunk);
 
   /* get the summation for all arenas, i == narenas */
   CTL_I_GET("stats.arenas.0.pdirty", pdirty, narenas);
+  CTL_I_GET("stats.arenas.0.metadata.allocated", ameta, narenas);
 
   stats->chunksize = 1 << lg_chunk;
   stats->mapped = mapped;
   stats->allocated = allocated;
   stats->waste = active - allocated;
   stats->page_cache = pdirty * page;
-
-  // We could get this value out of base.c::base_pages, but that really should
-  // be an upstream change, so don't worry about it for now.
-  stats->bookkeeping = 0;
+  stats->bookkeeping = meta - ameta;
   stats->bin_unused = 0;
 }
 
