ctl.h revision 0a5489e37da88a1a50fbf8552e0d3a7f8fd93ffc
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]; 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}; 63 64#endif /* JEMALLOC_H_STRUCTS */ 65/******************************************************************************/ 66#ifdef JEMALLOC_H_EXTERNS 67 68int ctl_byname(const char *name, void *oldp, size_t *oldlenp, void *newp, 69 size_t newlen); 70int ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp); 71 72int ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, 73 void *newp, size_t newlen); 74bool ctl_boot(void); 75 76#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \ 77 if (je_mallctl(name, oldp, oldlenp, newp, newlen) \ 78 != 0) { \ 79 malloc_write("<jemalloc>: Failure in xmallctl(\""); \ 80 malloc_write(name); \ 81 malloc_write("\", ...)\n"); \ 82 abort(); \ 83 } \ 84} while (0) 85 86#define xmallctlnametomib(name, mibp, miblenp) do { \ 87 if (je_mallctlnametomib(name, mibp, miblenp) != 0) { \ 88 malloc_write( \ 89 "<jemalloc>: Failure in xmallctlnametomib(\""); \ 90 malloc_write(name); \ 91 malloc_write("\", ...)\n"); \ 92 abort(); \ 93 } \ 94} while (0) 95 96#define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \ 97 if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp, \ 98 newlen) != 0) { \ 99 malloc_write( \ 100 "<jemalloc>: Failure in xmallctlbymib()\n"); \ 101 abort(); \ 102 } \ 103} while (0) 104 105#endif /* JEMALLOC_H_EXTERNS */ 106/******************************************************************************/ 107#ifdef JEMALLOC_H_INLINES 108 109#endif /* JEMALLOC_H_INLINES */ 110/******************************************************************************/ 111 112