Get rid of tcache_enabled_t as we have runtime init support.
This commit is contained in:
parent
fde3e20cc0
commit
0fba57e579
@ -942,7 +942,7 @@ tcache_available(tsd_t *tsd) {
|
|||||||
* initialization, or 2) disabled through thread.tcache.enabled mallctl
|
* initialization, or 2) disabled through thread.tcache.enabled mallctl
|
||||||
* or config options. This check covers all cases.
|
* or config options. This check covers all cases.
|
||||||
*/
|
*/
|
||||||
if (likely(tsd_tcache_enabled_get(tsd) == tcache_enabled_true)) {
|
if (likely(tsd_tcache_enabled_get(tsd) == true)) {
|
||||||
/* Associated arena == null implies tcache init in progress. */
|
/* Associated arena == null implies tcache init in progress. */
|
||||||
if (tsd_tcachep_get(tsd)->arena != NULL) {
|
if (tsd_tcachep_get(tsd)->arena != NULL) {
|
||||||
assert(tsd_tcachep_get(tsd)->tbins[0].avail != NULL);
|
assert(tsd_tcachep_get(tsd)->tbins[0].avail != NULL);
|
||||||
|
@ -22,30 +22,24 @@ tcache_t *tcaches_get(tsd_t *tsd, unsigned ind);
|
|||||||
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TCACHE_C_))
|
#if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_TCACHE_C_))
|
||||||
JEMALLOC_INLINE bool
|
JEMALLOC_INLINE bool
|
||||||
tcache_enabled_get(tsd_t *tsd) {
|
tcache_enabled_get(tsd_t *tsd) {
|
||||||
tcache_enabled_t tcache_enabled;
|
|
||||||
|
|
||||||
cassert(config_tcache);
|
cassert(config_tcache);
|
||||||
|
|
||||||
tcache_enabled = tsd_tcache_enabled_get(tsd);
|
return tsd_tcache_enabled_get(tsd);
|
||||||
assert(tcache_enabled != tcache_enabled_default);
|
|
||||||
|
|
||||||
return (bool)tcache_enabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JEMALLOC_INLINE void
|
JEMALLOC_INLINE void
|
||||||
tcache_enabled_set(tsd_t *tsd, bool enabled) {
|
tcache_enabled_set(tsd_t *tsd, bool enabled) {
|
||||||
cassert(config_tcache);
|
cassert(config_tcache);
|
||||||
|
|
||||||
tcache_enabled_t old = tsd_tcache_enabled_get(tsd);
|
bool was_enabled = tsd_tcache_enabled_get(tsd);
|
||||||
|
|
||||||
if ((old != tcache_enabled_true) && enabled) {
|
if (!was_enabled && enabled) {
|
||||||
tsd_tcache_data_init(tsd);
|
tsd_tcache_data_init(tsd);
|
||||||
} else if ((old == tcache_enabled_true) && !enabled) {
|
} else if (was_enabled && !enabled) {
|
||||||
tcache_cleanup(tsd);
|
tcache_cleanup(tsd);
|
||||||
}
|
}
|
||||||
/* Commit the state last. Above calls check current state. */
|
/* Commit the state last. Above calls check current state. */
|
||||||
tcache_enabled_t tcache_enabled = (tcache_enabled_t)enabled;
|
tsd_tcache_enabled_set(tsd, enabled);
|
||||||
tsd_tcache_enabled_set(tsd, tcache_enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JEMALLOC_ALWAYS_INLINE void
|
JEMALLOC_ALWAYS_INLINE void
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
#ifndef JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
||||||
#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
#define JEMALLOC_INTERNAL_TCACHE_STRUCTS_H
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
tcache_enabled_false = 0, /* Enable cast to/from bool. */
|
|
||||||
tcache_enabled_true = 1,
|
|
||||||
tcache_enabled_default = 2
|
|
||||||
} tcache_enabled_t;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read-only information associated with each element of tcache_t's tbins array
|
* Read-only information associated with each element of tcache_t's tbins array
|
||||||
* is stored separately, mainly to reduce memory usage.
|
* is stored separately, mainly to reduce memory usage.
|
||||||
|
@ -50,4 +50,7 @@ typedef struct tcaches_s tcaches_t;
|
|||||||
/* Used in TSD static initializer only. Real init in tcache_data_init(). */
|
/* Used in TSD static initializer only. Real init in tcache_data_init(). */
|
||||||
#define TCACHE_ZERO_INITIALIZER {{NULL}}
|
#define TCACHE_ZERO_INITIALIZER {{NULL}}
|
||||||
|
|
||||||
|
/* Used in TSD static initializer only. Will be initialized to opt_tcache. */
|
||||||
|
#define TCACHE_ENABLED_DEFAULT false
|
||||||
|
|
||||||
#endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */
|
#endif /* JEMALLOC_INTERNAL_TCACHE_TYPES_H */
|
||||||
|
@ -25,8 +25,7 @@ struct tsd_init_head_s {
|
|||||||
O(arenas_tdata, arena_tdata_t *,yes, no, yes) \
|
O(arenas_tdata, arena_tdata_t *,yes, no, yes) \
|
||||||
O(narenas_tdata, unsigned, yes, no, no) \
|
O(narenas_tdata, unsigned, yes, no, no) \
|
||||||
O(arenas_tdata_bypass, bool, no, no, no) \
|
O(arenas_tdata_bypass, bool, no, no, no) \
|
||||||
O(tcache_enabled, tcache_enabled_t, \
|
O(tcache_enabled, bool, yes, yes, no) \
|
||||||
yes, yes, no) \
|
|
||||||
O(rtree_ctx, rtree_ctx_t, no, yes, no) \
|
O(rtree_ctx, rtree_ctx_t, no, yes, no) \
|
||||||
O(witnesses, witness_list_t, no, no, yes) \
|
O(witnesses, witness_list_t, no, no, yes) \
|
||||||
O(rtree_leaf_elm_witnesses, rtree_leaf_elm_witness_tsd_t, \
|
O(rtree_leaf_elm_witnesses, rtree_leaf_elm_witness_tsd_t, \
|
||||||
@ -44,7 +43,7 @@ struct tsd_init_head_s {
|
|||||||
NULL, \
|
NULL, \
|
||||||
0, \
|
0, \
|
||||||
false, \
|
false, \
|
||||||
tcache_enabled_default, \
|
TCACHE_ENABLED_DEFAULT, \
|
||||||
RTREE_CTX_ZERO_INITIALIZER, \
|
RTREE_CTX_ZERO_INITIALIZER, \
|
||||||
ql_head_initializer(witnesses), \
|
ql_head_initializer(witnesses), \
|
||||||
RTREE_ELM_WITNESS_TSD_INITIALIZER, \
|
RTREE_ELM_WITNESS_TSD_INITIALIZER, \
|
||||||
|
@ -326,7 +326,7 @@ tcache_arena_reassociate(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena) {
|
|||||||
bool
|
bool
|
||||||
tsd_tcache_enabled_data_init(tsd_t *tsd) {
|
tsd_tcache_enabled_data_init(tsd_t *tsd) {
|
||||||
/* Called upon tsd initialization. */
|
/* Called upon tsd initialization. */
|
||||||
tsd_tcache_enabled_set(tsd, (tcache_enabled_t)opt_tcache);
|
tsd_tcache_enabled_set(tsd, opt_tcache);
|
||||||
if (opt_tcache) {
|
if (opt_tcache) {
|
||||||
/* Trigger tcache init. */
|
/* Trigger tcache init. */
|
||||||
tsd_tcache_data_init(tsd);
|
tsd_tcache_data_init(tsd);
|
||||||
@ -501,13 +501,13 @@ tcache_cleanup(tsd_t *tsd) {
|
|||||||
|
|
||||||
tcache_t *tcache = tsd_tcachep_get(tsd);
|
tcache_t *tcache = tsd_tcachep_get(tsd);
|
||||||
if (!tcache_available(tsd)) {
|
if (!tcache_available(tsd)) {
|
||||||
assert(tsd_tcache_enabled_get(tsd) == tcache_enabled_false);
|
assert(tsd_tcache_enabled_get(tsd) == false);
|
||||||
if (config_debug) {
|
if (config_debug) {
|
||||||
assert(tcache->tbins[0].avail == NULL);
|
assert(tcache->tbins[0].avail == NULL);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert(tsd_tcache_enabled_get(tsd) == tcache_enabled_true);
|
assert(tsd_tcache_enabled_get(tsd));
|
||||||
assert(tcache->tbins[0].avail != NULL);
|
assert(tcache->tbins[0].avail != NULL);
|
||||||
|
|
||||||
tcache_destroy(tsd, tcache, true);
|
tcache_destroy(tsd, tcache, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user