• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
3 
4 typedef struct ctl_node_s ctl_node_t;
5 typedef struct ctl_named_node_s ctl_named_node_t;
6 typedef struct ctl_indexed_node_s ctl_indexed_node_t;
7 typedef struct ctl_arena_stats_s ctl_arena_stats_t;
8 typedef struct ctl_stats_s ctl_stats_t;
9 
10 #endif /* JEMALLOC_H_TYPES */
11 /******************************************************************************/
12 #ifdef JEMALLOC_H_STRUCTS
13 
14 struct ctl_node_s {
15 	bool			named;
16 };
17 
18 struct ctl_named_node_s {
19 	struct ctl_node_s	node;
20 	const char		*name;
21 	/* If (nchildren == 0), this is a terminal node. */
22 	unsigned		nchildren;
23 	const			ctl_node_t *children;
24 	int			(*ctl)(const size_t *, size_t, void *, size_t *,
25 	    void *, size_t);
26 };
27 
28 struct ctl_indexed_node_s {
29 	struct ctl_node_s	node;
30 	const ctl_named_node_t	*(*index)(const size_t *, size_t, size_t);
31 };
32 
33 struct ctl_arena_stats_s {
34 	bool			initialized;
35 	unsigned		nthreads;
36 	const char		*dss;
37 	ssize_t			lg_dirty_mult;
38 	size_t			pactive;
39 	size_t			pdirty;
40 	arena_stats_t		astats;
41 
42 	/* Aggregate stats for small size classes, based on bin stats. */
43 	size_t			allocated_small;
44 	uint64_t		nmalloc_small;
45 	uint64_t		ndalloc_small;
46 	uint64_t		nrequests_small;
47 
48 	malloc_bin_stats_t	bstats[NBINS];
49 	malloc_large_stats_t	*lstats;	/* nlclasses elements. */
50 	malloc_huge_stats_t	*hstats;	/* nhclasses elements. */
51 };
52 
53 struct ctl_stats_s {
54 	size_t			allocated;
55 	size_t			active;
56 	size_t			metadata;
57 	size_t			resident;
58 	size_t			mapped;
59 	unsigned		narenas;
60 	ctl_arena_stats_t	*arenas;	/* (narenas + 1) elements. */
61 };
62 
63 #endif /* JEMALLOC_H_STRUCTS */
64 /******************************************************************************/
65 #ifdef JEMALLOC_H_EXTERNS
66 
67 int	ctl_byname(const char *name, void *oldp, size_t *oldlenp, void *newp,
68     size_t newlen);
69 int	ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp);
70 
71 int	ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
72     void *newp, size_t newlen);
73 bool	ctl_boot(void);
74 void	ctl_prefork(void);
75 void	ctl_postfork_parent(void);
76 void	ctl_postfork_child(void);
77 
78 #define	xmallctl(name, oldp, oldlenp, newp, newlen) do {		\
79 	if (je_mallctl(name, oldp, oldlenp, newp, newlen)		\
80 	    != 0) {							\
81 		malloc_printf(						\
82 		    "<jemalloc>: Failure in xmallctl(\"%s\", ...)\n",	\
83 		    name);						\
84 		abort();						\
85 	}								\
86 } while (0)
87 
88 #define	xmallctlnametomib(name, mibp, miblenp) do {			\
89 	if (je_mallctlnametomib(name, mibp, miblenp) != 0) {		\
90 		malloc_printf("<jemalloc>: Failure in "			\
91 		    "xmallctlnametomib(\"%s\", ...)\n", name);		\
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