Home | History | Annotate | Download | only in internal
      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 	ssize_t			decay_time;
     39 	size_t			pactive;
     40 	size_t			pdirty;
     41 
     42 	/* The remainder are only populated if config_stats is true. */
     43 
     44 	arena_stats_t		astats;
     45 
     46 	/* Aggregate stats for small size classes, based on bin stats. */
     47 	size_t			allocated_small;
     48 	uint64_t		nmalloc_small;
     49 	uint64_t		ndalloc_small;
     50 	uint64_t		nrequests_small;
     51 
     52 	malloc_bin_stats_t	bstats[NBINS];
     53 	malloc_large_stats_t	*lstats;	/* nlclasses elements. */
     54 	malloc_huge_stats_t	*hstats;	/* nhclasses elements. */
     55 };
     56 
     57 struct ctl_stats_s {
     58 	size_t			allocated;
     59 	size_t			active;
     60 	size_t			metadata;
     61 	size_t			resident;
     62 	size_t			mapped;
     63 	unsigned		narenas;
     64 	ctl_arena_stats_t	*arenas;	/* (narenas + 1) elements. */
     65 };
     66 
     67 #endif /* JEMALLOC_H_STRUCTS */
     68 /******************************************************************************/
     69 #ifdef JEMALLOC_H_EXTERNS
     70 
     71 int	ctl_byname(const char *name, void *oldp, size_t *oldlenp, void *newp,
     72     size_t newlen);
     73 int	ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp);
     74 
     75 int	ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
     76     void *newp, size_t newlen);
     77 bool	ctl_boot(void);
     78 void	ctl_prefork(void);
     79 void	ctl_postfork_parent(void);
     80 void	ctl_postfork_child(void);
     81 
     82 #define	xmallctl(name, oldp, oldlenp, newp, newlen) do {		\
     83 	if (je_mallctl(name, oldp, oldlenp, newp, newlen)		\
     84 	    != 0) {							\
     85 		malloc_printf(						\
     86 		    "<jemalloc>: Failure in xmallctl(\"%s\", ...)\n",	\
     87 		    name);						\
     88 		abort();						\
     89 	}								\
     90 } while (0)
     91 
     92 #define	xmallctlnametomib(name, mibp, miblenp) do {			\
     93 	if (je_mallctlnametomib(name, mibp, miblenp) != 0) {		\
     94 		malloc_printf("<jemalloc>: Failure in "			\
     95 		    "xmallctlnametomib(\"%s\", ...)\n", name);		\
     96 		abort();						\
     97 	}								\
     98 } while (0)
     99 
    100 #define	xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do {	\
    101 	if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp,		\
    102 	    newlen) != 0) {						\
    103 		malloc_write(						\
    104 		    "<jemalloc>: Failure in xmallctlbymib()\n");	\
    105 		abort();						\
    106 	}								\
    107 } while (0)
    108 
    109 #endif /* JEMALLOC_H_EXTERNS */
    110 /******************************************************************************/
    111 #ifdef JEMALLOC_H_INLINES
    112 
    113 #endif /* JEMALLOC_H_INLINES */
    114 /******************************************************************************/
    115 
    116