2010-01-28 05:10:55 +08:00
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_TYPES
|
|
|
|
|
|
|
|
typedef struct ctl_node_s ctl_node_t;
|
2012-04-20 14:38:42 +08:00
|
|
|
typedef struct ctl_named_node_s ctl_named_node_t;
|
|
|
|
typedef struct ctl_indexed_node_s ctl_indexed_node_t;
|
2010-01-28 05:10:55 +08:00
|
|
|
typedef struct ctl_arena_stats_s ctl_arena_stats_t;
|
|
|
|
typedef struct ctl_stats_s ctl_stats_t;
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_TYPES */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_STRUCTS
|
|
|
|
|
|
|
|
struct ctl_node_s {
|
|
|
|
bool named;
|
2012-04-20 14:38:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ctl_named_node_s {
|
|
|
|
struct ctl_node_s node;
|
2012-04-24 10:31:45 +08:00
|
|
|
const char *name;
|
2012-04-20 14:38:42 +08:00
|
|
|
/* If (nchildren == 0), this is a terminal node. */
|
2012-04-24 10:31:45 +08:00
|
|
|
unsigned nchildren;
|
|
|
|
const ctl_node_t *children;
|
|
|
|
int (*ctl)(const size_t *, size_t, void *, size_t *,
|
|
|
|
void *, size_t);
|
2010-01-28 05:10:55 +08:00
|
|
|
};
|
|
|
|
|
2012-04-20 14:38:42 +08:00
|
|
|
struct ctl_indexed_node_s {
|
|
|
|
struct ctl_node_s node;
|
2012-04-24 10:31:45 +08:00
|
|
|
const ctl_named_node_t *(*index)(const size_t *, size_t, size_t);
|
2012-04-20 14:38:42 +08:00
|
|
|
};
|
|
|
|
|
2010-01-28 05:10:55 +08:00
|
|
|
struct ctl_arena_stats_s {
|
|
|
|
bool initialized;
|
2011-03-19 04:41:33 +08:00
|
|
|
unsigned nthreads;
|
2012-10-12 04:53:15 +08:00
|
|
|
const char *dss;
|
2010-01-28 05:10:55 +08:00
|
|
|
size_t pactive;
|
|
|
|
size_t pdirty;
|
|
|
|
arena_stats_t astats;
|
2010-03-14 12:32:56 +08:00
|
|
|
|
2010-03-18 07:27:39 +08:00
|
|
|
/* Aggregate stats for small size classes, based on bin stats. */
|
2010-03-14 12:32:56 +08:00
|
|
|
size_t allocated_small;
|
|
|
|
uint64_t nmalloc_small;
|
|
|
|
uint64_t ndalloc_small;
|
|
|
|
uint64_t nrequests_small;
|
|
|
|
|
2012-02-29 08:50:47 +08:00
|
|
|
malloc_bin_stats_t bstats[NBINS];
|
2010-01-28 05:10:55 +08:00
|
|
|
malloc_large_stats_t *lstats; /* nlclasses elements. */
|
2014-10-13 13:53:59 +08:00
|
|
|
malloc_huge_stats_t *hstats; /* nhclasses elements. */
|
2010-01-28 05:10:55 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ctl_stats_s {
|
|
|
|
size_t allocated;
|
|
|
|
size_t active;
|
|
|
|
size_t mapped;
|
|
|
|
struct {
|
|
|
|
size_t current; /* stats_chunks.curchunks */
|
|
|
|
uint64_t total; /* stats_chunks.nchunks */
|
|
|
|
size_t high; /* stats_chunks.highchunks */
|
|
|
|
} chunks;
|
2012-10-12 04:53:15 +08:00
|
|
|
unsigned narenas;
|
2010-01-28 05:10:55 +08:00
|
|
|
ctl_arena_stats_t *arenas; /* (narenas + 1) elements. */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_STRUCTS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_EXTERNS
|
|
|
|
|
|
|
|
int ctl_byname(const char *name, void *oldp, size_t *oldlenp, void *newp,
|
|
|
|
size_t newlen);
|
|
|
|
int ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp);
|
|
|
|
|
|
|
|
int ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
|
|
|
|
void *newp, size_t newlen);
|
|
|
|
bool ctl_boot(void);
|
2012-10-10 05:46:22 +08:00
|
|
|
void ctl_prefork(void);
|
|
|
|
void ctl_postfork_parent(void);
|
|
|
|
void ctl_postfork_child(void);
|
2010-01-28 05:10:55 +08:00
|
|
|
|
|
|
|
#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \
|
2012-03-02 09:19:20 +08:00
|
|
|
if (je_mallctl(name, oldp, oldlenp, newp, newlen) \
|
2010-02-12 06:55:25 +08:00
|
|
|
!= 0) { \
|
2012-03-07 06:57:45 +08:00
|
|
|
malloc_printf( \
|
|
|
|
"<jemalloc>: Failure in xmallctl(\"%s\", ...)\n", \
|
|
|
|
name); \
|
2010-01-28 05:10:55 +08:00
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define xmallctlnametomib(name, mibp, miblenp) do { \
|
2012-03-02 09:19:20 +08:00
|
|
|
if (je_mallctlnametomib(name, mibp, miblenp) != 0) { \
|
2012-03-07 06:57:45 +08:00
|
|
|
malloc_printf("<jemalloc>: Failure in " \
|
|
|
|
"xmallctlnametomib(\"%s\", ...)\n", name); \
|
2010-01-28 05:10:55 +08:00
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \
|
2012-03-02 09:19:20 +08:00
|
|
|
if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp, \
|
2010-02-12 06:55:25 +08:00
|
|
|
newlen) != 0) { \
|
2010-03-04 09:45:38 +08:00
|
|
|
malloc_write( \
|
2010-10-24 09:37:06 +08:00
|
|
|
"<jemalloc>: Failure in xmallctlbymib()\n"); \
|
2010-01-28 05:10:55 +08:00
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_EXTERNS */
|
|
|
|
/******************************************************************************/
|
|
|
|
#ifdef JEMALLOC_H_INLINES
|
|
|
|
|
|
|
|
#endif /* JEMALLOC_H_INLINES */
|
|
|
|
/******************************************************************************/
|
|
|
|
|