2014-05-06 06:16:56 +08:00
|
|
|
#include "test/jemalloc_test.h"
|
|
|
|
|
2017-01-07 03:22:08 +08:00
|
|
|
#include "test/extent_hooks.h"
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
2016-12-23 06:39:10 +08:00
|
|
|
static void
|
2017-01-16 08:56:30 +08:00
|
|
|
test_extent_body(unsigned arena_ind) {
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
void *p;
|
2016-12-23 06:39:10 +08:00
|
|
|
size_t large0, large1, large2, sz;
|
|
|
|
size_t purge_mib[3];
|
|
|
|
size_t purge_miblen;
|
2016-04-26 11:26:03 +08:00
|
|
|
int flags;
|
2015-08-13 06:21:07 +08:00
|
|
|
bool xallocx_success_a, xallocx_success_b, xallocx_success_c;
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
2016-04-26 11:26:03 +08:00
|
|
|
flags = MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE;
|
|
|
|
|
2016-06-01 05:50:21 +08:00
|
|
|
/* Get large size classes. */
|
2016-05-28 15:17:28 +08:00
|
|
|
sz = sizeof(size_t);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
|
2016-10-28 12:31:25 +08:00
|
|
|
0), 0, "Unexpected arenas.lextent.0.size failure");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("arenas.lextent.1.size", (void *)&large1, &sz, NULL,
|
2016-10-28 12:31:25 +08:00
|
|
|
0), 0, "Unexpected arenas.lextent.1.size failure");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("arenas.lextent.2.size", (void *)&large2, &sz, NULL,
|
2016-10-28 12:31:25 +08:00
|
|
|
0), 0, "Unexpected arenas.lextent.2.size failure");
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
|
|
|
/* Test dalloc/decommit/purge cascade. */
|
2016-04-26 11:26:03 +08:00
|
|
|
purge_miblen = sizeof(purge_mib)/sizeof(size_t);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlnametomib("arena.0.purge", purge_mib, &purge_miblen),
|
2016-04-26 11:26:03 +08:00
|
|
|
0, "Unexpected mallctlnametomib() failure");
|
|
|
|
purge_mib[1] = (size_t)arena_ind;
|
2017-06-14 07:35:35 +08:00
|
|
|
called_alloc = false;
|
|
|
|
try_alloc = true;
|
2017-01-07 03:22:08 +08:00
|
|
|
try_dalloc = false;
|
|
|
|
try_decommit = false;
|
2016-06-01 05:50:21 +08:00
|
|
|
p = mallocx(large0 * 2, flags);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
|
|
|
expect_true(called_alloc, "Expected alloc call");
|
2017-01-07 03:22:08 +08:00
|
|
|
called_dalloc = false;
|
|
|
|
called_decommit = false;
|
2016-12-04 07:38:25 +08:00
|
|
|
did_purge_lazy = false;
|
|
|
|
did_purge_forced = false;
|
2017-01-07 03:22:08 +08:00
|
|
|
called_split = false;
|
2016-06-01 05:50:21 +08:00
|
|
|
xallocx_success_a = (xallocx(p, large0, 0, flags) == large0);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
2016-04-26 11:26:03 +08:00
|
|
|
0, "Unexpected arena.%u.purge error", arena_ind);
|
2015-08-13 06:21:07 +08:00
|
|
|
if (xallocx_success_a) {
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_true(called_dalloc, "Expected dalloc call");
|
|
|
|
expect_true(called_decommit, "Expected decommit call");
|
|
|
|
expect_true(did_purge_lazy || did_purge_forced,
|
2016-12-04 07:38:25 +08:00
|
|
|
"Expected purge");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_true(called_split, "Expected split call");
|
2015-08-13 06:21:07 +08:00
|
|
|
}
|
2016-04-26 11:26:03 +08:00
|
|
|
dallocx(p, flags);
|
2017-01-07 03:22:08 +08:00
|
|
|
try_dalloc = true;
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
|
|
|
/* Test decommit/commit and observe split/merge. */
|
2017-01-07 03:22:08 +08:00
|
|
|
try_dalloc = false;
|
|
|
|
try_decommit = true;
|
2016-06-01 05:50:21 +08:00
|
|
|
p = mallocx(large0 * 2, flags);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
did_decommit = false;
|
|
|
|
did_commit = false;
|
2017-01-07 03:22:08 +08:00
|
|
|
called_split = false;
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
did_split = false;
|
|
|
|
did_merge = false;
|
2016-06-01 05:50:21 +08:00
|
|
|
xallocx_success_b = (xallocx(p, large0, 0, flags) == large0);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
2016-04-26 11:26:03 +08:00
|
|
|
0, "Unexpected arena.%u.purge error", arena_ind);
|
2017-01-16 08:56:30 +08:00
|
|
|
if (xallocx_success_b) {
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_true(did_split, "Expected split");
|
2017-01-16 08:56:30 +08:00
|
|
|
}
|
2016-06-01 05:50:21 +08:00
|
|
|
xallocx_success_c = (xallocx(p, large0 * 2, 0, flags) == large0 * 2);
|
2016-06-06 13:30:31 +08:00
|
|
|
if (did_split) {
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_b_eq(did_decommit, did_commit,
|
2016-06-06 13:30:31 +08:00
|
|
|
"Expected decommit/commit match");
|
|
|
|
}
|
2017-01-16 08:56:30 +08:00
|
|
|
if (xallocx_success_b && xallocx_success_c) {
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_true(did_merge, "Expected merge");
|
2017-01-16 08:56:30 +08:00
|
|
|
}
|
2016-04-26 11:26:03 +08:00
|
|
|
dallocx(p, flags);
|
2017-01-07 03:22:08 +08:00
|
|
|
try_dalloc = true;
|
|
|
|
try_decommit = false;
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
2016-06-01 05:50:21 +08:00
|
|
|
/* Make sure non-large allocation succeeds. */
|
2016-04-26 11:26:03 +08:00
|
|
|
p = mallocx(42, flags);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_not_null(p, "Unexpected mallocx() error");
|
2016-04-26 11:26:03 +08:00
|
|
|
dallocx(p, flags);
|
2016-12-23 06:39:10 +08:00
|
|
|
}
|
|
|
|
|
2018-04-12 06:15:26 +08:00
|
|
|
static void
|
|
|
|
test_manual_hook_auto_arena(void) {
|
|
|
|
unsigned narenas;
|
|
|
|
size_t old_size, new_size, sz;
|
|
|
|
size_t hooks_mib[3];
|
|
|
|
size_t hooks_miblen;
|
|
|
|
extent_hooks_t *new_hooks, *old_hooks;
|
|
|
|
|
|
|
|
extent_hooks_prep();
|
|
|
|
|
|
|
|
sz = sizeof(unsigned);
|
|
|
|
/* Get number of auto arenas. */
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("opt.narenas", (void *)&narenas, &sz, NULL, 0),
|
2018-04-12 06:15:26 +08:00
|
|
|
0, "Unexpected mallctl() failure");
|
|
|
|
if (narenas == 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install custom extent hooks on arena 1 (might not be initialized). */
|
|
|
|
hooks_miblen = sizeof(hooks_mib)/sizeof(size_t);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
2018-04-12 06:15:26 +08:00
|
|
|
&hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
|
|
|
|
hooks_mib[1] = 1;
|
|
|
|
old_size = sizeof(extent_hooks_t *);
|
|
|
|
new_hooks = &hooks;
|
|
|
|
new_size = sizeof(extent_hooks_t *);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
2018-04-12 06:15:26 +08:00
|
|
|
&old_size, (void *)&new_hooks, new_size), 0,
|
|
|
|
"Unexpected extent_hooks error");
|
|
|
|
static bool auto_arena_created = false;
|
|
|
|
if (old_hooks != &hooks) {
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_b_eq(auto_arena_created, false,
|
2018-04-12 06:15:26 +08:00
|
|
|
"Expected auto arena 1 created only once.");
|
|
|
|
auto_arena_created = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-29 04:21:58 +08:00
|
|
|
static void
|
|
|
|
test_manual_hook_body(void) {
|
2016-12-23 06:39:10 +08:00
|
|
|
unsigned arena_ind;
|
|
|
|
size_t old_size, new_size, sz;
|
|
|
|
size_t hooks_mib[3];
|
|
|
|
size_t hooks_miblen;
|
2017-01-07 03:22:08 +08:00
|
|
|
extent_hooks_t *new_hooks, *old_hooks;
|
|
|
|
|
|
|
|
extent_hooks_prep();
|
2016-12-23 06:39:10 +08:00
|
|
|
|
|
|
|
sz = sizeof(unsigned);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
|
2016-12-23 06:39:10 +08:00
|
|
|
0, "Unexpected mallctl() failure");
|
|
|
|
|
|
|
|
/* Install custom extent hooks. */
|
|
|
|
hooks_miblen = sizeof(hooks_mib)/sizeof(size_t);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
2016-12-23 06:39:10 +08:00
|
|
|
&hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
|
|
|
|
hooks_mib[1] = (size_t)arena_ind;
|
|
|
|
old_size = sizeof(extent_hooks_t *);
|
2017-01-07 03:22:08 +08:00
|
|
|
new_hooks = &hooks;
|
2016-12-23 06:39:10 +08:00
|
|
|
new_size = sizeof(extent_hooks_t *);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
2016-12-23 06:39:10 +08:00
|
|
|
&old_size, (void *)&new_hooks, new_size), 0,
|
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->alloc, extent_alloc_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->dalloc, extent_dalloc_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->commit, extent_commit_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->decommit, extent_decommit_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->purge_lazy, extent_purge_lazy_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->purge_forced, extent_purge_forced_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->split, extent_split_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_ne(old_hooks->merge, extent_merge_hook,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2016-12-23 06:39:10 +08:00
|
|
|
|
2021-05-13 07:00:38 +08:00
|
|
|
if (!is_background_thread_enabled()) {
|
2017-11-29 04:21:58 +08:00
|
|
|
test_extent_body(arena_ind);
|
|
|
|
}
|
Generalize chunk management hooks.
Add the "arena.<i>.chunk_hooks" mallctl, which replaces and expands on
the "arena.<i>.chunk.{alloc,dalloc,purge}" mallctls. The chunk hooks
allow control over chunk allocation/deallocation, decommit/commit,
purging, and splitting/merging, such that the application can rely on
jemalloc's internal chunk caching and retaining functionality, yet
implement a variety of chunk management mechanisms and policies.
Merge the chunks_[sz]ad_{mmap,dss} red-black trees into
chunks_[sz]ad_retained. This slightly reduces how hard jemalloc tries
to honor the dss precedence setting; prior to this change the precedence
setting was also consulted when recycling chunks.
Fix chunk purging. Don't purge chunks in arena_purge_stashed(); instead
deallocate them in arena_unstash_purged(), so that the dirty memory
linkage remains valid until after the last time it is used.
This resolves #176 and #201.
2015-07-28 23:28:19 +08:00
|
|
|
|
2016-06-01 06:03:51 +08:00
|
|
|
/* Restore extent hooks. */
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, NULL, NULL,
|
2016-10-28 12:31:25 +08:00
|
|
|
(void *)&old_hooks, new_size), 0, "Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
2016-10-28 12:31:25 +08:00
|
|
|
&old_size, NULL, 0), 0, "Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks, default_hooks, "Unexpected extent_hooks error");
|
|
|
|
expect_ptr_eq(old_hooks->alloc, default_hooks->alloc,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->dalloc, default_hooks->dalloc,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->commit, default_hooks->commit,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->decommit, default_hooks->decommit,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->purge_lazy, default_hooks->purge_lazy,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->purge_forced, default_hooks->purge_forced,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->split, default_hooks->split,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_ptr_eq(old_hooks->merge, default_hooks->merge,
|
2017-01-07 03:22:08 +08:00
|
|
|
"Unexpected extent_hooks error");
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|
2017-11-29 04:21:58 +08:00
|
|
|
|
|
|
|
TEST_BEGIN(test_extent_manual_hook) {
|
2018-04-12 06:15:26 +08:00
|
|
|
test_manual_hook_auto_arena();
|
2017-11-29 04:21:58 +08:00
|
|
|
test_manual_hook_body();
|
|
|
|
|
|
|
|
/* Test failure paths. */
|
|
|
|
try_split = false;
|
|
|
|
test_manual_hook_body();
|
|
|
|
try_merge = false;
|
|
|
|
test_manual_hook_body();
|
|
|
|
try_purge_lazy = false;
|
|
|
|
try_purge_forced = false;
|
|
|
|
test_manual_hook_body();
|
|
|
|
|
|
|
|
try_split = try_merge = try_purge_lazy = try_purge_forced = true;
|
|
|
|
}
|
2014-05-06 06:16:56 +08:00
|
|
|
TEST_END
|
|
|
|
|
2017-01-16 08:56:30 +08:00
|
|
|
TEST_BEGIN(test_extent_auto_hook) {
|
2016-12-23 06:39:10 +08:00
|
|
|
unsigned arena_ind;
|
|
|
|
size_t new_size, sz;
|
2017-01-07 03:22:08 +08:00
|
|
|
extent_hooks_t *new_hooks;
|
|
|
|
|
|
|
|
extent_hooks_prep();
|
2016-12-23 06:39:10 +08:00
|
|
|
|
|
|
|
sz = sizeof(unsigned);
|
2017-01-07 03:22:08 +08:00
|
|
|
new_hooks = &hooks;
|
2016-12-23 06:39:10 +08:00
|
|
|
new_size = sizeof(extent_hooks_t *);
|
2020-02-19 06:39:06 +08:00
|
|
|
expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz,
|
2016-12-23 06:39:10 +08:00
|
|
|
(void *)&new_hooks, new_size), 0, "Unexpected mallctl() failure");
|
|
|
|
|
2021-05-13 07:00:38 +08:00
|
|
|
test_skip_if(is_background_thread_enabled());
|
2016-12-23 06:39:10 +08:00
|
|
|
test_extent_body(arena_ind);
|
|
|
|
}
|
|
|
|
TEST_END
|
|
|
|
|
2014-05-06 06:16:56 +08:00
|
|
|
int
|
2017-01-16 08:56:30 +08:00
|
|
|
main(void) {
|
2017-01-20 10:15:45 +08:00
|
|
|
return test(
|
2016-12-23 06:39:10 +08:00
|
|
|
test_extent_manual_hook,
|
2017-01-20 10:15:45 +08:00
|
|
|
test_extent_auto_hook);
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|