xref: /netbsd-src/external/bsd/jemalloc.old/include/jemalloc/internal/prof_externs.h (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1*8e33eff8Schristos #ifndef JEMALLOC_INTERNAL_PROF_EXTERNS_H
2*8e33eff8Schristos #define JEMALLOC_INTERNAL_PROF_EXTERNS_H
3*8e33eff8Schristos 
4*8e33eff8Schristos #include "jemalloc/internal/mutex.h"
5*8e33eff8Schristos 
6*8e33eff8Schristos extern malloc_mutex_t	bt2gctx_mtx;
7*8e33eff8Schristos 
8*8e33eff8Schristos extern bool	opt_prof;
9*8e33eff8Schristos extern bool	opt_prof_active;
10*8e33eff8Schristos extern bool	opt_prof_thread_active_init;
11*8e33eff8Schristos extern size_t	opt_lg_prof_sample;   /* Mean bytes between samples. */
12*8e33eff8Schristos extern ssize_t	opt_lg_prof_interval; /* lg(prof_interval). */
13*8e33eff8Schristos extern bool	opt_prof_gdump;       /* High-water memory dumping. */
14*8e33eff8Schristos extern bool	opt_prof_final;       /* Final profile dumping. */
15*8e33eff8Schristos extern bool	opt_prof_leak;        /* Dump leak summary at exit. */
16*8e33eff8Schristos extern bool	opt_prof_accum;       /* Report cumulative bytes. */
17*8e33eff8Schristos extern char	opt_prof_prefix[
18*8e33eff8Schristos     /* Minimize memory bloat for non-prof builds. */
19*8e33eff8Schristos #ifdef JEMALLOC_PROF
20*8e33eff8Schristos     PATH_MAX +
21*8e33eff8Schristos #endif
22*8e33eff8Schristos     1];
23*8e33eff8Schristos 
24*8e33eff8Schristos /* Accessed via prof_active_[gs]et{_unlocked,}(). */
25*8e33eff8Schristos extern bool	prof_active;
26*8e33eff8Schristos 
27*8e33eff8Schristos /* Accessed via prof_gdump_[gs]et{_unlocked,}(). */
28*8e33eff8Schristos extern bool	prof_gdump_val;
29*8e33eff8Schristos 
30*8e33eff8Schristos /*
31*8e33eff8Schristos  * Profile dump interval, measured in bytes allocated.  Each arena triggers a
32*8e33eff8Schristos  * profile dump when it reaches this threshold.  The effect is that the
33*8e33eff8Schristos  * interval between profile dumps averages prof_interval, though the actual
34*8e33eff8Schristos  * interval between dumps will tend to be sporadic, and the interval will be a
35*8e33eff8Schristos  * maximum of approximately (prof_interval * narenas).
36*8e33eff8Schristos  */
37*8e33eff8Schristos extern uint64_t	prof_interval;
38*8e33eff8Schristos 
39*8e33eff8Schristos /*
40*8e33eff8Schristos  * Initialized as opt_lg_prof_sample, and potentially modified during profiling
41*8e33eff8Schristos  * resets.
42*8e33eff8Schristos  */
43*8e33eff8Schristos extern size_t	lg_prof_sample;
44*8e33eff8Schristos 
45*8e33eff8Schristos void prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated);
46*8e33eff8Schristos void prof_malloc_sample_object(tsdn_t *tsdn, const void *ptr, size_t usize,
47*8e33eff8Schristos     prof_tctx_t *tctx);
48*8e33eff8Schristos void prof_free_sampled_object(tsd_t *tsd, size_t usize, prof_tctx_t *tctx);
49*8e33eff8Schristos void bt_init(prof_bt_t *bt, void **vec);
50*8e33eff8Schristos void prof_backtrace(prof_bt_t *bt);
51*8e33eff8Schristos prof_tctx_t *prof_lookup(tsd_t *tsd, prof_bt_t *bt);
52*8e33eff8Schristos #ifdef JEMALLOC_JET
53*8e33eff8Schristos size_t prof_tdata_count(void);
54*8e33eff8Schristos size_t prof_bt_count(void);
55*8e33eff8Schristos #endif
56*8e33eff8Schristos typedef int (prof_dump_open_t)(bool, const char *);
57*8e33eff8Schristos extern prof_dump_open_t *JET_MUTABLE prof_dump_open;
58*8e33eff8Schristos 
59*8e33eff8Schristos typedef bool (prof_dump_header_t)(tsdn_t *, bool, const prof_cnt_t *);
60*8e33eff8Schristos extern prof_dump_header_t *JET_MUTABLE prof_dump_header;
61*8e33eff8Schristos #ifdef JEMALLOC_JET
62*8e33eff8Schristos void prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
63*8e33eff8Schristos     uint64_t *accumbytes);
64*8e33eff8Schristos #endif
65*8e33eff8Schristos bool prof_accum_init(tsdn_t *tsdn, prof_accum_t *prof_accum);
66*8e33eff8Schristos void prof_idump(tsdn_t *tsdn);
67*8e33eff8Schristos bool prof_mdump(tsd_t *tsd, const char *filename);
68*8e33eff8Schristos void prof_gdump(tsdn_t *tsdn);
69*8e33eff8Schristos prof_tdata_t *prof_tdata_init(tsd_t *tsd);
70*8e33eff8Schristos prof_tdata_t *prof_tdata_reinit(tsd_t *tsd, prof_tdata_t *tdata);
71*8e33eff8Schristos void prof_reset(tsd_t *tsd, size_t lg_sample);
72*8e33eff8Schristos void prof_tdata_cleanup(tsd_t *tsd);
73*8e33eff8Schristos bool prof_active_get(tsdn_t *tsdn);
74*8e33eff8Schristos bool prof_active_set(tsdn_t *tsdn, bool active);
75*8e33eff8Schristos const char *prof_thread_name_get(tsd_t *tsd);
76*8e33eff8Schristos int prof_thread_name_set(tsd_t *tsd, const char *thread_name);
77*8e33eff8Schristos bool prof_thread_active_get(tsd_t *tsd);
78*8e33eff8Schristos bool prof_thread_active_set(tsd_t *tsd, bool active);
79*8e33eff8Schristos bool prof_thread_active_init_get(tsdn_t *tsdn);
80*8e33eff8Schristos bool prof_thread_active_init_set(tsdn_t *tsdn, bool active_init);
81*8e33eff8Schristos bool prof_gdump_get(tsdn_t *tsdn);
82*8e33eff8Schristos bool prof_gdump_set(tsdn_t *tsdn, bool active);
83*8e33eff8Schristos void prof_boot0(void);
84*8e33eff8Schristos void prof_boot1(void);
85*8e33eff8Schristos bool prof_boot2(tsd_t *tsd);
86*8e33eff8Schristos void prof_prefork0(tsdn_t *tsdn);
87*8e33eff8Schristos void prof_prefork1(tsdn_t *tsdn);
88*8e33eff8Schristos void prof_postfork_parent(tsdn_t *tsdn);
89*8e33eff8Schristos void prof_postfork_child(tsdn_t *tsdn);
90*8e33eff8Schristos void prof_sample_threshold_update(prof_tdata_t *tdata);
91*8e33eff8Schristos 
92*8e33eff8Schristos #endif /* JEMALLOC_INTERNAL_PROF_EXTERNS_H */
93