1/******************************************************************************/ 2#ifdef JEMALLOC_H_TYPES 3 4typedef struct tcache_bin_stats_s tcache_bin_stats_t; 5typedef struct malloc_bin_stats_s malloc_bin_stats_t; 6typedef struct malloc_large_stats_s malloc_large_stats_t; 7typedef struct arena_stats_s arena_stats_t; 8typedef struct chunk_stats_s chunk_stats_t; 9 10#endif /* JEMALLOC_H_TYPES */ 11/******************************************************************************/ 12#ifdef JEMALLOC_H_STRUCTS 13 14struct tcache_bin_stats_s { 15 /* 16 * Number of allocation requests that corresponded to the size of this 17 * bin. 18 */ 19 uint64_t nrequests; 20}; 21 22struct malloc_bin_stats_s { 23 /* 24 * Current number of bytes allocated, including objects currently 25 * cached by tcache. 26 */ 27 size_t allocated; 28 29 /* 30 * Total number of allocation/deallocation requests served directly by 31 * the bin. Note that tcache may allocate an object, then recycle it 32 * many times, resulting many increments to nrequests, but only one 33 * each to nmalloc and ndalloc. 34 */ 35 uint64_t nmalloc; 36 uint64_t ndalloc; 37 38 /* 39 * Number of allocation requests that correspond to the size of this 40 * bin. This includes requests served by tcache, though tcache only 41 * periodically merges into this counter. 42 */ 43 uint64_t nrequests; 44 45 /* Number of tcache fills from this bin. */ 46 uint64_t nfills; 47 48 /* Number of tcache flushes to this bin. */ 49 uint64_t nflushes; 50 51 /* Total number of runs created for this bin's size class. */ 52 uint64_t nruns; 53 54 /* 55 * Total number of runs reused by extracting them from the runs tree for 56 * this bin's size class. 57 */ 58 uint64_t reruns; 59 60 /* Current number of runs in this bin. */ 61 size_t curruns; 62}; 63 64struct malloc_large_stats_s { 65 /* 66 * Total number of allocation/deallocation requests served directly by 67 * the arena. Note that tcache may allocate an object, then recycle it 68 * many times, resulting many increments to nrequests, but only one 69 * each to nmalloc and ndalloc. 70 */ 71 uint64_t nmalloc; 72 uint64_t ndalloc; 73 74 /* 75 * Number of allocation requests that correspond to this size class. 76 * This includes requests served by tcache, though tcache only 77 * periodically merges into this counter. 78 */ 79 uint64_t nrequests; 80 81 /* Current number of runs of this size class. */ 82 size_t curruns; 83}; 84 85struct arena_stats_s { 86 /* Number of bytes currently mapped. */ 87 size_t mapped; 88 89 /* 90 * Total number of purge sweeps, total number of madvise calls made, 91 * and total pages purged in order to keep dirty unused memory under 92 * control. 93 */ 94 uint64_t npurge; 95 uint64_t nmadvise; 96 uint64_t purged; 97 98 /* Per-size-category statistics. */ 99 size_t allocated_large; 100 uint64_t nmalloc_large; 101 uint64_t ndalloc_large; 102 uint64_t nrequests_large; 103 104 size_t allocated_huge; 105 uint64_t nmalloc_huge; 106 uint64_t ndalloc_huge; 107 uint64_t nrequests_huge; 108 109 /* 110 * One element for each possible size class, including sizes that 111 * overlap with bin size classes. This is necessary because ipalloc() 112 * sometimes has to use such large objects in order to assure proper 113 * alignment. 114 */ 115 malloc_large_stats_t *lstats; 116}; 117 118struct chunk_stats_s { 119 /* Number of chunks that were allocated. */ 120 uint64_t nchunks; 121 122 /* High-water mark for number of chunks allocated. */ 123 size_t highchunks; 124 125 /* 126 * Current number of chunks allocated. This value isn't maintained for 127 * any other purpose, so keep track of it in order to be able to set 128 * highchunks. 129 */ 130 size_t curchunks; 131}; 132 133#endif /* JEMALLOC_H_STRUCTS */ 134/******************************************************************************/ 135#ifdef JEMALLOC_H_EXTERNS 136 137extern bool opt_stats_print; 138 139extern size_t stats_cactive; 140 141void stats_print(void (*write)(void *, const char *), void *cbopaque, 142 const char *opts); 143 144#endif /* JEMALLOC_H_EXTERNS */ 145/******************************************************************************/ 146#ifdef JEMALLOC_H_INLINES 147 148#ifndef JEMALLOC_ENABLE_INLINE 149size_t stats_cactive_get(void); 150void stats_cactive_add(size_t size); 151void stats_cactive_sub(size_t size); 152#endif 153 154#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_STATS_C_)) 155JEMALLOC_INLINE size_t 156stats_cactive_get(void) 157{ 158 159 return (atomic_read_z(&stats_cactive)); 160} 161 162JEMALLOC_INLINE void 163stats_cactive_add(size_t size) 164{ 165 166 atomic_add_z(&stats_cactive, size); 167} 168 169JEMALLOC_INLINE void 170stats_cactive_sub(size_t size) 171{ 172 173 atomic_sub_z(&stats_cactive, size); 174} 175#endif 176 177#endif /* JEMALLOC_H_INLINES */ 178/******************************************************************************/ 179