ctl.h revision 7372b15a31c63ac5cb9ed8aeabc2a0a3c005e8bf
1/******************************************************************************/ 2#ifdef JEMALLOC_H_TYPES 3 4typedef struct ctl_node_s ctl_node_t; 5typedef struct ctl_arena_stats_s ctl_arena_stats_t; 6typedef struct ctl_stats_s ctl_stats_t; 7 8#endif /* JEMALLOC_H_TYPES */ 9/******************************************************************************/ 10#ifdef JEMALLOC_H_STRUCTS 11 12struct ctl_node_s { 13 bool named; 14 union { 15 struct { 16 const char *name; 17 /* If (nchildren == 0), this is a terminal node. */ 18 unsigned nchildren; 19 const ctl_node_t *children; 20 } named; 21 struct { 22 const ctl_node_t *(*index)(const size_t *, size_t, 23 size_t); 24 } indexed; 25 } u; 26 int (*ctl)(const size_t *, size_t, void *, size_t *, void *, 27 size_t); 28}; 29 30struct ctl_arena_stats_s { 31 bool initialized; 32 unsigned nthreads; 33 size_t pactive; 34 size_t pdirty; 35 arena_stats_t astats; 36 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; 42 43 malloc_bin_stats_t *bstats; /* nbins elements. */ 44 malloc_large_stats_t *lstats; /* nlclasses elements. */ 45}; 46 47struct ctl_stats_s { 48 size_t allocated; 49 size_t active; 50 size_t mapped; 51 struct { 52 size_t current; /* stats_chunks.curchunks */ 53 uint64_t total; /* stats_chunks.nchunks */ 54 size_t high; /* stats_chunks.highchunks */ 55 } chunks; 56 struct { 57 size_t allocated; /* huge_allocated */ 58 uint64_t nmalloc; /* huge_nmalloc */ 59 uint64_t ndalloc; /* huge_ndalloc */ 60 } huge; 61 ctl_arena_stats_t *arenas; /* (narenas + 1) elements. */ 62 size_t swap_avail; 63}; 64 65#endif /* JEMALLOC_H_STRUCTS */ 66/******************************************************************************/ 67#ifdef JEMALLOC_H_EXTERNS 68 69int ctl_byname(const char *name, void *oldp, size_t *oldlenp, void *newp, 70 size_t newlen); 71int ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp); 72 73int ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, 74 void *newp, size_t newlen); 75bool ctl_boot(void); 76 77#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \ 78 if (JEMALLOC_P(mallctl)(name, oldp, oldlenp, newp, newlen) \ 79 != 0) { \ 80 malloc_write("<jemalloc>: Failure in xmallctl(\""); \ 81 malloc_write(name); \ 82 malloc_write("\", ...)\n"); \ 83 abort(); \ 84 } \ 85} while (0) 86 87#define xmallctlnametomib(name, mibp, miblenp) do { \ 88 if (JEMALLOC_P(mallctlnametomib)(name, mibp, miblenp) != 0) { \ 89 malloc_write( \ 90 "<jemalloc>: Failure in xmallctlnametomib(\""); \ 91 malloc_write(name); \ 92 malloc_write("\", ...)\n"); \ 93 abort(); \ 94 } \ 95} while (0) 96 97#define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \ 98 if (JEMALLOC_P(mallctlbymib)(mib, miblen, oldp, oldlenp, newp, \ 99 newlen) != 0) { \ 100 malloc_write( \ 101 "<jemalloc>: Failure in xmallctlbymib()\n"); \ 102 abort(); \ 103 } \ 104} while (0) 105 106#endif /* JEMALLOC_H_EXTERNS */ 107/******************************************************************************/ 108#ifdef JEMALLOC_H_INLINES 109 110#endif /* JEMALLOC_H_INLINES */ 111/******************************************************************************/ 112 113