Correct usize in prof last-N record

This commit is contained in:
Yinan Zhang 2020-08-11 15:35:41 -07:00
parent 202f01d4f8
commit b549389e4a
4 changed files with 6 additions and 5 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);