2017-01-11 10:06:31 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_PROF_EXTERNS_H
|
|
|
|
#define JEMALLOC_INTERNAL_PROF_EXTERNS_H
|
|
|
|
|
2017-05-24 03:28:19 +08:00
|
|
|
#include "jemalloc/internal/mutex.h"
|
|
|
|
|
2019-12-07 01:45:40 +08:00
|
|
|
extern malloc_mutex_t bt2gctx_mtx;
|
|
|
|
extern malloc_mutex_t tdatas_mtx;
|
|
|
|
extern malloc_mutex_t prof_dump_mtx;
|
2019-07-18 06:52:50 +08:00
|
|
|
|
2019-12-07 01:45:40 +08:00
|
|
|
extern bool opt_prof;
|
|
|
|
extern bool opt_prof_active;
|
|
|
|
extern bool opt_prof_thread_active_init;
|
|
|
|
extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */
|
|
|
|
extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */
|
|
|
|
extern bool opt_prof_gdump; /* High-water memory dumping. */
|
|
|
|
extern bool opt_prof_final; /* Final profile dumping. */
|
|
|
|
extern bool opt_prof_leak; /* Dump leak summary at exit. */
|
|
|
|
extern bool opt_prof_accum; /* Report cumulative bytes. */
|
|
|
|
extern bool opt_prof_log; /* Turn logging on at boot. */
|
|
|
|
extern char opt_prof_prefix[
|
2017-01-11 10:06:31 +08:00
|
|
|
/* Minimize memory bloat for non-prof builds. */
|
|
|
|
#ifdef JEMALLOC_PROF
|
|
|
|
PATH_MAX +
|
|
|
|
#endif
|
|
|
|
1];
|
|
|
|
|
2019-12-19 05:38:14 +08:00
|
|
|
/* For recording recent allocations */
|
|
|
|
extern ssize_t opt_prof_recent_alloc_max;
|
|
|
|
extern malloc_mutex_t prof_recent_alloc_mtx;
|
|
|
|
|
2020-03-25 08:53:41 +08:00
|
|
|
/* Whether to use thread name provided by the system or by mallctl. */
|
2020-06-20 06:16:53 +08:00
|
|
|
extern bool opt_prof_sys_thread_name;
|
2020-03-25 08:53:41 +08:00
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
/* Accessed via prof_active_[gs]et{_unlocked,}(). */
|
2019-12-07 01:45:40 +08:00
|
|
|
extern bool prof_active;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/* Accessed via prof_gdump_[gs]et{_unlocked,}(). */
|
2019-12-07 01:45:40 +08:00
|
|
|
extern bool prof_gdump_val;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2019-10-15 00:35:51 +08:00
|
|
|
/* Profile dump interval, measured in bytes allocated. */
|
2019-12-07 01:45:40 +08:00
|
|
|
extern uint64_t prof_interval;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialized as opt_lg_prof_sample, and potentially modified during profiling
|
|
|
|
* resets.
|
|
|
|
*/
|
2019-12-07 01:45:40 +08:00
|
|
|
extern size_t lg_prof_sample;
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2019-12-07 01:45:40 +08:00
|
|
|
extern bool prof_booted;
|
2019-07-13 07:37:37 +08:00
|
|
|
|
2020-04-29 00:59:37 +08:00
|
|
|
/* Functions only accessed in prof_inlines.h */
|
2019-12-19 07:15:31 +08:00
|
|
|
prof_tdata_t *prof_tdata_init(tsd_t *tsd);
|
|
|
|
prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);
|
|
|
|
|
2020-03-10 06:49:15 +08:00
|
|
|
void prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx);
|
2020-01-10 02:20:34 +08:00
|
|
|
void prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size,
|
|
|
|
size_t usize, prof_tctx_t *tctx);
|
2019-11-20 08:24:57 +08:00
|
|
|
void prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_info_t *prof_info);
|
2019-12-06 07:52:54 +08:00
|
|
|
prof_tctx_t *prof_tctx_create(tsd_t *tsd);
|
2019-07-13 07:37:37 +08:00
|
|
|
int prof_getpid(void);
|
2019-09-10 11:18:41 +08:00
|
|
|
void prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind);
|
2017-05-02 14:10:42 +08:00
|
|
|
void prof_idump(tsdn_t *tsdn);
|
|
|
|
bool prof_mdump(tsd_t *tsd, const char *filename);
|
|
|
|
void prof_gdump(tsdn_t *tsdn);
|
2019-09-10 11:18:41 +08:00
|
|
|
bool prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix);
|
2019-07-13 07:37:37 +08:00
|
|
|
|
2017-05-02 14:10:42 +08:00
|
|
|
void prof_reset(tsd_t *tsd, size_t lg_sample);
|
|
|
|
void prof_tdata_cleanup(tsd_t *tsd);
|
|
|
|
bool prof_active_get(tsdn_t *tsdn);
|
|
|
|
bool prof_active_set(tsdn_t *tsdn, bool active);
|
|
|
|
const char *prof_thread_name_get(tsd_t *tsd);
|
|
|
|
int prof_thread_name_set(tsd_t *tsd, const char *thread_name);
|
|
|
|
bool prof_thread_active_get(tsd_t *tsd);
|
|
|
|
bool prof_thread_active_set(tsd_t *tsd, bool active);
|
|
|
|
bool prof_thread_active_init_get(tsdn_t *tsdn);
|
|
|
|
bool prof_thread_active_init_set(tsdn_t *tsdn, bool active_init);
|
|
|
|
bool prof_gdump_get(tsdn_t *tsdn);
|
|
|
|
bool prof_gdump_set(tsdn_t *tsdn, bool active);
|
|
|
|
void prof_boot0(void);
|
|
|
|
void prof_boot1(void);
|
2020-02-18 06:09:29 +08:00
|
|
|
bool prof_boot2(tsd_t *tsd, base_t *base);
|
2017-05-02 14:10:42 +08:00
|
|
|
void prof_prefork0(tsdn_t *tsdn);
|
|
|
|
void prof_prefork1(tsdn_t *tsdn);
|
|
|
|
void prof_postfork_parent(tsdn_t *tsdn);
|
|
|
|
void prof_postfork_child(tsdn_t *tsdn);
|
2020-04-17 04:33:56 +08:00
|
|
|
|
2020-04-16 01:49:08 +08:00
|
|
|
/* Only accessed by thread event. */
|
|
|
|
uint64_t prof_sample_new_event_wait(tsd_t *tsd);
|
2020-04-17 04:33:56 +08:00
|
|
|
uint64_t prof_sample_postponed_event_wait(tsd_t *tsd);
|
2020-04-18 01:38:06 +08:00
|
|
|
void prof_sample_event_handler(tsd_t *tsd, uint64_t elapsed);
|
2017-01-11 10:06:31 +08:00
|
|
|
|
2020-06-18 00:57:54 +08:00
|
|
|
/* Used by unit tests. */
|
2020-06-20 06:16:53 +08:00
|
|
|
typedef int (prof_sys_thread_name_read_t)(char *buf, size_t limit);
|
|
|
|
extern prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read;
|
2020-06-18 00:57:54 +08:00
|
|
|
size_t prof_tdata_count(void);
|
|
|
|
size_t prof_bt_count(void);
|
2020-03-18 02:05:07 +08:00
|
|
|
typedef int (prof_dump_open_file_t)(const char *, int);
|
|
|
|
extern prof_dump_open_file_t *JET_MUTABLE prof_dump_open_file;
|
2020-03-18 11:27:52 +08:00
|
|
|
typedef ssize_t (prof_dump_write_file_t)(int, const void *, size_t);
|
|
|
|
extern prof_dump_write_file_t *JET_MUTABLE prof_dump_write_file;
|
2020-04-01 01:00:37 +08:00
|
|
|
typedef void (prof_dump_header_t)(tsdn_t *, const prof_cnt_t *);
|
2020-06-18 00:57:54 +08:00
|
|
|
extern prof_dump_header_t *JET_MUTABLE prof_dump_header;
|
2020-03-18 10:57:06 +08:00
|
|
|
typedef int (prof_dump_open_maps_t)();
|
|
|
|
extern prof_dump_open_maps_t *JET_MUTABLE prof_dump_open_maps;
|
2020-06-18 00:57:54 +08:00
|
|
|
void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
|
|
|
|
uint64_t *accumbytes);
|
|
|
|
|
2018-07-04 02:10:09 +08:00
|
|
|
bool prof_log_start(tsdn_t *tsdn, const char *filename);
|
|
|
|
bool prof_log_stop(tsdn_t *tsdn);
|
2019-07-18 06:52:50 +08:00
|
|
|
|
2019-12-19 05:38:14 +08:00
|
|
|
ssize_t prof_recent_alloc_max_ctl_read();
|
|
|
|
ssize_t prof_recent_alloc_max_ctl_write(tsd_t *tsd, ssize_t max);
|
2020-04-18 05:49:20 +08:00
|
|
|
void prof_recent_alloc_dump(tsd_t *tsd, write_cb_t *write_cb, void *cbopaque);
|
2019-12-19 05:38:14 +08:00
|
|
|
|
2017-01-11 10:06:31 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */
|