1 #ifndef JEMALLOC_INTERNAL_CTL_H
2 #define JEMALLOC_INTERNAL_CTL_H
4 #include "jemalloc/internal/jemalloc_internal_types.h"
5 #include "jemalloc/internal/malloc_io.h"
6 #include "jemalloc/internal/mutex_prof.h"
7 #include "jemalloc/internal/ql.h"
8 #include "jemalloc/internal/size_classes.h"
9 #include "jemalloc/internal/stats.h"
11 /* Maximum ctl tree depth. */
12 #define CTL_MAX_DEPTH 7
14 typedef struct ctl_node_s {
18 typedef struct ctl_named_node_s {
21 /* If (nchildren == 0), this is a terminal node. */
23 const ctl_node_t *children;
24 int (*ctl)(tsd_t *, const size_t *, size_t, void *, size_t *, void *,
28 typedef struct ctl_indexed_node_s {
29 struct ctl_node_s node;
30 const ctl_named_node_t *(*index)(tsdn_t *, const size_t *, size_t,
34 typedef struct ctl_arena_stats_s {
37 /* Aggregate stats for small size classes, based on bin stats. */
38 size_t allocated_small;
39 uint64_t nmalloc_small;
40 uint64_t ndalloc_small;
41 uint64_t nrequests_small;
43 bin_stats_t bstats[NBINS];
44 arena_stats_large_t lstats[NSIZES - NBINS];
47 typedef struct ctl_stats_s {
56 background_thread_stats_t background_thread;
57 mutex_prof_data_t mutex_prof_data[mutex_prof_num_global_mutexes];
60 typedef struct ctl_arena_s ctl_arena_t;
64 ql_elm(ctl_arena_t) destroyed_link;
66 /* Basic stats, supported even if !config_stats. */
69 ssize_t dirty_decay_ms;
70 ssize_t muzzy_decay_ms;
75 /* NULL if !config_stats. */
76 ctl_arena_stats_t *astats;
79 typedef struct ctl_arenas_s {
82 ql_head(ctl_arena_t) destroyed;
85 * Element 0 corresponds to merged stats for extant arenas (accessed via
86 * MALLCTL_ARENAS_ALL), element 1 corresponds to merged stats for
87 * destroyed arenas (accessed via MALLCTL_ARENAS_DESTROYED), and the
88 * remaining MALLOCX_ARENA_LIMIT elements correspond to arenas.
90 ctl_arena_t *arenas[2 + MALLOCX_ARENA_LIMIT];
93 int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
94 void *newp, size_t newlen);
95 int ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp);
97 int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
98 size_t *oldlenp, void *newp, size_t newlen);
100 void ctl_prefork(tsdn_t *tsdn);
101 void ctl_postfork_parent(tsdn_t *tsdn);
102 void ctl_postfork_child(tsdn_t *tsdn);
104 #define xmallctl(name, oldp, oldlenp, newp, newlen) do { \
105 if (je_mallctl(name, oldp, oldlenp, newp, newlen) \
108 "<jemalloc>: Failure in xmallctl(\"%s\", ...)\n", \
114 #define xmallctlnametomib(name, mibp, miblenp) do { \
115 if (je_mallctlnametomib(name, mibp, miblenp) != 0) { \
116 malloc_printf("<jemalloc>: Failure in " \
117 "xmallctlnametomib(\"%s\", ...)\n", name); \
122 #define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \
123 if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp, \
126 "<jemalloc>: Failure in xmallctlbymib()\n"); \
131 #endif /* JEMALLOC_INTERNAL_CTL_H */