summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-01-04 01:21:59 (GMT)
committerJason Evans <jasone@canonware.com>2017-01-07 02:58:46 (GMT)
commitedf1bafb2b36ef4e8a2ef1ac19a4f76e5bc42528 (patch)
tree55512f1f1a6599756dac8d014f1826afd3cb3795 /include
parent3f291d59ada15f2be84c80dac71e0ddf03908d15 (diff)
downloadjemalloc-edf1bafb2b36ef4e8a2ef1ac19a4f76e5bc42528.zip
jemalloc-edf1bafb2b36ef4e8a2ef1ac19a4f76e5bc42528.tar.gz
jemalloc-edf1bafb2b36ef4e8a2ef1ac19a4f76e5bc42528.tar.bz2
Implement arena.<i>.destroy .
Add MALLCTL_ARENAS_DESTROYED for accessing destroyed arena stats as an analogue to MALLCTL_ARENAS_ALL. This resolves #382.
Diffstat (limited to 'include')
-rw-r--r--include/jemalloc/internal/arena.h1
-rw-r--r--include/jemalloc/internal/ctl.h12
-rw-r--r--include/jemalloc/internal/extent.h2
-rw-r--r--include/jemalloc/internal/jemalloc_internal.h.in2
-rw-r--r--include/jemalloc/internal/private_symbols.txt3
-rw-r--r--include/jemalloc/jemalloc_macros.h.in5
6 files changed, 24 insertions, 1 deletions
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index 929adbe..5e29550 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -290,6 +290,7 @@ bool arena_decay_time_set(tsdn_t *tsdn, arena_t *arena, ssize_t decay_time);
void arena_purge(tsdn_t *tsdn, arena_t *arena, bool all);
void arena_maybe_purge(tsdn_t *tsdn, arena_t *arena);
void arena_reset(tsd_t *tsd, arena_t *arena);
+void arena_destroy(tsd_t *tsd, arena_t *arena);
void arena_tcache_fill_small(tsdn_t *tsdn, arena_t *arena,
tcache_bin_t *tbin, szind_t binind, uint64_t prof_accumbytes);
void arena_alloc_junk_small(void *ptr, const arena_bin_info_t *bin_info,
diff --git a/include/jemalloc/internal/ctl.h b/include/jemalloc/internal/ctl.h
index 0aa8254..7dc3e5b 100644
--- a/include/jemalloc/internal/ctl.h
+++ b/include/jemalloc/internal/ctl.h
@@ -32,7 +32,10 @@ struct ctl_indexed_node_s {
};
struct ctl_arena_stats_s {
+ unsigned arena_ind;
bool initialized;
+ ql_elm(ctl_arena_stats_t) destroyed_link;
+
unsigned nthreads;
const char *dss;
ssize_t decay_time;
@@ -62,7 +65,14 @@ struct ctl_stats_s {
size_t mapped;
size_t retained;
unsigned narenas;
- ctl_arena_stats_t *arenas[1 << MALLOCX_ARENA_BITS];
+ ql_head(ctl_arena_stats_t) destroyed;
+ /*
+ * Element 0 contains merged stats for extant arenas (accessed via
+ * MALLCTL_ARENAS_ALL), element 1 contains merged stats for destroyed
+ * arenas (accessed via MALLCTL_ARENAS_DESTROYED), and the remaining
+ * MALLOCX_ARENA_MAX+1 elements correspond to arenas.
+ */
+ ctl_arena_stats_t *arenas[MALLOCX_ARENA_MAX + 3];
};
#endif /* JEMALLOC_H_STRUCTS */
diff --git a/include/jemalloc/internal/extent.h b/include/jemalloc/internal/extent.h
index 33b8514..70accff 100644
--- a/include/jemalloc/internal/extent.h
+++ b/include/jemalloc/internal/extent.h
@@ -125,6 +125,8 @@ extent_t *extent_alloc_wrapper(tsdn_t *tsdn, arena_t *arena,
void extent_dalloc_gap(tsdn_t *tsdn, arena_t *arena, extent_t *extent);
void extent_dalloc_cache(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, extent_t *extent);
+bool extent_dalloc_wrapper_try(tsdn_t *tsdn, arena_t *arena,
+ extent_hooks_t **r_extent_hooks, extent_t *extent);
void extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, extent_t *extent);
bool extent_commit_wrapper(tsdn_t *tsdn, arena_t *arena,
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
index 991c541..6395d75 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -215,6 +215,7 @@ typedef unsigned szind_t;
#define MALLOCX_TCACHE_SHIFT 8
#define MALLOCX_ARENA_MASK \
(((1 << MALLOCX_ARENA_BITS) - 1) << MALLOCX_ARENA_SHIFT)
+/* NB: Arena index bias decreases the maximum number of arenas by 1. */
#define MALLOCX_ARENA_MAX ((1 << MALLOCX_ARENA_BITS) - 2)
#define MALLOCX_TCACHE_MASK \
(((1 << MALLOCX_TCACHE_BITS) - 1) << MALLOCX_TCACHE_SHIFT)
@@ -470,6 +471,7 @@ void a0dalloc(void *ptr);
void *bootstrap_malloc(size_t size);
void *bootstrap_calloc(size_t num, size_t size);
void bootstrap_free(void *ptr);
+void arena_set(unsigned ind, arena_t *arena);
unsigned narenas_total_get(void);
arena_t *arena_init(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks);
arena_tdata_t *arena_tdata_get_hard(tsd_t *tsd, unsigned ind);
diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt
index 36960f0..c85219a 100644
--- a/include/jemalloc/internal/private_symbols.txt
+++ b/include/jemalloc/internal/private_symbols.txt
@@ -21,6 +21,7 @@ arena_decay_time_default_get
arena_decay_time_default_set
arena_decay_time_get
arena_decay_time_set
+arena_destroy
arena_dss_prec_get
arena_dss_prec_set
arena_extent_alloc_large
@@ -67,6 +68,7 @@ arena_ralloc_no_move
arena_reset
arena_salloc
arena_sdalloc
+arena_set
arena_slab_regind
arena_stats_merge
arena_tcache_fill_small
@@ -164,6 +166,7 @@ extent_dalloc_cache
extent_dalloc_gap
extent_dalloc_mmap
extent_dalloc_wrapper
+extent_dalloc_wrapper_try
extent_decommit_wrapper
extent_dss_boot
extent_dss_mergeable
diff --git a/include/jemalloc/jemalloc_macros.h.in b/include/jemalloc/jemalloc_macros.h.in
index ea41e2e..05bcdd7 100644
--- a/include/jemalloc/jemalloc_macros.h.in
+++ b/include/jemalloc/jemalloc_macros.h.in
@@ -44,6 +44,11 @@
* 0);
*/
#define MALLCTL_ARENAS_ALL 4096
+/*
+ * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
+ * destroyed arenas.
+ */
+#define MALLCTL_ARENAS_DESTROYED 4097
#if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
# define JEMALLOC_CXX_THROW throw()