From 7be2ebc23f0f145e095e7230d7d8a202b8dcc55e Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Thu, 2 Jun 2016 11:11:35 -0700 Subject: Make tsd cleanup functions optional, remove noop cleanup functions. --- include/jemalloc/internal/jemalloc_internal.h.in | 4 --- include/jemalloc/internal/private_symbols.txt | 7 ----- include/jemalloc/internal/rtree.h | 1 - include/jemalloc/internal/tcache.h | 1 - include/jemalloc/internal/tsd.h | 34 ++++++++++++------------ include/jemalloc/internal/witness.h | 1 - src/jemalloc.c | 28 ------------------- src/rtree.c | 7 ----- src/tcache.c | 7 ----- src/tsd.c | 7 ++++- src/witness.c | 7 ----- 11 files changed, 23 insertions(+), 81 deletions(-) diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in index 176487e..5b809bf 100644 --- a/include/jemalloc/internal/jemalloc_internal.h.in +++ b/include/jemalloc/internal/jemalloc_internal.h.in @@ -455,13 +455,9 @@ arena_t *arena_init(tsdn_t *tsdn, unsigned ind); arena_tdata_t *arena_tdata_get_hard(tsd_t *tsd, unsigned ind); arena_t *arena_choose_hard(tsd_t *tsd, bool internal); void arena_migrate(tsd_t *tsd, unsigned oldind, unsigned newind); -void thread_allocated_cleanup(tsd_t *tsd); -void thread_deallocated_cleanup(tsd_t *tsd); void iarena_cleanup(tsd_t *tsd); void arena_cleanup(tsd_t *tsd); void arenas_tdata_cleanup(tsd_t *tsd); -void narenas_tdata_cleanup(tsd_t *tsd); -void arenas_tdata_bypass_cleanup(tsd_t *tsd); void jemalloc_prefork(void); void jemalloc_postfork_parent(void); void jemalloc_postfork_child(void); diff --git a/include/jemalloc/internal/private_symbols.txt b/include/jemalloc/internal/private_symbols.txt index be81d74..d4e5525 100644 --- a/include/jemalloc/internal/private_symbols.txt +++ b/include/jemalloc/internal/private_symbols.txt @@ -74,7 +74,6 @@ arena_tcache_fill_small arena_tdata_get arena_tdata_get_hard arenas -arenas_tdata_bypass_cleanup arenas_tdata_cleanup atomic_add_p atomic_add_u @@ -285,7 +284,6 @@ malloc_vsnprintf malloc_write mb_write narenas_auto -narenas_tdata_cleanup narenas_total_get ncpus nhbins @@ -410,7 +408,6 @@ rtree_elm_release rtree_elm_witness_access rtree_elm_witness_acquire rtree_elm_witness_release -rtree_elm_witnesses_cleanup rtree_elm_write rtree_elm_write_acquired rtree_new @@ -451,7 +448,6 @@ tcache_cleanup tcache_create tcache_dalloc_large tcache_dalloc_small -tcache_enabled_cleanup tcache_enabled_get tcache_enabled_set tcache_event @@ -467,8 +463,6 @@ tcaches_create tcaches_destroy tcaches_flush tcaches_get -thread_allocated_cleanup -thread_deallocated_cleanup ticker_copy ticker_init ticker_read @@ -539,7 +533,6 @@ tsdn_tsd witness_assert_lockless witness_assert_not_owner witness_assert_owner -witness_fork_cleanup witness_init witness_lock witness_lock_error diff --git a/include/jemalloc/internal/rtree.h b/include/jemalloc/internal/rtree.h index af52f9f..a47a79e 100644 --- a/include/jemalloc/internal/rtree.h +++ b/include/jemalloc/internal/rtree.h @@ -137,7 +137,6 @@ void rtree_elm_witness_access(tsdn_t *tsdn, const rtree_t *rtree, const rtree_elm_t *elm); void rtree_elm_witness_release(tsdn_t *tsdn, const rtree_t *rtree, const rtree_elm_t *elm); -void rtree_elm_witnesses_cleanup(tsd_t *tsd); #endif /* JEMALLOC_H_EXTERNS */ /******************************************************************************/ diff --git a/include/jemalloc/internal/tcache.h b/include/jemalloc/internal/tcache.h index e7606d6..933255c 100644 --- a/include/jemalloc/internal/tcache.h +++ b/include/jemalloc/internal/tcache.h @@ -143,7 +143,6 @@ void tcache_arena_reassociate(tsdn_t *tsdn, tcache_t *tcache, tcache_t *tcache_get_hard(tsd_t *tsd); tcache_t *tcache_create(tsdn_t *tsdn, arena_t *arena); void tcache_cleanup(tsd_t *tsd); -void tcache_enabled_cleanup(tsd_t *tsd); void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena); bool tcaches_create(tsdn_t *tsdn, unsigned *r_ind); void tcaches_flush(tsd_t *tsd, unsigned ind); diff --git a/include/jemalloc/internal/tsd.h b/include/jemalloc/internal/tsd.h index ca8915e..988edf5 100644 --- a/include/jemalloc/internal/tsd.h +++ b/include/jemalloc/internal/tsd.h @@ -561,20 +561,20 @@ struct tsd_init_head_s { #endif #define MALLOC_TSD \ -/* O(name, type) */ \ - O(tcache, tcache_t *) \ - O(thread_allocated, uint64_t) \ - O(thread_deallocated, uint64_t) \ - O(prof_tdata, prof_tdata_t *) \ - O(iarena, arena_t *) \ - O(arena, arena_t *) \ - O(arenas_tdata, arena_tdata_t *) \ - O(narenas_tdata, unsigned) \ - O(arenas_tdata_bypass, bool) \ - O(tcache_enabled, tcache_enabled_t) \ - O(witnesses, witness_list_t) \ - O(rtree_elm_witnesses, rtree_elm_witness_tsd_t) \ - O(witness_fork, bool) \ +/* O(name, type, cleanup) */ \ + O(tcache, tcache_t *, yes) \ + O(thread_allocated, uint64_t, no) \ + O(thread_deallocated, uint64_t, no) \ + O(prof_tdata, prof_tdata_t *, yes) \ + O(iarena, arena_t *, yes) \ + O(arena, arena_t *, yes) \ + O(arenas_tdata, arena_tdata_t *, yes) \ + O(narenas_tdata, unsigned, no) \ + O(arenas_tdata_bypass, bool, no) \ + O(tcache_enabled, tcache_enabled_t, no) \ + O(witnesses, witness_list_t, yes) \ + O(rtree_elm_witnesses, rtree_elm_witness_tsd_t,no) \ + O(witness_fork, bool, no) \ #define TSD_INITIALIZER { \ tsd_state_uninitialized, \ @@ -595,7 +595,7 @@ struct tsd_init_head_s { struct tsd_s { tsd_state_t state; -#define O(n, t) \ +#define O(n, t, c) \ t n; MALLOC_TSD #undef O @@ -642,7 +642,7 @@ malloc_tsd_protos(JEMALLOC_ATTR(unused), , tsd_t) tsd_t *tsd_fetch(void); tsdn_t *tsd_tsdn(tsd_t *tsd); bool tsd_nominal(tsd_t *tsd); -#define O(n, t) \ +#define O(n, t, c) \ t *tsd_##n##p_get(tsd_t *tsd); \ t tsd_##n##_get(tsd_t *tsd); \ void tsd_##n##_set(tsd_t *tsd, t n); @@ -691,7 +691,7 @@ tsd_nominal(tsd_t *tsd) return (tsd->state == tsd_state_nominal); } -#define O(n, t) \ +#define O(n, t, c) \ JEMALLOC_ALWAYS_INLINE t * \ tsd_##n##p_get(tsd_t *tsd) \ { \ diff --git a/include/jemalloc/internal/witness.h b/include/jemalloc/internal/witness.h index e2f8563..9a2a676 100644 --- a/include/jemalloc/internal/witness.h +++ b/include/jemalloc/internal/witness.h @@ -103,7 +103,6 @@ void witness_lockless_error(const witness_list_t *witnesses); #endif void witnesses_cleanup(tsd_t *tsd); -void witness_fork_cleanup(tsd_t *tsd); void witness_prefork(tsd_t *tsd); void witness_postfork_parent(tsd_t *tsd); void witness_postfork_child(tsd_t *tsd); diff --git a/src/jemalloc.c b/src/jemalloc.c index 2d33464..1007401 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -645,20 +645,6 @@ arena_choose_hard(tsd_t *tsd, bool internal) } void -thread_allocated_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void -thread_deallocated_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void iarena_cleanup(tsd_t *tsd) { arena_t *iarena; @@ -693,20 +679,6 @@ arenas_tdata_cleanup(tsd_t *tsd) } } -void -narenas_tdata_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void -arenas_tdata_bypass_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - static void stats_print_atexit(void) { diff --git a/src/rtree.c b/src/rtree.c index 504f9f2..b602730 100644 --- a/src/rtree.c +++ b/src/rtree.c @@ -285,10 +285,3 @@ rtree_elm_witness_release(tsdn_t *tsdn, const rtree_t *rtree, witness_unlock(tsdn, witness); rtree_elm_witness_dalloc(tsdn_tsd(tsdn), witness, elm); } - -void -rtree_elm_witnesses_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} diff --git a/src/tcache.c b/src/tcache.c index 69444fa..96e54e1 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -405,13 +405,6 @@ tcache_cleanup(tsd_t *tsd) } void -tcache_enabled_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena) { unsigned i; diff --git a/src/tsd.c b/src/tsd.c index ec69a51..5d9fc9f 100644 --- a/src/tsd.c +++ b/src/tsd.c @@ -77,9 +77,14 @@ tsd_cleanup(void *arg) /* Do nothing. */ break; case tsd_state_nominal: -#define O(n, t) \ +#define MALLOC_TSD_cleanup_yes(n, t) \ n##_cleanup(tsd); +#define MALLOC_TSD_cleanup_no(n, t) +#define O(n, t, c) \ + MALLOC_TSD_cleanup_##c(n, t) MALLOC_TSD +#undef MALLOC_TSD_cleanup_yes +#undef MALLOC_TSD_cleanup_no #undef O tsd->state = tsd_state_purgatory; tsd_set(tsd); diff --git a/src/witness.c b/src/witness.c index 8efff56..0f5c0d7 100644 --- a/src/witness.c +++ b/src/witness.c @@ -104,13 +104,6 @@ witnesses_cleanup(tsd_t *tsd) } void -witness_fork_cleanup(tsd_t *tsd) -{ - - /* Do nothing. */ -} - -void witness_prefork(tsd_t *tsd) { -- cgit v0.12