ctl.h revision d81e4bdd5c991bd5642c8b859ef1f752b51cd9be
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_printf(						\
80		    "<jemalloc>: Failure in xmallctl(\"%s\", ...)\n",	\
81		    name);						\
82		abort();						\
83	}								\
84} while (0)
85
86#define	xmallctlnametomib(name, mibp, miblenp) do {			\
87	if (je_mallctlnametomib(name, mibp, miblenp) != 0) {		\
88		malloc_printf("<jemalloc>: Failure in "			\
89		    "xmallctlnametomib(\"%s\", ...)\n", name);		\
90		abort();						\
91	}								\
92} while (0)
93
94#define	xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do {	\
95	if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp,		\
96	    newlen) != 0) {						\
97		malloc_write(						\
98		    "<jemalloc>: Failure in xmallctlbymib()\n");	\
99		abort();						\
100	}								\
101} while (0)
102
103#endif /* JEMALLOC_H_EXTERNS */
104/******************************************************************************/
105#ifdef JEMALLOC_H_INLINES
106
107#endif /* JEMALLOC_H_INLINES */
108/******************************************************************************/
109
110