From b549389e4a491f48ea466dce4fda475bcd6b7936 Mon Sep 17 00:00:00 2001 From: Yinan Zhang Date: Tue, 11 Aug 2020 15:35:41 -0700 Subject: [PATCH] Correct usize in prof last-N record --- include/jemalloc/internal/prof_recent.h | 2 +- include/jemalloc/internal/prof_structs.h | 1 + src/prof.c | 2 +- src/prof_recent.c | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/jemalloc/internal/prof_recent.h b/include/jemalloc/internal/prof_recent.h index d793c6da..df410236 100644 --- a/include/jemalloc/internal/prof_recent.h +++ b/include/jemalloc/internal/prof_recent.h @@ -5,7 +5,7 @@ extern malloc_mutex_t prof_recent_alloc_mtx; extern malloc_mutex_t prof_recent_dump_mtx; bool prof_recent_alloc_prepare(tsd_t *tsd, prof_tctx_t *tctx); -void prof_recent_alloc(tsd_t *tsd, edata_t *edata, size_t size); +void prof_recent_alloc(tsd_t *tsd, edata_t *edata, size_t size, size_t usize); void prof_recent_alloc_reset(tsd_t *tsd, edata_t *edata); bool prof_recent_init(); void edata_prof_recent_alloc_init(edata_t *edata); diff --git a/include/jemalloc/internal/prof_structs.h b/include/jemalloc/internal/prof_structs.h index fbad6145..73ac3d5c 100644 --- a/include/jemalloc/internal/prof_structs.h +++ b/include/jemalloc/internal/prof_structs.h @@ -209,6 +209,7 @@ struct prof_recent_s { ql_elm(prof_recent_t) link; size_t size; + size_t usize; atomic_p_t alloc_edata; /* NULL means allocation has been freed. */ prof_tctx_t *alloc_tctx; prof_tctx_t *dalloc_tctx; diff --git a/src/prof.c b/src/prof.c index 4f451998..9b651db8 100644 --- a/src/prof.c +++ b/src/prof.c @@ -129,7 +129,7 @@ prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size, malloc_mutex_unlock(tsd_tsdn(tsd), tctx->tdata->lock); if (record_recent) { assert(tctx == edata_prof_tctx_get(edata)); - prof_recent_alloc(tsd, edata, size); + prof_recent_alloc(tsd, edata, size, usize); } } diff --git a/src/prof_recent.c b/src/prof_recent.c index 426f62ec..cfaa5a68 100644 --- a/src/prof_recent.c +++ b/src/prof_recent.c @@ -270,7 +270,7 @@ prof_recent_alloc_assert_count(tsd_t *tsd) { } void -prof_recent_alloc(tsd_t *tsd, edata_t *edata, size_t size) { +prof_recent_alloc(tsd_t *tsd, edata_t *edata, size_t size, size_t usize) { assert(edata != NULL); prof_tctx_t *tctx = edata_prof_tctx_get(edata); @@ -356,6 +356,7 @@ prof_recent_alloc(tsd_t *tsd, edata_t *edata, size_t size) { prof_recent_t *tail = ql_last(&prof_recent_alloc_list, link); assert(tail != NULL); tail->size = size; + tail->usize = usize; nstime_copy(&tail->alloc_time, edata_prof_alloc_time_get(edata)); tail->alloc_tctx = tctx; nstime_init_zero(&tail->dalloc_time); @@ -477,8 +478,7 @@ prof_recent_alloc_dump_node(emitter_t *emitter, prof_recent_t *node) { emitter_json_object_begin(emitter); emitter_json_kv(emitter, "size", emitter_type_size, &node->size); - size_t usize = sz_s2u(node->size); - emitter_json_kv(emitter, "usize", emitter_type_size, &usize); + emitter_json_kv(emitter, "usize", emitter_type_size, &node->usize); bool released = prof_recent_alloc_edata_get_no_lock(node) == NULL; emitter_json_kv(emitter, "released", emitter_type_bool, &released);