Skip to content

Commit 57beeb2

Browse files
committed
Switch ctl to explicitly use tsd instead of tsdn.
1 parent 425463a commit 57beeb2

File tree

3 files changed

+24
-26
lines changed

3 files changed

+24
-26
lines changed

include/jemalloc/internal/ctl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ typedef struct ctl_arenas_s {
9191

9292
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
9393
void *newp, size_t newlen);
94-
int ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp,
95-
size_t *miblenp);
94+
int ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp);
9695

9796
int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
9897
size_t *oldlenp, void *newp, size_t newlen);

src/ctl.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ arenas_i2a(size_t i) {
622622
}
623623

624624
static ctl_arena_t *
625-
arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
625+
arenas_i_impl(tsd_t *tsd, size_t i, bool compat, bool init) {
626626
ctl_arena_t *ret;
627627

628628
assert(!compat || !init);
@@ -635,15 +635,15 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
635635
ctl_arena_stats_t astats;
636636
};
637637
struct container_s *cont =
638-
(struct container_s *)base_alloc(tsdn, b0get(),
639-
sizeof(struct container_s), QUANTUM);
638+
(struct container_s *)base_alloc(tsd_tsdn(tsd),
639+
b0get(), sizeof(struct container_s), QUANTUM);
640640
if (cont == NULL) {
641641
return NULL;
642642
}
643643
ret = &cont->ctl_arena;
644644
ret->astats = &cont->astats;
645645
} else {
646-
ret = (ctl_arena_t *)base_alloc(tsdn, b0get(),
646+
ret = (ctl_arena_t *)base_alloc(tsd_tsdn(tsd), b0get(),
647647
sizeof(ctl_arena_t), QUANTUM);
648648
if (ret == NULL) {
649649
return NULL;
@@ -659,7 +659,7 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
659659

660660
static ctl_arena_t *
661661
arenas_i(size_t i) {
662-
ctl_arena_t *ret = arenas_i_impl(TSDN_NULL, i, true, false);
662+
ctl_arena_t *ret = arenas_i_impl(tsd_fetch(), i, true, false);
663663
assert(ret != NULL);
664664
return ret;
665665
}
@@ -863,7 +863,7 @@ ctl_arena_refresh(tsdn_t *tsdn, arena_t *arena, ctl_arena_t *ctl_sdarena,
863863
}
864864

865865
static unsigned
866-
ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
866+
ctl_arena_init(tsd_t *tsd, extent_hooks_t *extent_hooks) {
867867
unsigned arena_ind;
868868
ctl_arena_t *ctl_arena;
869869

@@ -876,12 +876,12 @@ ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
876876
}
877877

878878
/* Trigger stats allocation. */
879-
if (arenas_i_impl(tsdn, arena_ind, false, true) == NULL) {
879+
if (arenas_i_impl(tsd, arena_ind, false, true) == NULL) {
880880
return UINT_MAX;
881881
}
882882

883883
/* Initialize new arena. */
884-
if (arena_init(tsdn, arena_ind, extent_hooks) == NULL) {
884+
if (arena_init(tsd_tsdn(tsd), arena_ind, extent_hooks) == NULL) {
885885
return UINT_MAX;
886886
}
887887

@@ -975,8 +975,9 @@ ctl_refresh(tsdn_t *tsdn) {
975975
}
976976

977977
static bool
978-
ctl_init(tsdn_t *tsdn) {
978+
ctl_init(tsd_t *tsd) {
979979
bool ret;
980+
tsdn_t *tsdn = tsd_tsdn(tsd);
980981

981982
malloc_mutex_lock(tsdn, &ctl_mtx);
982983
if (!ctl_initialized) {
@@ -1010,14 +1011,14 @@ ctl_init(tsdn_t *tsdn) {
10101011
* here rather than doing it lazily elsewhere, in order
10111012
* to limit when OOM-caused errors can occur.
10121013
*/
1013-
if ((ctl_sarena = arenas_i_impl(tsdn, MALLCTL_ARENAS_ALL, false,
1014+
if ((ctl_sarena = arenas_i_impl(tsd, MALLCTL_ARENAS_ALL, false,
10141015
true)) == NULL) {
10151016
ret = true;
10161017
goto label_return;
10171018
}
10181019
ctl_sarena->initialized = true;
10191020

1020-
if ((ctl_darena = arenas_i_impl(tsdn, MALLCTL_ARENAS_DESTROYED,
1021+
if ((ctl_darena = arenas_i_impl(tsd, MALLCTL_ARENAS_DESTROYED,
10211022
false, true)) == NULL) {
10221023
ret = true;
10231024
goto label_return;
@@ -1031,7 +1032,7 @@ ctl_init(tsdn_t *tsdn) {
10311032

10321033
ctl_arenas->narenas = narenas_total_get();
10331034
for (i = 0; i < ctl_arenas->narenas; i++) {
1034-
if (arenas_i_impl(tsdn, i, false, true) == NULL) {
1035+
if (arenas_i_impl(tsd, i, false, true) == NULL) {
10351036
ret = true;
10361037
goto label_return;
10371038
}
@@ -1156,7 +1157,7 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
11561157
size_t mib[CTL_MAX_DEPTH];
11571158
const ctl_named_node_t *node;
11581159

1159-
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
1160+
if (!ctl_initialized && ctl_init(tsd)) {
11601161
ret = EAGAIN;
11611162
goto label_return;
11621163
}
@@ -1180,15 +1181,15 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
11801181
}
11811182

11821183
int
1183-
ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp, size_t *miblenp) {
1184+
ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp) {
11841185
int ret;
11851186

1186-
if (!ctl_initialized && ctl_init(tsdn)) {
1187+
if (!ctl_initialized && ctl_init(tsd)) {
11871188
ret = EAGAIN;
11881189
goto label_return;
11891190
}
11901191

1191-
ret = ctl_lookup(tsdn, name, NULL, mibp, miblenp);
1192+
ret = ctl_lookup(tsd_tsdn(tsd), name, NULL, mibp, miblenp);
11921193
label_return:
11931194
return(ret);
11941195
}
@@ -1200,7 +1201,7 @@ ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
12001201
const ctl_named_node_t *node;
12011202
size_t i;
12021203

1203-
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
1204+
if (!ctl_initialized && ctl_init(tsd)) {
12041205
ret = EAGAIN;
12051206
goto label_return;
12061207
}
@@ -2312,8 +2313,7 @@ arenas_create_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
23122313

23132314
extent_hooks = (extent_hooks_t *)&extent_hooks_default;
23142315
WRITE(extent_hooks, extent_hooks_t *);
2315-
if ((arena_ind = ctl_arena_init(tsd_tsdn(tsd), extent_hooks)) ==
2316-
UINT_MAX) {
2316+
if ((arena_ind = ctl_arena_init(tsd, extent_hooks)) == UINT_MAX) {
23172317
ret = EAGAIN;
23182318
goto label_return;
23192319
}

src/jemalloc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,16 +2918,15 @@ je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
29182918
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
29192919
je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp) {
29202920
int ret;
2921-
tsdn_t *tsdn;
29222921

29232922
if (unlikely(malloc_init())) {
29242923
return EAGAIN;
29252924
}
29262925

2927-
tsdn = tsdn_fetch();
2928-
check_entry_exit_locking(tsdn);
2929-
ret = ctl_nametomib(tsdn, name, mibp, miblenp);
2930-
check_entry_exit_locking(tsdn);
2926+
tsd_t *tsd = tsd_fetch();
2927+
check_entry_exit_locking(tsd_tsdn(tsd));
2928+
ret = ctl_nametomib(tsd, name, mibp, miblenp);
2929+
check_entry_exit_locking(tsd_tsdn(tsd));
29312930
return ret;
29322931
}
29332932

0 commit comments

Comments
 (0)