Always initialize tcache data structures.
Always initialize tcache data structures if the tcache configuration option is enabled, regardless of opt_tcache. This fixes "thread.tcache.enabled" mallctl manipulation in the case when opt_tcache is false.
This commit is contained in:
parent
fad100bc35
commit
3701367e4c
26
src/tcache.c
26
src/tcache.c
@ -334,17 +334,17 @@ tcache_thread_cleanup(void *arg)
|
|||||||
} else if (tcache == TCACHE_STATE_REINCARNATED) {
|
} else if (tcache == TCACHE_STATE_REINCARNATED) {
|
||||||
/*
|
/*
|
||||||
* Another destructor called an allocator function after this
|
* Another destructor called an allocator function after this
|
||||||
* destructor was called. Reset tcache to 1 in order to
|
* destructor was called. Reset tcache to
|
||||||
* receive another callback.
|
* TCACHE_STATE_PURGATORY in order to receive another callback.
|
||||||
*/
|
*/
|
||||||
tcache = TCACHE_STATE_PURGATORY;
|
tcache = TCACHE_STATE_PURGATORY;
|
||||||
tcache_tsd_set(&tcache);
|
tcache_tsd_set(&tcache);
|
||||||
} else if (tcache == TCACHE_STATE_PURGATORY) {
|
} else if (tcache == TCACHE_STATE_PURGATORY) {
|
||||||
/*
|
/*
|
||||||
* The previous time this destructor was called, we set the key
|
* The previous time this destructor was called, we set the key
|
||||||
* to 1 so that other destructors wouldn't cause re-creation of
|
* to TCACHE_STATE_PURGATORY so that other destructors wouldn't
|
||||||
* the tcache. This time, do nothing, so that the destructor
|
* cause re-creation of the tcache. This time, do nothing, so
|
||||||
* will not be called again.
|
* that the destructor will not be called again.
|
||||||
*/
|
*/
|
||||||
} else if (tcache != NULL) {
|
} else if (tcache != NULL) {
|
||||||
assert(tcache != TCACHE_STATE_PURGATORY);
|
assert(tcache != TCACHE_STATE_PURGATORY);
|
||||||
@ -381,17 +381,13 @@ tcache_stats_merge(tcache_t *tcache, arena_t *arena)
|
|||||||
bool
|
bool
|
||||||
tcache_boot0(void)
|
tcache_boot0(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (opt_tcache) {
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If necessary, clamp opt_lg_tcache_max, now that
|
* If necessary, clamp opt_lg_tcache_max, now that arena_maxclass is
|
||||||
* SMALL_MAXCLASS and arena_maxclass are known.
|
* known.
|
||||||
* XXX Can this be done earlier?
|
|
||||||
*/
|
*/
|
||||||
if (opt_lg_tcache_max < 0 || (1U << opt_lg_tcache_max) <
|
if (opt_lg_tcache_max < 0 || (1U << opt_lg_tcache_max) < SMALL_MAXCLASS)
|
||||||
SMALL_MAXCLASS)
|
|
||||||
tcache_maxclass = SMALL_MAXCLASS;
|
tcache_maxclass = SMALL_MAXCLASS;
|
||||||
else if ((1U << opt_lg_tcache_max) > arena_maxclass)
|
else if ((1U << opt_lg_tcache_max) > arena_maxclass)
|
||||||
tcache_maxclass = arena_maxclass;
|
tcache_maxclass = arena_maxclass;
|
||||||
@ -407,8 +403,7 @@ tcache_boot0(void)
|
|||||||
return (true);
|
return (true);
|
||||||
stack_nelms = 0;
|
stack_nelms = 0;
|
||||||
for (i = 0; i < NBINS; i++) {
|
for (i = 0; i < NBINS; i++) {
|
||||||
if ((arena_bin_info[i].nregs << 1) <=
|
if ((arena_bin_info[i].nregs << 1) <= TCACHE_NSLOTS_SMALL_MAX) {
|
||||||
TCACHE_NSLOTS_SMALL_MAX) {
|
|
||||||
tcache_bin_info[i].ncached_max =
|
tcache_bin_info[i].ncached_max =
|
||||||
(arena_bin_info[i].nregs << 1);
|
(arena_bin_info[i].nregs << 1);
|
||||||
} else {
|
} else {
|
||||||
@ -421,7 +416,6 @@ tcache_boot0(void)
|
|||||||
tcache_bin_info[i].ncached_max = TCACHE_NSLOTS_LARGE;
|
tcache_bin_info[i].ncached_max = TCACHE_NSLOTS_LARGE;
|
||||||
stack_nelms += tcache_bin_info[i].ncached_max;
|
stack_nelms += tcache_bin_info[i].ncached_max;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
@ -430,10 +424,8 @@ bool
|
|||||||
tcache_boot1(void)
|
tcache_boot1(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (opt_tcache) {
|
|
||||||
if (tcache_tsd_boot() || tcache_enabled_tsd_boot())
|
if (tcache_tsd_boot() || tcache_enabled_tsd_boot())
|
||||||
return (true);
|
return (true);
|
||||||
}
|
|
||||||
|
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user