summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2023-03-21 14:02:30 -0700
committerQi Wang <interwq@gmail.com>2023-03-22 15:16:43 -0700
commit8e7353a19b5fd9dd1041307b884bc969065b63af (patch)
treef9bd52ef5191defb4f7360f1da767373fc7a6748
parent45249cf5a9cfa13c2c62e68e272a391721523b4b (diff)
downloadjemalloc-8e7353a19b5fd9dd1041307b884bc969065b63af.tar.gz
Explicit arena assignment in test_thread_idle.
Otherwise the associated arena could change with percpu arena enabled.
-rw-r--r--test/unit/mallctl.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/unit/mallctl.c b/test/unit/mallctl.c
index 244d4c96..1ff8b564 100644
--- a/test/unit/mallctl.c
+++ b/test/unit/mallctl.c
@@ -1097,8 +1097,12 @@ TEST_BEGIN(test_thread_idle) {
unsigned arena_ind;
sz = sizeof(arena_ind);
- err = mallctl("thread.arena", &arena_ind, &sz, NULL, 0);
- expect_d_eq(err, 0, "");
+ expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
+ 0, "Unexpected mallctl() failure");
+ err = mallctl("thread.arena", NULL, NULL, &arena_ind, sizeof(arena_ind));
+ expect_d_eq(err, 0, "Unexpected mallctl() failure");
+ err = mallctl("thread.tcache.flush", NULL, NULL, NULL, 0);
+ expect_d_eq(err, 0, "Unexpected mallctl() failure");
/* We're going to do an allocation of size 1, which we know is small. */
size_t mib[5];
@@ -1108,10 +1112,11 @@ TEST_BEGIN(test_thread_idle) {
mib[2] = arena_ind;
/*
- * This alloc and dalloc should leave something in the tcache, in a
- * small size's cache bin.
+ * This alloc and dalloc should leave something (from the newly created
+ * arena) in the tcache, in a small size's cache bin. Later the stats
+ * of that arena will be checked to verify if tcache flush happened.
*/
- void *ptr = mallocx(1, 0);
+ void *ptr = mallocx(1, MALLOCX_TCACHE_NONE);
dallocx(ptr, 0);
uint64_t epoch;