summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-04-21 00:21:37 (GMT)
committerJason Evans <jasone@canonware.com>2017-04-21 17:06:12 (GMT)
commit4403c9ab441eabb6c55d93b99836f7126e46be75 (patch)
treea7bf4b383956b2cd02b4cb8bdb8012640d283130 /test/unit
parent5aa46f027df42636d4aa1fb70d1078a6c5f96420 (diff)
downloadjemalloc-4403c9ab441eabb6c55d93b99836f7126e46be75.zip
jemalloc-4403c9ab441eabb6c55d93b99836f7126e46be75.tar.gz
jemalloc-4403c9ab441eabb6c55d93b99836f7126e46be75.tar.bz2
Remove --disable-tcache.
Simplify configuration by removing the --disable-tcache option, but replace the testing for that configuration with --with-malloc-conf=tcache:false. Fix the thread.arena and thread.tcache.flush mallctls to work correctly if tcache is disabled. This partially resolves #580.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/decay.c109
-rw-r--r--test/unit/decay.sh5
-rw-r--r--test/unit/mallctl.c9
-rw-r--r--test/unit/prof_idump.sh8
-rw-r--r--test/unit/stats.c20
5 files changed, 66 insertions, 85 deletions
diff --git a/test/unit/decay.c b/test/unit/decay.c
index 471a558..26359fa 100644
--- a/test/unit/decay.c
+++ b/test/unit/decay.c
@@ -174,16 +174,15 @@ TEST_BEGIN(test_decay_ticks) {
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
0), 0, "Unexpected mallctl failure");
- int err;
/* Set up a manually managed arena for test. */
arena_ind = do_arena_create(0, 0);
/* Migrate to the new arena, and get the ticker. */
unsigned old_arena_ind;
size_t sz_arena_ind = sizeof(old_arena_ind);
- err = mallctl("thread.arena", (void *)&old_arena_ind, &sz_arena_ind,
- (void *)&arena_ind, sizeof(arena_ind));
- assert_d_eq(err, 0, "Unexpected mallctl() failure");
+ assert_d_eq(mallctl("thread.arena", (void *)&old_arena_ind,
+ &sz_arena_ind, (void *)&arena_ind, sizeof(arena_ind)), 0,
+ "Unexpected mallctl() failure");
decay_ticker = decay_ticker_get(tsd_fetch(), arena_ind);
assert_ptr_not_null(decay_ticker,
"Unexpected failure getting decay ticker");
@@ -310,51 +309,48 @@ TEST_BEGIN(test_decay_ticks) {
* Test tcache fill/flush interactions for large and small size classes,
* using an explicit tcache.
*/
- if (config_tcache) {
- unsigned tcache_ind, i;
- size_t tcache_sizes[2];
- tcache_sizes[0] = large0;
- tcache_sizes[1] = 1;
-
- size_t tcache_max, sz_tcache_max;
- sz_tcache_max = sizeof(tcache_max);
- err = mallctl("arenas.tcache_max", (void *)&tcache_max,
- &sz_tcache_max, NULL, 0);
- assert_d_eq(err, 0, "Unexpected mallctl() failure");
-
- sz = sizeof(unsigned);
- assert_d_eq(mallctl("tcache.create", (void *)&tcache_ind, &sz,
- NULL, 0), 0, "Unexpected mallctl failure");
-
- for (i = 0; i < sizeof(tcache_sizes) / sizeof(size_t); i++) {
- sz = tcache_sizes[i];
-
- /* tcache fill. */
- tick0 = ticker_read(decay_ticker);
- p = mallocx(sz, MALLOCX_TCACHE(tcache_ind));
- assert_ptr_not_null(p, "Unexpected mallocx() failure");
- tick1 = ticker_read(decay_ticker);
+ unsigned tcache_ind, i;
+ size_t tcache_sizes[2];
+ tcache_sizes[0] = large0;
+ tcache_sizes[1] = 1;
+
+ size_t tcache_max, sz_tcache_max;
+ sz_tcache_max = sizeof(tcache_max);
+ assert_d_eq(mallctl("arenas.tcache_max", (void *)&tcache_max,
+ &sz_tcache_max, NULL, 0), 0, "Unexpected mallctl() failure");
+
+ sz = sizeof(unsigned);
+ assert_d_eq(mallctl("tcache.create", (void *)&tcache_ind, &sz,
+ NULL, 0), 0, "Unexpected mallctl failure");
+
+ for (i = 0; i < sizeof(tcache_sizes) / sizeof(size_t); i++) {
+ sz = tcache_sizes[i];
+
+ /* tcache fill. */
+ tick0 = ticker_read(decay_ticker);
+ p = mallocx(sz, MALLOCX_TCACHE(tcache_ind));
+ assert_ptr_not_null(p, "Unexpected mallocx() failure");
+ tick1 = ticker_read(decay_ticker);
+ assert_u32_ne(tick1, tick0,
+ "Expected ticker to tick during tcache fill "
+ "(sz=%zu)", sz);
+ /* tcache flush. */
+ dallocx(p, MALLOCX_TCACHE(tcache_ind));
+ tick0 = ticker_read(decay_ticker);
+ assert_d_eq(mallctl("tcache.flush", NULL, NULL,
+ (void *)&tcache_ind, sizeof(unsigned)), 0,
+ "Unexpected mallctl failure");
+ tick1 = ticker_read(decay_ticker);
+
+ /* Will only tick if it's in tcache. */
+ if (sz <= tcache_max) {
assert_u32_ne(tick1, tick0,
- "Expected ticker to tick during tcache fill "
- "(sz=%zu)", sz);
- /* tcache flush. */
- dallocx(p, MALLOCX_TCACHE(tcache_ind));
- tick0 = ticker_read(decay_ticker);
- assert_d_eq(mallctl("tcache.flush", NULL, NULL,
- (void *)&tcache_ind, sizeof(unsigned)), 0,
- "Unexpected mallctl failure");
- tick1 = ticker_read(decay_ticker);
-
- /* Will only tick if it's in tcache. */
- if (sz <= tcache_max) {
- assert_u32_ne(tick1, tick0,
- "Expected ticker to tick during tcache "
- "flush (sz=%zu)", sz);
- } else {
- assert_u32_eq(tick1, tick0,
- "Unexpected ticker tick during tcache "
- "flush (sz=%zu)", sz);
- }
+ "Expected ticker to tick during tcache "
+ "flush (sz=%zu)", sz);
+ } else {
+ assert_u32_eq(tick1, tick0,
+ "Unexpected ticker tick during tcache "
+ "flush (sz=%zu)", sz);
}
}
}
@@ -422,18 +418,11 @@ TEST_BEGIN(test_decay_ticker) {
* the ticker triggers purging.
*/
- if (config_tcache) {
- size_t tcache_max;
-
- size_t sz = sizeof(size_t);
- assert_d_eq(mallctl("arenas.tcache_max", (void *)&tcache_max,
- &sz, NULL, 0), 0, "Unexpected mallctl failure");
- large = nallocx(tcache_max + 1, flags);
- } else {
- size_t sz = sizeof(size_t);
- assert_d_eq(mallctl("arenas.lextent.0.size", &large, &sz, NULL,
- 0), 0, "Unexpected mallctl failure");
- }
+ size_t tcache_max;
+ size_t sz = sizeof(size_t);
+ assert_d_eq(mallctl("arenas.tcache_max", (void *)&tcache_max, &sz, NULL,
+ 0), 0, "Unexpected mallctl failure");
+ large = nallocx(tcache_max + 1, flags);
do_purge(arena_ind);
uint64_t dirty_npurge0 = get_arena_dirty_npurge(arena_ind);
diff --git a/test/unit/decay.sh b/test/unit/decay.sh
index 0df1788..a41489b 100644
--- a/test/unit/decay.sh
+++ b/test/unit/decay.sh
@@ -1,6 +1,3 @@
#!/bin/sh
-export MALLOC_CONF="dirty_decay_time:1,muzzy_decay_time:1"
-if [ "x${enable_tcache}" = "x1" ] ; then
- export MALLOC_CONF="${MALLOC_CONF},lg_tcache_max:0"
-fi
+export MALLOC_CONF="dirty_decay_time:1,muzzy_decay_time:1,lg_tcache_max:0"
diff --git a/test/unit/mallctl.c b/test/unit/mallctl.c
index b8c6a25..945d829 100644
--- a/test/unit/mallctl.c
+++ b/test/unit/mallctl.c
@@ -136,7 +136,6 @@ TEST_BEGIN(test_mallctl_config) {
TEST_MALLCTL_CONFIG(prof_libgcc, bool);
TEST_MALLCTL_CONFIG(prof_libunwind, bool);
TEST_MALLCTL_CONFIG(stats, bool);
- TEST_MALLCTL_CONFIG(tcache, bool);
TEST_MALLCTL_CONFIG(tls, bool);
TEST_MALLCTL_CONFIG(utrace, bool);
TEST_MALLCTL_CONFIG(xmalloc, bool);
@@ -170,8 +169,8 @@ TEST_BEGIN(test_mallctl_opt) {
TEST_MALLCTL_OPT(bool, zero, fill);
TEST_MALLCTL_OPT(bool, utrace, utrace);
TEST_MALLCTL_OPT(bool, xmalloc, xmalloc);
- TEST_MALLCTL_OPT(bool, tcache, tcache);
- TEST_MALLCTL_OPT(size_t, lg_tcache_max, tcache);
+ TEST_MALLCTL_OPT(bool, tcache, always);
+ TEST_MALLCTL_OPT(size_t, lg_tcache_max, always);
TEST_MALLCTL_OPT(bool, prof, prof);
TEST_MALLCTL_OPT(const char *, prof_prefix, prof);
TEST_MALLCTL_OPT(bool, prof_active, prof);
@@ -213,8 +212,6 @@ TEST_END
TEST_BEGIN(test_tcache_none) {
void *p0, *q, *p1;
- test_skip_if(!config_tcache);
-
/* Allocate p and q. */
p0 = mallocx(42, 0);
assert_ptr_not_null(p0, "Unexpected mallocx() failure");
@@ -243,8 +240,6 @@ TEST_BEGIN(test_tcache) {
unsigned i;
size_t sz, psz, qsz;
- test_skip_if(!config_tcache);
-
psz = 42;
qsz = nallocx(psz, 0) + 1;
diff --git a/test/unit/prof_idump.sh b/test/unit/prof_idump.sh
index fdb5813..4dc599a 100644
--- a/test/unit/prof_idump.sh
+++ b/test/unit/prof_idump.sh
@@ -1,12 +1,8 @@
#!/bin/sh
+export MALLOC_CONF="tcache:false"
if [ "x${enable_prof}" = "x1" ] ; then
- export MALLOC_CONF="prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0"
- if [ "x${enable_tcache}" = "x1" ] ; then
- export MALLOC_CONF="${MALLOC_CONF},tcache:false"
- fi
-elif [ "x${enable_tcache}" = "x1" ] ; then
- export MALLOC_CONF="tcache:false"
+ export MALLOC_CONF="${MALLOC_CONF},prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0"
fi
diff --git a/test/unit/stats.c b/test/unit/stats.c
index 1619f5b..f5ee128 100644
--- a/test/unit/stats.c
+++ b/test/unit/stats.c
@@ -83,7 +83,7 @@ TEST_BEGIN(test_stats_arenas_summary) {
dallocx(large, 0);
assert_d_eq(mallctl("thread.tcache.flush", NULL, NULL, NULL, 0),
- config_tcache ? 0 : ENOENT, "Unexpected mallctl() result");
+ opt_tcache ? 0 : EFAULT, "Unexpected mallctl() result");
assert_d_eq(mallctl("arena.0.purge", NULL, NULL, NULL, 0), 0,
"Unexpected mallctl() failure");
@@ -150,7 +150,7 @@ TEST_BEGIN(test_stats_arenas_small) {
assert_ptr_not_null(p, "Unexpected mallocx() failure");
assert_d_eq(mallctl("thread.tcache.flush", NULL, NULL, NULL, 0),
- config_tcache ? 0 : ENOENT, "Unexpected mallctl() result");
+ opt_tcache ? 0 : EFAULT, "Unexpected mallctl() result");
assert_d_eq(mallctl("epoch", NULL, NULL, (void *)&epoch, sizeof(epoch)),
0, "Unexpected mallctl() failure");
@@ -230,6 +230,10 @@ TEST_BEGIN(test_stats_arenas_bins) {
uint64_t nslabs, nreslabs;
int expected = config_stats ? 0 : ENOENT;
+ /* Make sure allocation below isn't satisfied by tcache. */
+ assert_d_eq(mallctl("thread.tcache.flush", NULL, NULL, NULL, 0),
+ opt_tcache ? 0 : EFAULT, "Unexpected mallctl() result");
+
unsigned arena_ind, old_arena_ind;
sz = sizeof(unsigned);
assert_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
@@ -243,7 +247,7 @@ TEST_BEGIN(test_stats_arenas_bins) {
assert_ptr_not_null(p, "Unexpected malloc() failure");
assert_d_eq(mallctl("thread.tcache.flush", NULL, NULL, NULL, 0),
- config_tcache ? 0 : ENOENT, "Unexpected mallctl() result");
+ opt_tcache ? 0 : EFAULT, "Unexpected mallctl() result");
assert_d_eq(mallctl("epoch", NULL, NULL, (void *)&epoch, sizeof(epoch)),
0, "Unexpected mallctl() failure");
@@ -266,11 +270,11 @@ TEST_BEGIN(test_stats_arenas_bins) {
sz = sizeof(uint64_t);
gen_mallctl_str(cmd, "nfills", arena_ind);
- assert_d_eq(mallctl(cmd, (void *)&nfills, &sz, NULL, 0),
- config_tcache ? expected : ENOENT, "Unexpected mallctl() result");
+ assert_d_eq(mallctl(cmd, (void *)&nfills, &sz, NULL, 0), expected,
+ "Unexpected mallctl() result");
gen_mallctl_str(cmd, "nflushes", arena_ind);
- assert_d_eq(mallctl(cmd, (void *)&nflushes, &sz, NULL, 0),
- config_tcache ? expected : ENOENT, "Unexpected mallctl() result");
+ assert_d_eq(mallctl(cmd, (void *)&nflushes, &sz, NULL, 0), expected,
+ "Unexpected mallctl() result");
gen_mallctl_str(cmd, "nslabs", arena_ind);
assert_d_eq(mallctl(cmd, (void *)&nslabs, &sz, NULL, 0), expected,
@@ -292,7 +296,7 @@ TEST_BEGIN(test_stats_arenas_bins) {
"nrequests should be greater than zero");
assert_zu_gt(curregs, 0,
"allocated should be greater than zero");
- if (config_tcache) {
+ if (opt_tcache) {
assert_u64_gt(nfills, 0,
"At least one fill should have occurred");
assert_u64_gt(nflushes, 0,