Switch ctl to explicitly use tsd instead of tsdn.
This commit is contained in:
parent
425463a446
commit
57beeb2fcb
@ -91,8 +91,7 @@ typedef struct ctl_arenas_s {
|
|||||||
|
|
||||||
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
||||||
void *newp, size_t newlen);
|
void *newp, size_t newlen);
|
||||||
int ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp,
|
int ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp);
|
||||||
size_t *miblenp);
|
|
||||||
|
|
||||||
int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
||||||
size_t *oldlenp, void *newp, size_t newlen);
|
size_t *oldlenp, void *newp, size_t newlen);
|
||||||
|
38
src/ctl.c
38
src/ctl.c
@ -622,7 +622,7 @@ arenas_i2a(size_t i) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ctl_arena_t *
|
static ctl_arena_t *
|
||||||
arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
|
arenas_i_impl(tsd_t *tsd, size_t i, bool compat, bool init) {
|
||||||
ctl_arena_t *ret;
|
ctl_arena_t *ret;
|
||||||
|
|
||||||
assert(!compat || !init);
|
assert(!compat || !init);
|
||||||
@ -635,15 +635,15 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
|
|||||||
ctl_arena_stats_t astats;
|
ctl_arena_stats_t astats;
|
||||||
};
|
};
|
||||||
struct container_s *cont =
|
struct container_s *cont =
|
||||||
(struct container_s *)base_alloc(tsdn, b0get(),
|
(struct container_s *)base_alloc(tsd_tsdn(tsd),
|
||||||
sizeof(struct container_s), QUANTUM);
|
b0get(), sizeof(struct container_s), QUANTUM);
|
||||||
if (cont == NULL) {
|
if (cont == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = &cont->ctl_arena;
|
ret = &cont->ctl_arena;
|
||||||
ret->astats = &cont->astats;
|
ret->astats = &cont->astats;
|
||||||
} else {
|
} else {
|
||||||
ret = (ctl_arena_t *)base_alloc(tsdn, b0get(),
|
ret = (ctl_arena_t *)base_alloc(tsd_tsdn(tsd), b0get(),
|
||||||
sizeof(ctl_arena_t), QUANTUM);
|
sizeof(ctl_arena_t), QUANTUM);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -659,7 +659,7 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
|
|||||||
|
|
||||||
static ctl_arena_t *
|
static ctl_arena_t *
|
||||||
arenas_i(size_t i) {
|
arenas_i(size_t i) {
|
||||||
ctl_arena_t *ret = arenas_i_impl(TSDN_NULL, i, true, false);
|
ctl_arena_t *ret = arenas_i_impl(tsd_fetch(), i, true, false);
|
||||||
assert(ret != NULL);
|
assert(ret != NULL);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -863,7 +863,7 @@ ctl_arena_refresh(tsdn_t *tsdn, arena_t *arena, ctl_arena_t *ctl_sdarena,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static unsigned
|
static unsigned
|
||||||
ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
|
ctl_arena_init(tsd_t *tsd, extent_hooks_t *extent_hooks) {
|
||||||
unsigned arena_ind;
|
unsigned arena_ind;
|
||||||
ctl_arena_t *ctl_arena;
|
ctl_arena_t *ctl_arena;
|
||||||
|
|
||||||
@ -876,12 +876,12 @@ ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Trigger stats allocation. */
|
/* Trigger stats allocation. */
|
||||||
if (arenas_i_impl(tsdn, arena_ind, false, true) == NULL) {
|
if (arenas_i_impl(tsd, arena_ind, false, true) == NULL) {
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize new arena. */
|
/* Initialize new arena. */
|
||||||
if (arena_init(tsdn, arena_ind, extent_hooks) == NULL) {
|
if (arena_init(tsd_tsdn(tsd), arena_ind, extent_hooks) == NULL) {
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -975,8 +975,9 @@ ctl_refresh(tsdn_t *tsdn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
ctl_init(tsdn_t *tsdn) {
|
ctl_init(tsd_t *tsd) {
|
||||||
bool ret;
|
bool ret;
|
||||||
|
tsdn_t *tsdn = tsd_tsdn(tsd);
|
||||||
|
|
||||||
malloc_mutex_lock(tsdn, &ctl_mtx);
|
malloc_mutex_lock(tsdn, &ctl_mtx);
|
||||||
if (!ctl_initialized) {
|
if (!ctl_initialized) {
|
||||||
@ -1010,14 +1011,14 @@ ctl_init(tsdn_t *tsdn) {
|
|||||||
* here rather than doing it lazily elsewhere, in order
|
* here rather than doing it lazily elsewhere, in order
|
||||||
* to limit when OOM-caused errors can occur.
|
* to limit when OOM-caused errors can occur.
|
||||||
*/
|
*/
|
||||||
if ((ctl_sarena = arenas_i_impl(tsdn, MALLCTL_ARENAS_ALL, false,
|
if ((ctl_sarena = arenas_i_impl(tsd, MALLCTL_ARENAS_ALL, false,
|
||||||
true)) == NULL) {
|
true)) == NULL) {
|
||||||
ret = true;
|
ret = true;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
ctl_sarena->initialized = true;
|
ctl_sarena->initialized = true;
|
||||||
|
|
||||||
if ((ctl_darena = arenas_i_impl(tsdn, MALLCTL_ARENAS_DESTROYED,
|
if ((ctl_darena = arenas_i_impl(tsd, MALLCTL_ARENAS_DESTROYED,
|
||||||
false, true)) == NULL) {
|
false, true)) == NULL) {
|
||||||
ret = true;
|
ret = true;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
@ -1031,7 +1032,7 @@ ctl_init(tsdn_t *tsdn) {
|
|||||||
|
|
||||||
ctl_arenas->narenas = narenas_total_get();
|
ctl_arenas->narenas = narenas_total_get();
|
||||||
for (i = 0; i < ctl_arenas->narenas; i++) {
|
for (i = 0; i < ctl_arenas->narenas; i++) {
|
||||||
if (arenas_i_impl(tsdn, i, false, true) == NULL) {
|
if (arenas_i_impl(tsd, i, false, true) == NULL) {
|
||||||
ret = true;
|
ret = true;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
@ -1156,7 +1157,7 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
|
|||||||
size_t mib[CTL_MAX_DEPTH];
|
size_t mib[CTL_MAX_DEPTH];
|
||||||
const ctl_named_node_t *node;
|
const ctl_named_node_t *node;
|
||||||
|
|
||||||
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
|
if (!ctl_initialized && ctl_init(tsd)) {
|
||||||
ret = EAGAIN;
|
ret = EAGAIN;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
@ -1180,15 +1181,15 @@ label_return:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp, size_t *miblenp) {
|
ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!ctl_initialized && ctl_init(tsdn)) {
|
if (!ctl_initialized && ctl_init(tsd)) {
|
||||||
ret = EAGAIN;
|
ret = EAGAIN;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ctl_lookup(tsdn, name, NULL, mibp, miblenp);
|
ret = ctl_lookup(tsd_tsdn(tsd), name, NULL, mibp, miblenp);
|
||||||
label_return:
|
label_return:
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -1200,7 +1201,7 @@ ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
const ctl_named_node_t *node;
|
const ctl_named_node_t *node;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
|
if (!ctl_initialized && ctl_init(tsd)) {
|
||||||
ret = EAGAIN;
|
ret = EAGAIN;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
@ -2312,8 +2313,7 @@ arenas_create_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
|
|||||||
|
|
||||||
extent_hooks = (extent_hooks_t *)&extent_hooks_default;
|
extent_hooks = (extent_hooks_t *)&extent_hooks_default;
|
||||||
WRITE(extent_hooks, extent_hooks_t *);
|
WRITE(extent_hooks, extent_hooks_t *);
|
||||||
if ((arena_ind = ctl_arena_init(tsd_tsdn(tsd), extent_hooks)) ==
|
if ((arena_ind = ctl_arena_init(tsd, extent_hooks)) == UINT_MAX) {
|
||||||
UINT_MAX) {
|
|
||||||
ret = EAGAIN;
|
ret = EAGAIN;
|
||||||
goto label_return;
|
goto label_return;
|
||||||
}
|
}
|
||||||
|
@ -2918,16 +2918,15 @@ je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
|
|||||||
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
|
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
|
||||||
je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp) {
|
je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp) {
|
||||||
int ret;
|
int ret;
|
||||||
tsdn_t *tsdn;
|
|
||||||
|
|
||||||
if (unlikely(malloc_init())) {
|
if (unlikely(malloc_init())) {
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdn = tsdn_fetch();
|
tsd_t *tsd = tsd_fetch();
|
||||||
check_entry_exit_locking(tsdn);
|
check_entry_exit_locking(tsd_tsdn(tsd));
|
||||||
ret = ctl_nametomib(tsdn, name, mibp, miblenp);
|
ret = ctl_nametomib(tsd, name, mibp, miblenp);
|
||||||
check_entry_exit_locking(tsdn);
|
check_entry_exit_locking(tsd_tsdn(tsd));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user