Fix allocated_large stats with respect to sampled small allocations.

This commit is contained in:
Jason Evans 2017-01-06 18:56:02 -08:00
parent 5c5ff8d121
commit 363629df88

View File

@ -211,11 +211,15 @@ arena_nactive_sub(arena_t *arena, size_t sub_pages)
static void static void
arena_large_malloc_stats_update(arena_t *arena, size_t usize) arena_large_malloc_stats_update(arena_t *arena, size_t usize)
{ {
szind_t index = size2index(usize); szind_t index, hindex;
szind_t hindex = (index >= NBINS) ? index - NBINS : 0;
cassert(config_stats); cassert(config_stats);
if (usize < LARGE_MINCLASS)
usize = LARGE_MINCLASS;
index = size2index(usize);
hindex = (index >= NBINS) ? index - NBINS : 0;
arena->stats.nmalloc_large++; arena->stats.nmalloc_large++;
arena->stats.allocated_large += usize; arena->stats.allocated_large += usize;
arena->stats.lstats[hindex].nmalloc++; arena->stats.lstats[hindex].nmalloc++;
@ -226,11 +230,15 @@ arena_large_malloc_stats_update(arena_t *arena, size_t usize)
static void static void
arena_large_malloc_stats_update_undo(arena_t *arena, size_t usize) arena_large_malloc_stats_update_undo(arena_t *arena, size_t usize)
{ {
szind_t index = size2index(usize); szind_t index, hindex;
szind_t hindex = (index >= NBINS) ? index - NBINS : 0;
cassert(config_stats); cassert(config_stats);
if (usize < LARGE_MINCLASS)
usize = LARGE_MINCLASS;
index = size2index(usize);
hindex = (index >= NBINS) ? index - NBINS : 0;
arena->stats.nmalloc_large--; arena->stats.nmalloc_large--;
arena->stats.allocated_large -= usize; arena->stats.allocated_large -= usize;
arena->stats.lstats[hindex].nmalloc--; arena->stats.lstats[hindex].nmalloc--;
@ -241,11 +249,15 @@ arena_large_malloc_stats_update_undo(arena_t *arena, size_t usize)
static void static void
arena_large_dalloc_stats_update(arena_t *arena, size_t usize) arena_large_dalloc_stats_update(arena_t *arena, size_t usize)
{ {
szind_t index = size2index(usize); szind_t index, hindex;
szind_t hindex = (index >= NBINS) ? index - NBINS : 0;
cassert(config_stats); cassert(config_stats);
if (usize < LARGE_MINCLASS)
usize = LARGE_MINCLASS;
index = size2index(usize);
hindex = (index >= NBINS) ? index - NBINS : 0;
arena->stats.ndalloc_large++; arena->stats.ndalloc_large++;
arena->stats.allocated_large -= usize; arena->stats.allocated_large -= usize;
arena->stats.lstats[hindex].ndalloc++; arena->stats.lstats[hindex].ndalloc++;