2017-04-25 08:09:56 +08:00
|
|
|
#ifndef JEMALLOC_INTERNAL_CTL_H
|
|
|
|
#define JEMALLOC_INTERNAL_CTL_H
|
|
|
|
|
2023-06-10 08:37:47 +08:00
|
|
|
#include "jemalloc/internal/jemalloc_preamble.h"
|
|
|
|
#include "jemalloc/internal/arena_stats.h"
|
|
|
|
#include "jemalloc/internal/background_thread_structs.h"
|
|
|
|
#include "jemalloc/internal/bin_stats.h"
|
2017-04-25 08:09:56 +08:00
|
|
|
#include "jemalloc/internal/jemalloc_internal_types.h"
|
|
|
|
#include "jemalloc/internal/malloc_io.h"
|
|
|
|
#include "jemalloc/internal/mutex_prof.h"
|
|
|
|
#include "jemalloc/internal/ql.h"
|
2017-12-15 04:46:39 +08:00
|
|
|
#include "jemalloc/internal/sc.h"
|
2017-04-25 08:09:56 +08:00
|
|
|
#include "jemalloc/internal/stats.h"
|
|
|
|
|
|
|
|
/* Maximum ctl tree depth. */
|
|
|
|
#define CTL_MAX_DEPTH 7
|
2023-09-20 05:37:09 +08:00
|
|
|
#define CTL_MULTI_SETTING_MAX_LEN 1000
|
2017-04-25 08:09:56 +08:00
|
|
|
|
|
|
|
typedef struct ctl_node_s {
|
|
|
|
bool named;
|
|
|
|
} ctl_node_t;
|
|
|
|
|
|
|
|
typedef struct ctl_named_node_s {
|
|
|
|
ctl_node_t node;
|
|
|
|
const char *name;
|
|
|
|
/* If (nchildren == 0), this is a terminal node. */
|
|
|
|
size_t nchildren;
|
|
|
|
const ctl_node_t *children;
|
|
|
|
int (*ctl)(tsd_t *, const size_t *, size_t, void *, size_t *, void *,
|
|
|
|
size_t);
|
|
|
|
} ctl_named_node_t;
|
|
|
|
|
|
|
|
typedef struct ctl_indexed_node_s {
|
|
|
|
struct ctl_node_s node;
|
|
|
|
const ctl_named_node_t *(*index)(tsdn_t *, const size_t *, size_t,
|
|
|
|
size_t);
|
|
|
|
} ctl_indexed_node_t;
|
|
|
|
|
|
|
|
typedef struct ctl_arena_stats_s {
|
|
|
|
arena_stats_t astats;
|
|
|
|
|
|
|
|
/* Aggregate stats for small size classes, based on bin stats. */
|
|
|
|
size_t allocated_small;
|
|
|
|
uint64_t nmalloc_small;
|
|
|
|
uint64_t ndalloc_small;
|
|
|
|
uint64_t nrequests_small;
|
2019-05-07 07:36:55 +08:00
|
|
|
uint64_t nfills_small;
|
|
|
|
uint64_t nflushes_small;
|
2017-04-25 08:09:56 +08:00
|
|
|
|
2019-11-06 12:43:59 +08:00
|
|
|
bin_stats_data_t bstats[SC_NBINS];
|
2017-12-15 04:46:39 +08:00
|
|
|
arena_stats_large_t lstats[SC_NSIZES - SC_NBINS];
|
2020-06-02 08:42:27 +08:00
|
|
|
pac_estats_t estats[SC_NPSIZES];
|
2020-09-05 03:01:52 +08:00
|
|
|
hpa_shard_stats_t hpastats;
|
2020-10-17 04:14:59 +08:00
|
|
|
sec_stats_t secstats;
|
2017-04-25 08:09:56 +08:00
|
|
|
} ctl_arena_stats_t;
|
|
|
|
|
|
|
|
typedef struct ctl_stats_s {
|
|
|
|
size_t allocated;
|
|
|
|
size_t active;
|
|
|
|
size_t metadata;
|
2023-10-11 00:46:23 +08:00
|
|
|
size_t metadata_edata;
|
|
|
|
size_t metadata_rtree;
|
2017-08-26 04:24:49 +08:00
|
|
|
size_t metadata_thp;
|
2017-04-25 08:09:56 +08:00
|
|
|
size_t resident;
|
|
|
|
size_t mapped;
|
|
|
|
size_t retained;
|
|
|
|
|
2017-05-13 03:30:33 +08:00
|
|
|
background_thread_stats_t background_thread;
|
2017-04-25 08:09:56 +08:00
|
|
|
mutex_prof_data_t mutex_prof_data[mutex_prof_num_global_mutexes];
|
|
|
|
} ctl_stats_t;
|
|
|
|
|
|
|
|
typedef struct ctl_arena_s ctl_arena_t;
|
|
|
|
struct ctl_arena_s {
|
|
|
|
unsigned arena_ind;
|
|
|
|
bool initialized;
|
|
|
|
ql_elm(ctl_arena_t) destroyed_link;
|
|
|
|
|
|
|
|
/* Basic stats, supported even if !config_stats. */
|
|
|
|
unsigned nthreads;
|
|
|
|
const char *dss;
|
2017-05-18 01:47:00 +08:00
|
|
|
ssize_t dirty_decay_ms;
|
|
|
|
ssize_t muzzy_decay_ms;
|
2017-04-25 08:09:56 +08:00
|
|
|
size_t pactive;
|
|
|
|
size_t pdirty;
|
|
|
|
size_t pmuzzy;
|
|
|
|
|
|
|
|
/* NULL if !config_stats. */
|
|
|
|
ctl_arena_stats_t *astats;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct ctl_arenas_s {
|
|
|
|
uint64_t epoch;
|
|
|
|
unsigned narenas;
|
|
|
|
ql_head(ctl_arena_t) destroyed;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Element 0 corresponds to merged stats for extant arenas (accessed via
|
|
|
|
* MALLCTL_ARENAS_ALL), element 1 corresponds to merged stats for
|
|
|
|
* destroyed arenas (accessed via MALLCTL_ARENAS_DESTROYED), and the
|
2017-05-14 06:20:48 +08:00
|
|
|
* remaining MALLOCX_ARENA_LIMIT elements correspond to arenas.
|
2017-04-25 08:09:56 +08:00
|
|
|
*/
|
2017-05-14 06:20:48 +08:00
|
|
|
ctl_arena_t *arenas[2 + MALLOCX_ARENA_LIMIT];
|
2017-04-25 08:09:56 +08:00
|
|
|
} ctl_arenas_t;
|
|
|
|
|
|
|
|
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
|
|
|
void *newp, size_t newlen);
|
2017-06-23 09:58:40 +08:00
|
|
|
int ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp);
|
2017-04-25 08:09:56 +08:00
|
|
|
int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|
|
|
size_t *oldlenp, void *newp, size_t newlen);
|
2020-08-14 02:28:22 +08:00
|
|
|
int ctl_mibnametomib(tsd_t *tsd, size_t *mib, size_t miblen, const char *name,
|
|
|
|
size_t *miblenp);
|
2020-08-14 06:26:46 +08:00
|
|
|
int ctl_bymibname(tsd_t *tsd, size_t *mib, size_t miblen, const char *name,
|
|
|
|
size_t *miblenp, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
2017-04-25 08:09:56 +08:00
|
|
|
bool ctl_boot(void);
|
|
|
|
void ctl_prefork(tsdn_t *tsdn);
|
|
|
|
void ctl_postfork_parent(tsdn_t *tsdn);
|
|
|
|
void ctl_postfork_child(tsdn_t *tsdn);
|
2019-09-10 11:18:41 +08:00
|
|
|
void ctl_mtx_assert_held(tsdn_t *tsdn);
|
2017-04-25 08:09:56 +08:00
|
|
|
|
|
|
|
#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \
|
|
|
|
if (je_mallctl(name, oldp, oldlenp, newp, newlen) \
|
|
|
|
!= 0) { \
|
|
|
|
malloc_printf( \
|
|
|
|
"<jemalloc>: Failure in xmallctl(\"%s\", ...)\n", \
|
|
|
|
name); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define xmallctlnametomib(name, mibp, miblenp) do { \
|
|
|
|
if (je_mallctlnametomib(name, mibp, miblenp) != 0) { \
|
|
|
|
malloc_printf("<jemalloc>: Failure in " \
|
|
|
|
"xmallctlnametomib(\"%s\", ...)\n", name); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \
|
|
|
|
if (je_mallctlbymib(mib, miblen, oldp, oldlenp, newp, \
|
|
|
|
newlen) != 0) { \
|
|
|
|
malloc_write( \
|
|
|
|
"<jemalloc>: Failure in xmallctlbymib()\n"); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2020-12-18 06:01:56 +08:00
|
|
|
#define xmallctlmibnametomib(mib, miblen, name, miblenp) do { \
|
|
|
|
if (ctl_mibnametomib(tsd_fetch(), mib, miblen, name, miblenp) \
|
|
|
|
!= 0) { \
|
|
|
|
malloc_write( \
|
|
|
|
"<jemalloc>: Failure in ctl_mibnametomib()\n"); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define xmallctlbymibname(mib, miblen, name, miblenp, oldp, oldlenp, \
|
|
|
|
newp, newlen) do { \
|
|
|
|
if (ctl_bymibname(tsd_fetch(), mib, miblen, name, miblenp, \
|
|
|
|
oldp, oldlenp, newp, newlen) != 0) { \
|
|
|
|
malloc_write( \
|
|
|
|
"<jemalloc>: Failure in ctl_bymibname()\n"); \
|
|
|
|
abort(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2017-04-25 08:09:56 +08:00
|
|
|
#endif /* JEMALLOC_INTERNAL_CTL_H */
|