mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-15 09:26:21 +03:00
Remove obsolete TSD nominal list
This commit is contained in:
parent
42e671433f
commit
cec4e84c02
3 changed files with 10 additions and 111 deletions
|
|
@ -10,7 +10,6 @@
|
|||
#include "jemalloc/internal/jemalloc_internal_externs.h"
|
||||
#include "jemalloc/internal/peak.h"
|
||||
#include "jemalloc/internal/prof_types.h"
|
||||
#include "jemalloc/internal/ql.h"
|
||||
#include "jemalloc/internal/rtree_tsd.h"
|
||||
#include "jemalloc/internal/tcache_structs.h"
|
||||
#include "jemalloc/internal/tcache_types.h"
|
||||
|
|
@ -57,8 +56,6 @@ typedef void (*test_callback_t)(int *);
|
|||
# define MALLOC_TEST_TSD_INITIALIZER
|
||||
#endif
|
||||
|
||||
typedef ql_elm(tsd_t) tsd_link_t;
|
||||
|
||||
/* O(name, type, nullable type) */
|
||||
#define TSD_DATA_SLOW \
|
||||
O(tcache_enabled, bool, bool) \
|
||||
|
|
@ -80,7 +77,6 @@ typedef ql_elm(tsd_t) tsd_link_t;
|
|||
O(arena_decay_ticker, ticker_geom_t, ticker_geom_t) \
|
||||
O(sec_shard, uint8_t, uint8_t) \
|
||||
O(binshards, tsd_binshards_t, tsd_binshards_t) \
|
||||
O(tsd_link, tsd_link_t, tsd_link_t) \
|
||||
O(peak, peak_t, peak_t) \
|
||||
O(tcache_slow, tcache_slow_t, tcache_slow_t) \
|
||||
O(rtree_ctx, rtree_ctx_t, rtree_ctx_t)
|
||||
|
|
@ -100,8 +96,8 @@ typedef ql_elm(tsd_t) tsd_link_t;
|
|||
TICKER_GEOM_INIT(ARENA_DECAY_NTICKS_PER_UPDATE), \
|
||||
/* sec_shard */ (uint8_t) - 1, \
|
||||
/* binshards */ TSD_BINSHARDS_ZERO_INITIALIZER, \
|
||||
/* tsd_link */ {NULL}, /* peak */ PEAK_INITIALIZER, \
|
||||
/* tcache_slow */ TCACHE_SLOW_ZERO_INITIALIZER, \
|
||||
/* peak */ PEAK_INITIALIZER, /* tcache_slow */ \
|
||||
TCACHE_SLOW_ZERO_INITIALIZER, \
|
||||
/* rtree_ctx */ RTREE_CTX_INITIALIZER,
|
||||
|
||||
/* O(name, type, nullable type) */
|
||||
|
|
@ -146,9 +142,6 @@ void tsd_cleanup(void *arg);
|
|||
tsd_t *tsd_fetch_slow(tsd_t *tsd, bool minimal);
|
||||
void tsd_state_set(tsd_t *tsd, uint8_t new_state);
|
||||
void tsd_slow_update(tsd_t *tsd);
|
||||
void tsd_prefork(tsd_t *tsd);
|
||||
void tsd_postfork_parent(tsd_t *tsd);
|
||||
void tsd_postfork_child(tsd_t *tsd);
|
||||
|
||||
#define TSD_MIN_INIT_STATE_MAX_FETCHED (128)
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ _malloc_prefork(void)
|
|||
}
|
||||
prof_prefork1(tsd_tsdn(tsd));
|
||||
stats_prefork(tsd_tsdn(tsd));
|
||||
tsd_prefork(tsd);
|
||||
}
|
||||
|
||||
#ifndef JEMALLOC_MUTEX_INIT_CB
|
||||
|
|
@ -111,8 +110,6 @@ _malloc_postfork(void)
|
|||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
tsd_postfork_parent(tsd);
|
||||
|
||||
witness_postfork_parent(tsd_witness_tsdp_get(tsd));
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
stats_postfork_parent(tsd_tsdn(tsd));
|
||||
|
|
@ -141,8 +138,6 @@ jemalloc_postfork_child(void) {
|
|||
|
||||
tsd = tsd_fetch();
|
||||
|
||||
tsd_postfork_child(tsd);
|
||||
|
||||
witness_postfork_child(tsd_witness_tsdp_get(tsd));
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
stats_postfork_child(tsd_tsdn(tsd));
|
||||
|
|
|
|||
105
src/tsd.c
105
src/tsd.c
|
|
@ -56,51 +56,6 @@ bool tsd_booted = false;
|
|||
|
||||
JEMALLOC_DIAGNOSTIC_POP
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* A list of all the tsds in the nominal state. */
|
||||
typedef ql_head(tsd_t) tsd_list_t;
|
||||
static tsd_list_t tsd_nominal_tsds = ql_head_initializer(tsd_nominal_tsds);
|
||||
static malloc_mutex_t tsd_nominal_tsds_lock;
|
||||
|
||||
static bool
|
||||
tsd_in_nominal_list(tsd_t *tsd) {
|
||||
tsd_t *tsd_list;
|
||||
bool found = false;
|
||||
/*
|
||||
* We don't know that tsd is nominal; it might not be safe to get data
|
||||
* out of it here.
|
||||
*/
|
||||
malloc_mutex_lock(TSDN_NULL, &tsd_nominal_tsds_lock);
|
||||
ql_foreach (tsd_list, &tsd_nominal_tsds, TSD_MANGLE(tsd_link)) {
|
||||
if (tsd == tsd_list) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
malloc_mutex_unlock(TSDN_NULL, &tsd_nominal_tsds_lock);
|
||||
return found;
|
||||
}
|
||||
|
||||
static void
|
||||
tsd_add_nominal(tsd_t *tsd) {
|
||||
assert(!tsd_in_nominal_list(tsd));
|
||||
assert(tsd_state_get(tsd) <= tsd_state_nominal_max);
|
||||
ql_elm_new(tsd, TSD_MANGLE(tsd_link));
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
ql_tail_insert(&tsd_nominal_tsds, tsd, TSD_MANGLE(tsd_link));
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
static void
|
||||
tsd_remove_nominal(tsd_t *tsd) {
|
||||
assert(tsd_in_nominal_list(tsd));
|
||||
assert(tsd_state_get(tsd) <= tsd_state_nominal_max);
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
ql_remove(&tsd_nominal_tsds, tsd, TSD_MANGLE(tsd_link));
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
static bool
|
||||
tsd_local_slow(tsd_t *tsd) {
|
||||
return !tsd_tcache_enabled_get(tsd)
|
||||
|
|
@ -136,36 +91,17 @@ tsd_state_set(tsd_t *tsd, uint8_t new_state) {
|
|||
assert(!tsd_booted_get() || tsd_get(false) == tsd
|
||||
|| (tsd_get_allocates() && tsd_get(false) == NULL));
|
||||
uint8_t old_state = tsd_atomic_load(&tsd->state, ATOMIC_RELAXED);
|
||||
if (old_state > tsd_state_nominal_max) {
|
||||
if (old_state <= tsd_state_nominal_max
|
||||
&& new_state <= tsd_state_nominal_max) {
|
||||
/*
|
||||
* Not currently in the nominal list, but it might need to be
|
||||
* inserted there.
|
||||
* We're transitioning from one nominal state to another.
|
||||
* Recompute the state from the underlying slow-path data rather
|
||||
* than trusting the caller's requested nominal state.
|
||||
*/
|
||||
assert(!tsd_in_nominal_list(tsd));
|
||||
tsd_atomic_store(&tsd->state, new_state, ATOMIC_RELAXED);
|
||||
if (new_state <= tsd_state_nominal_max) {
|
||||
tsd_add_nominal(tsd);
|
||||
}
|
||||
tsd_slow_update(tsd);
|
||||
return;
|
||||
} else {
|
||||
/*
|
||||
* We're currently nominal. If the new state is non-nominal,
|
||||
* great; we take ourselves off the list and just enter the new
|
||||
* state.
|
||||
*/
|
||||
assert(tsd_in_nominal_list(tsd));
|
||||
if (new_state > tsd_state_nominal_max) {
|
||||
tsd_remove_nominal(tsd);
|
||||
tsd_atomic_store(
|
||||
&tsd->state, new_state, ATOMIC_RELAXED);
|
||||
} else {
|
||||
/*
|
||||
* We're transitioning from one nominal state to
|
||||
* another. Recompute the state from the underlying
|
||||
* slow-path data rather than trusting the caller's
|
||||
* requested nominal state.
|
||||
*/
|
||||
tsd_slow_update(tsd);
|
||||
}
|
||||
tsd_atomic_store(&tsd->state, new_state, ATOMIC_RELAXED);
|
||||
}
|
||||
te_recompute_fast_threshold(tsd);
|
||||
}
|
||||
|
|
@ -198,7 +134,6 @@ tsd_data_init(tsd_t *tsd) {
|
|||
static void
|
||||
assert_tsd_data_cleanup_done(tsd_t *tsd) {
|
||||
assert(!tsd_nominal(tsd));
|
||||
assert(!tsd_in_nominal_list(tsd));
|
||||
assert(*tsd_arenap_get_unsafe(tsd) == NULL);
|
||||
assert(*tsd_iarenap_get_unsafe(tsd) == NULL);
|
||||
assert(*tsd_tcache_enabledp_get_unsafe(tsd) == false);
|
||||
|
|
@ -400,10 +335,6 @@ malloc_tsd_boot0(void) {
|
|||
#if defined(JEMALLOC_MALLOC_THREAD_CLEANUP) || defined(_WIN32)
|
||||
ncleanups = 0;
|
||||
#endif
|
||||
if (malloc_mutex_init(&tsd_nominal_tsds_lock, "tsd_nominal_tsds_lock",
|
||||
WITNESS_RANK_OMIT, malloc_mutex_rank_exclusive)) {
|
||||
return NULL;
|
||||
}
|
||||
if (tsd_boot0()) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -492,23 +423,3 @@ tsd_init_finish(tsd_init_head_t *head, tsd_init_block_t *block) {
|
|||
malloc_mutex_unlock(TSDN_NULL, &head->lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
tsd_prefork(tsd_t *tsd) {
|
||||
malloc_mutex_prefork(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
void
|
||||
tsd_postfork_parent(tsd_t *tsd) {
|
||||
malloc_mutex_postfork_parent(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
}
|
||||
|
||||
void
|
||||
tsd_postfork_child(tsd_t *tsd) {
|
||||
malloc_mutex_postfork_child(tsd_tsdn(tsd), &tsd_nominal_tsds_lock);
|
||||
ql_new(&tsd_nominal_tsds);
|
||||
|
||||
if (tsd_state_get(tsd) <= tsd_state_nominal_max) {
|
||||
tsd_add_nominal(tsd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue