Print merged arena stats iff multiple arenas.

This commit is contained in:
Jason Evans 2010-01-24 17:21:47 -08:00
parent 41631d0061
commit 68ddb6736d

View File

@ -320,6 +320,7 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
huge_nmalloc, huge_ndalloc, huge_allocated); huge_nmalloc, huge_ndalloc, huge_allocated);
if (merged) { if (merged) {
unsigned nmerged;
size_t nactive, ndirty; size_t nactive, ndirty;
arena_stats_t astats; arena_stats_t astats;
malloc_bin_stats_t bstats[nbins]; malloc_bin_stats_t bstats[nbins];
@ -333,21 +334,29 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
memset(lstats, 0, sizeof(lstats)); memset(lstats, 0, sizeof(lstats));
/* Create merged arena stats. */ /* Create merged arena stats. */
for (i = 0; i < narenas; i++) { for (i = nmerged = 0; i < narenas; i++) {
arena = arenas[i]; arena = arenas[i];
if (arena != NULL) { if (arena != NULL) {
malloc_mutex_lock(&arena->lock); malloc_mutex_lock(&arena->lock);
arena_stats_merge(arena, &nactive, arena_stats_merge(arena, &nactive,
&ndirty, &astats, bstats, lstats); &ndirty, &astats, bstats, lstats);
malloc_mutex_unlock(&arena->lock); malloc_mutex_unlock(&arena->lock);
nmerged++;
} }
} }
if (nmerged > 1) {
/* Print merged arena stats. */ /* Print merged arena stats. */
malloc_cprintf(write4, w4opaque, malloc_cprintf(write4, w4opaque,
"\nMerge arenas stats:\n"); "\nMerge arenas stats:\n");
/* arenas[0] is used only for invariant bin settings. */ /*
arena_stats_mprint(arenas[0], nactive, ndirty, &astats, * arenas[0] is used only for invariant bin
bstats, lstats, bins, large, write4, w4opaque); * settings.
*/
arena_stats_mprint(arenas[0], nactive, ndirty,
&astats, bstats, lstats, bins, large,
write4, w4opaque);
}
} }
if (unmerged) { if (unmerged) {