]> git.saurik.com Git - redis.git/blame - deps/jemalloc/src/stats.c
Sentinel: SENTINEL FAILOVER command implemented.
[redis.git] / deps / jemalloc / src / stats.c
CommitLineData
a78e148b 1#define JEMALLOC_STATS_C_
2#include "jemalloc/internal/jemalloc_internal.h"
3
4#define CTL_GET(n, v, t) do { \
5 size_t sz = sizeof(t); \
6 xmallctl(n, v, &sz, NULL, 0); \
7} while (0)
8
9#define CTL_I_GET(n, v, t) do { \
10 size_t mib[6]; \
11 size_t miblen = sizeof(mib) / sizeof(size_t); \
12 size_t sz = sizeof(t); \
13 xmallctlnametomib(n, mib, &miblen); \
14 mib[2] = i; \
15 xmallctlbymib(mib, miblen, v, &sz, NULL, 0); \
16} while (0)
17
18#define CTL_J_GET(n, v, t) do { \
19 size_t mib[6]; \
20 size_t miblen = sizeof(mib) / sizeof(size_t); \
21 size_t sz = sizeof(t); \
22 xmallctlnametomib(n, mib, &miblen); \
23 mib[2] = j; \
24 xmallctlbymib(mib, miblen, v, &sz, NULL, 0); \
25} while (0)
26
27#define CTL_IJ_GET(n, v, t) do { \
28 size_t mib[6]; \
29 size_t miblen = sizeof(mib) / sizeof(size_t); \
30 size_t sz = sizeof(t); \
31 xmallctlnametomib(n, mib, &miblen); \
32 mib[2] = i; \
33 mib[4] = j; \
34 xmallctlbymib(mib, miblen, v, &sz, NULL, 0); \
35} while (0)
36
37/******************************************************************************/
38/* Data. */
39
40bool opt_stats_print = false;
41
a78e148b 42size_t stats_cactive = 0;
a78e148b 43
44/******************************************************************************/
45/* Function prototypes for non-inline static functions. */
46
a78e148b 47static void stats_arena_bins_print(void (*write_cb)(void *, const char *),
48 void *cbopaque, unsigned i);
49static void stats_arena_lruns_print(void (*write_cb)(void *, const char *),
50 void *cbopaque, unsigned i);
51static void stats_arena_print(void (*write_cb)(void *, const char *),
ad4c0b41 52 void *cbopaque, unsigned i, bool bins, bool large);
a78e148b 53
54/******************************************************************************/
55
a78e148b 56static void
57stats_arena_bins_print(void (*write_cb)(void *, const char *), void *cbopaque,
58 unsigned i)
59{
ad4c0b41 60 size_t page;
a78e148b 61 bool config_tcache;
62 unsigned nbins, j, gap_start;
63
ad4c0b41 64 CTL_GET("arenas.page", &page, size_t);
a78e148b 65
66 CTL_GET("config.tcache", &config_tcache, bool);
67 if (config_tcache) {
68 malloc_cprintf(write_cb, cbopaque,
ad4c0b41 69 "bins: bin size regs pgs allocated nmalloc"
a78e148b 70 " ndalloc nrequests nfills nflushes"
ad4c0b41 71 " newruns reruns curruns\n");
a78e148b 72 } else {
73 malloc_cprintf(write_cb, cbopaque,
ad4c0b41 74 "bins: bin size regs pgs allocated nmalloc"
75 " ndalloc newruns reruns curruns\n");
a78e148b 76 }
77 CTL_GET("arenas.nbins", &nbins, unsigned);
78 for (j = 0, gap_start = UINT_MAX; j < nbins; j++) {
79 uint64_t nruns;
80
81 CTL_IJ_GET("stats.arenas.0.bins.0.nruns", &nruns, uint64_t);
82 if (nruns == 0) {
83 if (gap_start == UINT_MAX)
84 gap_start = j;
85 } else {
a78e148b 86 size_t reg_size, run_size, allocated;
87 uint32_t nregs;
88 uint64_t nmalloc, ndalloc, nrequests, nfills, nflushes;
89 uint64_t reruns;
ad4c0b41 90 size_t curruns;
a78e148b 91
92 if (gap_start != UINT_MAX) {
93 if (j > gap_start + 1) {
94 /* Gap of more than one size class. */
95 malloc_cprintf(write_cb, cbopaque,
96 "[%u..%u]\n", gap_start,
97 j - 1);
98 } else {
99 /* Gap of one size class. */
100 malloc_cprintf(write_cb, cbopaque,
101 "[%u]\n", gap_start);
102 }
103 gap_start = UINT_MAX;
104 }
a78e148b 105 CTL_J_GET("arenas.bin.0.size", &reg_size, size_t);
106 CTL_J_GET("arenas.bin.0.nregs", &nregs, uint32_t);
107 CTL_J_GET("arenas.bin.0.run_size", &run_size, size_t);
108 CTL_IJ_GET("stats.arenas.0.bins.0.allocated",
109 &allocated, size_t);
110 CTL_IJ_GET("stats.arenas.0.bins.0.nmalloc",
111 &nmalloc, uint64_t);
112 CTL_IJ_GET("stats.arenas.0.bins.0.ndalloc",
113 &ndalloc, uint64_t);
114 if (config_tcache) {
115 CTL_IJ_GET("stats.arenas.0.bins.0.nrequests",
116 &nrequests, uint64_t);
117 CTL_IJ_GET("stats.arenas.0.bins.0.nfills",
118 &nfills, uint64_t);
119 CTL_IJ_GET("stats.arenas.0.bins.0.nflushes",
120 &nflushes, uint64_t);
121 }
122 CTL_IJ_GET("stats.arenas.0.bins.0.nreruns", &reruns,
123 uint64_t);
a78e148b 124 CTL_IJ_GET("stats.arenas.0.bins.0.curruns", &curruns,
125 size_t);
126 if (config_tcache) {
127 malloc_cprintf(write_cb, cbopaque,
ad4c0b41 128 "%13u %5zu %4u %3zu %12zu %12"PRIu64
a78e148b 129 " %12"PRIu64" %12"PRIu64" %12"PRIu64
130 " %12"PRIu64" %12"PRIu64" %12"PRIu64
ad4c0b41 131 " %12zu\n",
132 j, reg_size, nregs, run_size / page,
a78e148b 133 allocated, nmalloc, ndalloc, nrequests,
ad4c0b41 134 nfills, nflushes, nruns, reruns, curruns);
a78e148b 135 } else {
136 malloc_cprintf(write_cb, cbopaque,
ad4c0b41 137 "%13u %5zu %4u %3zu %12zu %12"PRIu64
a78e148b 138 " %12"PRIu64" %12"PRIu64" %12"PRIu64
ad4c0b41 139 " %12zu\n",
140 j, reg_size, nregs, run_size / page,
a78e148b 141 allocated, nmalloc, ndalloc, nruns, reruns,
ad4c0b41 142 curruns);
a78e148b 143 }
144 }
145 }
146 if (gap_start != UINT_MAX) {
147 if (j > gap_start + 1) {
148 /* Gap of more than one size class. */
149 malloc_cprintf(write_cb, cbopaque, "[%u..%u]\n",
150 gap_start, j - 1);
151 } else {
152 /* Gap of one size class. */
153 malloc_cprintf(write_cb, cbopaque, "[%u]\n", gap_start);
154 }
155 }
156}
157
158static void
159stats_arena_lruns_print(void (*write_cb)(void *, const char *), void *cbopaque,
160 unsigned i)
161{
ad4c0b41 162 size_t page, nlruns, j;
a78e148b 163 ssize_t gap_start;
164
ad4c0b41 165 CTL_GET("arenas.page", &page, size_t);
a78e148b 166
167 malloc_cprintf(write_cb, cbopaque,
168 "large: size pages nmalloc ndalloc nrequests"
ad4c0b41 169 " curruns\n");
a78e148b 170 CTL_GET("arenas.nlruns", &nlruns, size_t);
171 for (j = 0, gap_start = -1; j < nlruns; j++) {
172 uint64_t nmalloc, ndalloc, nrequests;
ad4c0b41 173 size_t run_size, curruns;
a78e148b 174
175 CTL_IJ_GET("stats.arenas.0.lruns.0.nmalloc", &nmalloc,
176 uint64_t);
177 CTL_IJ_GET("stats.arenas.0.lruns.0.ndalloc", &ndalloc,
178 uint64_t);
179 CTL_IJ_GET("stats.arenas.0.lruns.0.nrequests", &nrequests,
180 uint64_t);
181 if (nrequests == 0) {
182 if (gap_start == -1)
183 gap_start = j;
184 } else {
185 CTL_J_GET("arenas.lrun.0.size", &run_size, size_t);
a78e148b 186 CTL_IJ_GET("stats.arenas.0.lruns.0.curruns", &curruns,
187 size_t);
188 if (gap_start != -1) {
189 malloc_cprintf(write_cb, cbopaque, "[%zu]\n",
190 j - gap_start);
191 gap_start = -1;
192 }
193 malloc_cprintf(write_cb, cbopaque,
194 "%13zu %5zu %12"PRIu64" %12"PRIu64" %12"PRIu64
ad4c0b41 195 " %12zu\n",
196 run_size, run_size / page, nmalloc, ndalloc,
197 nrequests, curruns);
a78e148b 198 }
199 }
200 if (gap_start != -1)
201 malloc_cprintf(write_cb, cbopaque, "[%zu]\n", j - gap_start);
202}
203
204static void
205stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
ad4c0b41 206 unsigned i, bool bins, bool large)
a78e148b 207{
208 unsigned nthreads;
ad4c0b41 209 size_t page, pactive, pdirty, mapped;
a78e148b 210 uint64_t npurge, nmadvise, purged;
211 size_t small_allocated;
212 uint64_t small_nmalloc, small_ndalloc, small_nrequests;
213 size_t large_allocated;
214 uint64_t large_nmalloc, large_ndalloc, large_nrequests;
215
ad4c0b41 216 CTL_GET("arenas.page", &page, size_t);
a78e148b 217
218 CTL_I_GET("stats.arenas.0.nthreads", &nthreads, unsigned);
219 malloc_cprintf(write_cb, cbopaque,
220 "assigned threads: %u\n", nthreads);
221 CTL_I_GET("stats.arenas.0.pactive", &pactive, size_t);
222 CTL_I_GET("stats.arenas.0.pdirty", &pdirty, size_t);
223 CTL_I_GET("stats.arenas.0.npurge", &npurge, uint64_t);
224 CTL_I_GET("stats.arenas.0.nmadvise", &nmadvise, uint64_t);
225 CTL_I_GET("stats.arenas.0.purged", &purged, uint64_t);
226 malloc_cprintf(write_cb, cbopaque,
227 "dirty pages: %zu:%zu active:dirty, %"PRIu64" sweep%s,"
228 " %"PRIu64" madvise%s, %"PRIu64" purged\n",
229 pactive, pdirty, npurge, npurge == 1 ? "" : "s",
230 nmadvise, nmadvise == 1 ? "" : "s", purged);
231
232 malloc_cprintf(write_cb, cbopaque,
233 " allocated nmalloc ndalloc nrequests\n");
234 CTL_I_GET("stats.arenas.0.small.allocated", &small_allocated, size_t);
235 CTL_I_GET("stats.arenas.0.small.nmalloc", &small_nmalloc, uint64_t);
236 CTL_I_GET("stats.arenas.0.small.ndalloc", &small_ndalloc, uint64_t);
237 CTL_I_GET("stats.arenas.0.small.nrequests", &small_nrequests, uint64_t);
238 malloc_cprintf(write_cb, cbopaque,
239 "small: %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
240 small_allocated, small_nmalloc, small_ndalloc, small_nrequests);
241 CTL_I_GET("stats.arenas.0.large.allocated", &large_allocated, size_t);
242 CTL_I_GET("stats.arenas.0.large.nmalloc", &large_nmalloc, uint64_t);
243 CTL_I_GET("stats.arenas.0.large.ndalloc", &large_ndalloc, uint64_t);
244 CTL_I_GET("stats.arenas.0.large.nrequests", &large_nrequests, uint64_t);
245 malloc_cprintf(write_cb, cbopaque,
246 "large: %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
247 large_allocated, large_nmalloc, large_ndalloc, large_nrequests);
248 malloc_cprintf(write_cb, cbopaque,
249 "total: %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
250 small_allocated + large_allocated,
251 small_nmalloc + large_nmalloc,
252 small_ndalloc + large_ndalloc,
253 small_nrequests + large_nrequests);
ad4c0b41 254 malloc_cprintf(write_cb, cbopaque, "active: %12zu\n", pactive * page);
a78e148b 255 CTL_I_GET("stats.arenas.0.mapped", &mapped, size_t);
256 malloc_cprintf(write_cb, cbopaque, "mapped: %12zu\n", mapped);
257
ad4c0b41 258 if (bins)
259 stats_arena_bins_print(write_cb, cbopaque, i);
260 if (large)
261 stats_arena_lruns_print(write_cb, cbopaque, i);
a78e148b 262}
a78e148b 263
264void
265stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
266 const char *opts)
267{
268 int err;
269 uint64_t epoch;
270 size_t u64sz;
a78e148b 271 bool general = true;
272 bool merged = true;
273 bool unmerged = true;
274 bool bins = true;
275 bool large = true;
276
277 /*
278 * Refresh stats, in case mallctl() was called by the application.
279 *
280 * Check for OOM here, since refreshing the ctl cache can trigger
281 * allocation. In practice, none of the subsequent mallctl()-related
282 * calls in this function will cause OOM if this one succeeds.
283 * */
284 epoch = 1;
285 u64sz = sizeof(uint64_t);
ad4c0b41 286 err = je_mallctl("epoch", &epoch, &u64sz, &epoch, sizeof(uint64_t));
a78e148b 287 if (err != 0) {
288 if (err == EAGAIN) {
289 malloc_write("<jemalloc>: Memory allocation failure in "
290 "mallctl(\"epoch\", ...)\n");
291 return;
292 }
293 malloc_write("<jemalloc>: Failure in mallctl(\"epoch\", "
294 "...)\n");
295 abort();
296 }
297
a78e148b 298 if (opts != NULL) {
299 unsigned i;
300
301 for (i = 0; opts[i] != '\0'; i++) {
302 switch (opts[i]) {
ad4c0b41 303 case 'g':
304 general = false;
305 break;
306 case 'm':
307 merged = false;
308 break;
309 case 'a':
310 unmerged = false;
311 break;
312 case 'b':
313 bins = false;
314 break;
315 case 'l':
316 large = false;
317 break;
318 default:;
a78e148b 319 }
320 }
321 }
322
ad4c0b41 323 malloc_cprintf(write_cb, cbopaque,
324 "___ Begin jemalloc statistics ___\n");
a78e148b 325 if (general) {
326 int err;
327 const char *cpv;
328 bool bv;
329 unsigned uv;
330 ssize_t ssv;
331 size_t sv, bsz, ssz, sssz, cpsz;
332
333 bsz = sizeof(bool);
334 ssz = sizeof(size_t);
335 sssz = sizeof(ssize_t);
336 cpsz = sizeof(const char *);
337
338 CTL_GET("version", &cpv, const char *);
ad4c0b41 339 malloc_cprintf(write_cb, cbopaque, "Version: %s\n", cpv);
a78e148b 340 CTL_GET("config.debug", &bv, bool);
ad4c0b41 341 malloc_cprintf(write_cb, cbopaque, "Assertions %s\n",
342 bv ? "enabled" : "disabled");
a78e148b 343
344#define OPT_WRITE_BOOL(n) \
ad4c0b41 345 if ((err = je_mallctl("opt."#n, &bv, &bsz, NULL, 0)) \
346 == 0) { \
347 malloc_cprintf(write_cb, cbopaque, \
348 " opt."#n": %s\n", bv ? "true" : "false"); \
a78e148b 349 }
350#define OPT_WRITE_SIZE_T(n) \
ad4c0b41 351 if ((err = je_mallctl("opt."#n, &sv, &ssz, NULL, 0)) \
352 == 0) { \
353 malloc_cprintf(write_cb, cbopaque, \
354 " opt."#n": %zu\n", sv); \
a78e148b 355 }
356#define OPT_WRITE_SSIZE_T(n) \
ad4c0b41 357 if ((err = je_mallctl("opt."#n, &ssv, &sssz, NULL, 0)) \
358 == 0) { \
359 malloc_cprintf(write_cb, cbopaque, \
360 " opt."#n": %zd\n", ssv); \
a78e148b 361 }
362#define OPT_WRITE_CHAR_P(n) \
ad4c0b41 363 if ((err = je_mallctl("opt."#n, &cpv, &cpsz, NULL, 0)) \
364 == 0) { \
365 malloc_cprintf(write_cb, cbopaque, \
366 " opt."#n": \"%s\"\n", cpv); \
a78e148b 367 }
368
ad4c0b41 369 malloc_cprintf(write_cb, cbopaque,
370 "Run-time option settings:\n");
a78e148b 371 OPT_WRITE_BOOL(abort)
a78e148b 372 OPT_WRITE_SIZE_T(lg_chunk)
373 OPT_WRITE_SIZE_T(narenas)
374 OPT_WRITE_SSIZE_T(lg_dirty_mult)
375 OPT_WRITE_BOOL(stats_print)
376 OPT_WRITE_BOOL(junk)
ad4c0b41 377 OPT_WRITE_SIZE_T(quarantine)
378 OPT_WRITE_BOOL(redzone)
a78e148b 379 OPT_WRITE_BOOL(zero)
ad4c0b41 380 OPT_WRITE_BOOL(utrace)
381 OPT_WRITE_BOOL(valgrind)
a78e148b 382 OPT_WRITE_BOOL(xmalloc)
383 OPT_WRITE_BOOL(tcache)
a78e148b 384 OPT_WRITE_SSIZE_T(lg_tcache_max)
385 OPT_WRITE_BOOL(prof)
386 OPT_WRITE_CHAR_P(prof_prefix)
a78e148b 387 OPT_WRITE_BOOL(prof_active)
388 OPT_WRITE_SSIZE_T(lg_prof_sample)
389 OPT_WRITE_BOOL(prof_accum)
a78e148b 390 OPT_WRITE_SSIZE_T(lg_prof_interval)
391 OPT_WRITE_BOOL(prof_gdump)
ad4c0b41 392 OPT_WRITE_BOOL(prof_final)
a78e148b 393 OPT_WRITE_BOOL(prof_leak)
a78e148b 394
395#undef OPT_WRITE_BOOL
396#undef OPT_WRITE_SIZE_T
397#undef OPT_WRITE_SSIZE_T
398#undef OPT_WRITE_CHAR_P
399
ad4c0b41 400 malloc_cprintf(write_cb, cbopaque, "CPUs: %u\n", ncpus);
a78e148b 401
402 CTL_GET("arenas.narenas", &uv, unsigned);
ad4c0b41 403 malloc_cprintf(write_cb, cbopaque, "Max arenas: %u\n", uv);
a78e148b 404
ad4c0b41 405 malloc_cprintf(write_cb, cbopaque, "Pointer size: %zu\n",
406 sizeof(void *));
a78e148b 407
408 CTL_GET("arenas.quantum", &sv, size_t);
ad4c0b41 409 malloc_cprintf(write_cb, cbopaque, "Quantum size: %zu\n", sv);
a78e148b 410
ad4c0b41 411 CTL_GET("arenas.page", &sv, size_t);
412 malloc_cprintf(write_cb, cbopaque, "Page size: %zu\n", sv);
a78e148b 413
414 CTL_GET("opt.lg_dirty_mult", &ssv, ssize_t);
415 if (ssv >= 0) {
ad4c0b41 416 malloc_cprintf(write_cb, cbopaque,
417 "Min active:dirty page ratio per arena: %u:1\n",
418 (1U << ssv));
a78e148b 419 } else {
ad4c0b41 420 malloc_cprintf(write_cb, cbopaque,
a78e148b 421 "Min active:dirty page ratio per arena: N/A\n");
422 }
ad4c0b41 423 if ((err = je_mallctl("arenas.tcache_max", &sv, &ssz, NULL, 0))
424 == 0) {
425 malloc_cprintf(write_cb, cbopaque,
426 "Maximum thread-cached size class: %zu\n", sv);
a78e148b 427 }
ad4c0b41 428 if ((err = je_mallctl("opt.prof", &bv, &bsz, NULL, 0)) == 0 &&
429 bv) {
a78e148b 430 CTL_GET("opt.lg_prof_sample", &sv, size_t);
ad4c0b41 431 malloc_cprintf(write_cb, cbopaque,
432 "Average profile sample interval: %"PRIu64
433 " (2^%zu)\n", (((uint64_t)1U) << sv), sv);
a78e148b 434
435 CTL_GET("opt.lg_prof_interval", &ssv, ssize_t);
a78e148b 436 if (ssv >= 0) {
ad4c0b41 437 malloc_cprintf(write_cb, cbopaque,
438 "Average profile dump interval: %"PRIu64
439 " (2^%zd)\n",
440 (((uint64_t)1U) << ssv), ssv);
441 } else {
442 malloc_cprintf(write_cb, cbopaque,
443 "Average profile dump interval: N/A\n");
444 }
a78e148b 445 }
a78e148b 446 CTL_GET("opt.lg_chunk", &sv, size_t);
ad4c0b41 447 malloc_cprintf(write_cb, cbopaque, "Chunk size: %zu (2^%zu)\n",
448 (ZU(1) << sv), sv);
a78e148b 449 }
450
ad4c0b41 451 if (config_stats) {
a78e148b 452 size_t *cactive;
453 size_t allocated, active, mapped;
ad4c0b41 454 size_t chunks_current, chunks_high;
a78e148b 455 uint64_t chunks_total;
456 size_t huge_allocated;
457 uint64_t huge_nmalloc, huge_ndalloc;
458
a78e148b 459 CTL_GET("stats.cactive", &cactive, size_t *);
460 CTL_GET("stats.allocated", &allocated, size_t);
461 CTL_GET("stats.active", &active, size_t);
462 CTL_GET("stats.mapped", &mapped, size_t);
463 malloc_cprintf(write_cb, cbopaque,
464 "Allocated: %zu, active: %zu, mapped: %zu\n",
465 allocated, active, mapped);
466 malloc_cprintf(write_cb, cbopaque,
467 "Current active ceiling: %zu\n", atomic_read_z(cactive));
468
469 /* Print chunk stats. */
470 CTL_GET("stats.chunks.total", &chunks_total, uint64_t);
471 CTL_GET("stats.chunks.high", &chunks_high, size_t);
472 CTL_GET("stats.chunks.current", &chunks_current, size_t);
ad4c0b41 473 malloc_cprintf(write_cb, cbopaque, "chunks: nchunks "
474 "highchunks curchunks\n");
475 malloc_cprintf(write_cb, cbopaque, " %13"PRIu64"%13zu%13zu\n",
476 chunks_total, chunks_high, chunks_current);
a78e148b 477
478 /* Print huge stats. */
479 CTL_GET("stats.huge.nmalloc", &huge_nmalloc, uint64_t);
480 CTL_GET("stats.huge.ndalloc", &huge_ndalloc, uint64_t);
481 CTL_GET("stats.huge.allocated", &huge_allocated, size_t);
482 malloc_cprintf(write_cb, cbopaque,
483 "huge: nmalloc ndalloc allocated\n");
484 malloc_cprintf(write_cb, cbopaque,
485 " %12"PRIu64" %12"PRIu64" %12zu\n",
486 huge_nmalloc, huge_ndalloc, huge_allocated);
487
488 if (merged) {
489 unsigned narenas;
490
491 CTL_GET("arenas.narenas", &narenas, unsigned);
492 {
ad4c0b41 493 VARIABLE_ARRAY(bool, initialized, narenas);
a78e148b 494 size_t isz;
495 unsigned i, ninitialized;
496
ad4c0b41 497 isz = sizeof(bool) * narenas;
a78e148b 498 xmallctl("arenas.initialized", initialized,
499 &isz, NULL, 0);
500 for (i = ninitialized = 0; i < narenas; i++) {
501 if (initialized[i])
502 ninitialized++;
503 }
504
1d03c1c9 505 if (ninitialized > 1 || unmerged == false) {
a78e148b 506 /* Print merged arena stats. */
507 malloc_cprintf(write_cb, cbopaque,
508 "\nMerged arenas stats:\n");
509 stats_arena_print(write_cb, cbopaque,
ad4c0b41 510 narenas, bins, large);
a78e148b 511 }
512 }
513 }
514
515 if (unmerged) {
516 unsigned narenas;
517
518 /* Print stats for each arena. */
519
520 CTL_GET("arenas.narenas", &narenas, unsigned);
521 {
ad4c0b41 522 VARIABLE_ARRAY(bool, initialized, narenas);
a78e148b 523 size_t isz;
524 unsigned i;
525
ad4c0b41 526 isz = sizeof(bool) * narenas;
a78e148b 527 xmallctl("arenas.initialized", initialized,
528 &isz, NULL, 0);
529
530 for (i = 0; i < narenas; i++) {
531 if (initialized[i]) {
532 malloc_cprintf(write_cb,
533 cbopaque,
534 "\narenas[%u]:\n", i);
535 stats_arena_print(write_cb,
ad4c0b41 536 cbopaque, i, bins, large);
a78e148b 537 }
538 }
539 }
540 }
541 }
ad4c0b41 542 malloc_cprintf(write_cb, cbopaque, "--- End jemalloc statistics ---\n");
a78e148b 543}