2014-05-06 06:16:56 +08:00
|
|
|
#include "test/jemalloc_test.h"
|
|
|
|
|
2015-08-28 12:45:51 +08:00
|
|
|
#ifdef JEMALLOC_FILL
|
|
|
|
const char *malloc_conf = "junk:false";
|
|
|
|
#endif
|
|
|
|
|
2016-09-30 00:50:35 +08:00
|
|
|
static void *extent_alloc(extent_hooks_t *extent_hooks, void *new_addr,
|
|
|
|
size_t size, size_t alignment, bool *zero, bool *commit,
|
|
|
|
unsigned arena_ind);
|
|
|
|
static bool extent_dalloc(extent_hooks_t *extent_hooks, void *addr,
|
|
|
|
size_t size, bool committed, unsigned arena_ind);
|
|
|
|
static bool extent_commit(extent_hooks_t *extent_hooks, void *addr,
|
|
|
|
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
|
|
|
static bool extent_decommit(extent_hooks_t *extent_hooks, void *addr,
|
|
|
|
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
2016-12-04 07:38:25 +08:00
|
|
|
static bool extent_purge_lazy(extent_hooks_t *extent_hooks, void *addr,
|
|
|
|
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
|
|
|
static bool extent_purge_forced(extent_hooks_t *extent_hooks, void *addr,
|
2016-09-30 00:50:35 +08:00
|
|
|
size_t size, size_t offset, size_t length, unsigned arena_ind);
|
|
|
|
static bool extent_split(extent_hooks_t *extent_hooks, void *addr,
|
|
|
|
size_t size, size_t size_a, size_t size_b, bool committed,
|
|
|
|
unsigned arena_ind);
|
|
|
|
static bool extent_merge(extent_hooks_t *extent_hooks, void *addr_a,
|
|
|
|
size_t size_a, void *addr_b, size_t size_b, bool committed,
|
|
|
|
unsigned arena_ind);
|
|
|
|
|
|
|
|
static extent_hooks_t hooks = {
|
|
|
|
extent_alloc,
|
|
|
|
extent_dalloc,
|
|
|
|
extent_commit,
|
|
|
|
extent_decommit,
|
2016-12-04 07:38:25 +08:00
|
|
|
extent_purge_lazy,
|
|
|
|
extent_purge_forced,
|
2016-09-30 00:50:35 +08:00
|
|
|
extent_split,
|
|
|
|
extent_merge
|
|
|
|
};
|
|
|
|
static extent_hooks_t *new_hooks = &hooks;
|
2016-06-04 03:05:53 +08:00
|
|
|
static extent_hooks_t *orig_hooks;
|
|
|
|
static extent_hooks_t *old_hooks;
|
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
|
|
|
|
|
|
|
static bool do_dalloc = true;
|
|
|
|
static bool do_decommit;
|
|
|
|
|
|
|
|
static bool did_alloc;
|
|
|
|
static bool did_dalloc;
|
|
|
|
static bool did_commit;
|
|
|
|
static bool did_decommit;
|
2016-12-04 07:38:25 +08:00
|
|
|
static bool did_purge_lazy;
|
|
|
|
static bool did_purge_forced;
|
2016-06-06 13:30:31 +08:00
|
|
|
static bool tried_split;
|
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
|
|
|
static bool did_split;
|
|
|
|
static bool did_merge;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
# define TRACE_HOOK(fmt, ...) malloc_printf(fmt, __VA_ARGS__)
|
|
|
|
#else
|
|
|
|
# define TRACE_HOOK(fmt, ...)
|
|
|
|
#endif
|
2015-03-19 09:55:33 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static void *
|
|
|
|
extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
|
|
|
|
size_t alignment, bool *zero, bool *commit, unsigned arena_ind)
|
2015-03-19 09:55:33 +08:00
|
|
|
{
|
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, new_addr=%p, size=%zu, alignment=%zu, "
|
|
|
|
"*zero=%s, *commit=%s, arena_ind=%u)\n", __func__, extent_hooks,
|
|
|
|
new_addr, size, alignment, *zero ? "true" : "false", *commit ?
|
|
|
|
"true" : "false", arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->alloc, extent_alloc, "Wrong hook function");
|
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_alloc = true;
|
2016-06-04 03:05:53 +08:00
|
|
|
return (old_hooks->alloc(old_hooks, new_addr, size, alignment, zero,
|
2016-12-23 06:39:10 +08:00
|
|
|
commit, 0));
|
2015-03-19 09:55:33 +08:00
|
|
|
}
|
2014-05-06 06:16:56 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
|
|
|
extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
|
|
bool committed, unsigned arena_ind)
|
2014-05-06 06:16:56 +08:00
|
|
|
{
|
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, committed=%s, "
|
|
|
|
"arena_ind=%u)\n", __func__, extent_hooks, addr, size, committed ?
|
|
|
|
"true" : "false", arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->dalloc, extent_dalloc,
|
|
|
|
"Wrong hook function");
|
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_dalloc = true;
|
|
|
|
if (!do_dalloc)
|
|
|
|
return (true);
|
2016-12-23 06:39:10 +08:00
|
|
|
return (old_hooks->dalloc(old_hooks, addr, size, committed, 0));
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
|
|
|
extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
|
|
size_t offset, size_t length, unsigned arena_ind)
|
2014-05-06 06:16:56 +08:00
|
|
|
{
|
2015-08-13 01:26:54 +08:00
|
|
|
bool err;
|
2014-05-06 06:16:56 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
|
|
|
|
"length=%zu, arena_ind=%u)\n", __func__, extent_hooks, addr, size,
|
|
|
|
offset, length, arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->commit, extent_commit,
|
|
|
|
"Wrong hook function");
|
2016-12-23 06:39:10 +08:00
|
|
|
err = old_hooks->commit(old_hooks, addr, size, offset, length, 0);
|
2015-08-13 01:26:54 +08:00
|
|
|
did_commit = !err;
|
|
|
|
return (err);
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
|
|
|
extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
|
|
size_t offset, size_t length, unsigned arena_ind)
|
2014-05-06 06:16:56 +08:00
|
|
|
{
|
2015-08-13 01:26:54 +08:00
|
|
|
bool err;
|
2014-05-06 06:16:56 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
|
|
|
|
"length=%zu, arena_ind=%u)\n", __func__, extent_hooks, addr, size,
|
|
|
|
offset, length, arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->decommit, extent_decommit,
|
|
|
|
"Wrong hook function");
|
2015-08-13 01:26:54 +08:00
|
|
|
if (!do_decommit)
|
|
|
|
return (true);
|
2016-12-23 06:39:10 +08:00
|
|
|
err = old_hooks->decommit(old_hooks, addr, size, offset, length, 0);
|
2015-08-13 01:26:54 +08:00
|
|
|
did_decommit = !err;
|
|
|
|
return (err);
|
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
|
|
|
}
|
2014-05-06 06:16:56 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
2016-12-04 07:38:25 +08:00
|
|
|
extent_purge_lazy(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
|
|
size_t offset, size_t length, unsigned arena_ind)
|
|
|
|
{
|
|
|
|
|
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
|
|
|
|
"length=%zu arena_ind=%u)\n", __func__, extent_hooks, addr, size,
|
|
|
|
offset, length, arena_ind);
|
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->purge_lazy, extent_purge_lazy,
|
|
|
|
"Wrong hook function");
|
|
|
|
did_purge_lazy = true;
|
|
|
|
return (old_hooks->purge_lazy == NULL ||
|
2016-12-23 06:39:10 +08:00
|
|
|
old_hooks->purge_lazy(old_hooks, addr, size, offset, length, 0));
|
2016-12-04 07:38:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool
|
|
|
|
extent_purge_forced(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
2016-06-04 03:05:53 +08:00
|
|
|
size_t offset, size_t length, 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
|
|
|
{
|
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, offset=%zu, "
|
|
|
|
"length=%zu arena_ind=%u)\n", __func__, extent_hooks, addr, size,
|
|
|
|
offset, length, arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
2016-12-04 07:38:25 +08:00
|
|
|
assert_ptr_eq(extent_hooks->purge_forced, extent_purge_forced,
|
|
|
|
"Wrong hook function");
|
|
|
|
did_purge_forced = true;
|
|
|
|
return (old_hooks->purge_forced == NULL ||
|
2016-12-23 06:39:10 +08:00
|
|
|
old_hooks->purge_forced(old_hooks, addr, size, offset, length, 0));
|
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
|
|
|
}
|
2015-03-19 09:55:33 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
|
|
|
extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
|
|
|
|
size_t size_a, size_t size_b, bool committed, 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
|
|
|
{
|
2016-06-06 13:30:31 +08:00
|
|
|
bool err;
|
2014-05-06 06:16:56 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr=%p, size=%zu, size_a=%zu, "
|
|
|
|
"size_b=%zu, committed=%s, arena_ind=%u)\n", __func__, extent_hooks,
|
|
|
|
addr, size, size_a, size_b, committed ? "true" : "false",
|
|
|
|
arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->split, extent_split, "Wrong hook function");
|
2016-06-06 13:30:31 +08:00
|
|
|
tried_split = true;
|
2016-12-04 07:38:25 +08:00
|
|
|
err = (old_hooks->split == NULL || old_hooks->split(old_hooks, addr,
|
2016-12-23 06:39:10 +08:00
|
|
|
size, size_a, size_b, committed, 0));
|
2016-06-06 13:30:31 +08:00
|
|
|
did_split = !err;
|
|
|
|
return (err);
|
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
|
|
|
}
|
2015-03-19 09:55:33 +08:00
|
|
|
|
2016-06-04 03:05:53 +08:00
|
|
|
static bool
|
|
|
|
extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
|
|
|
|
void *addr_b, size_t size_b, bool committed, 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
|
|
|
{
|
2016-06-06 13:30:31 +08:00
|
|
|
bool err;
|
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-04 03:05:53 +08:00
|
|
|
TRACE_HOOK("%s(extent_hooks=%p, addr_a=%p, size_a=%zu, addr_b=%p "
|
|
|
|
"size_b=%zu, committed=%s, arena_ind=%u)\n", __func__, extent_hooks,
|
|
|
|
addr_a, size_a, addr_b, size_b, committed ? "true" : "false",
|
|
|
|
arena_ind);
|
2016-09-30 00:50:35 +08:00
|
|
|
assert_ptr_eq(extent_hooks, new_hooks,
|
|
|
|
"extent_hooks should be same as pointer used to set hooks");
|
|
|
|
assert_ptr_eq(extent_hooks->merge, extent_merge, "Wrong hook function");
|
2016-12-04 07:38:25 +08:00
|
|
|
err = (old_hooks->merge == NULL || old_hooks->merge(old_hooks, addr_a,
|
2016-12-23 06:39:10 +08:00
|
|
|
size_a, addr_b, size_b, committed, 0));
|
2016-06-06 13:30:31 +08:00
|
|
|
did_merge = !err;
|
|
|
|
return (err);
|
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
|
|
|
|
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);
|
2016-10-28 12:31:25 +08:00
|
|
|
assert_d_eq(mallctl("arenas.lextent.0.size", (void *)&large0, &sz, NULL,
|
|
|
|
0), 0, "Unexpected arenas.lextent.0.size failure");
|
|
|
|
assert_d_eq(mallctl("arenas.lextent.1.size", (void *)&large1, &sz, NULL,
|
|
|
|
0), 0, "Unexpected arenas.lextent.1.size failure");
|
|
|
|
assert_d_eq(mallctl("arenas.lextent.2.size", (void *)&large2, &sz, NULL,
|
|
|
|
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);
|
|
|
|
assert_d_eq(mallctlnametomib("arena.0.purge", purge_mib, &purge_miblen),
|
|
|
|
0, "Unexpected mallctlnametomib() failure");
|
|
|
|
purge_mib[1] = (size_t)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
|
|
|
do_dalloc = false;
|
|
|
|
do_decommit = false;
|
2016-06-01 05:50:21 +08:00
|
|
|
p = mallocx(large0 * 2, flags);
|
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
|
|
|
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
|
|
|
did_dalloc = false;
|
|
|
|
did_decommit = false;
|
2016-12-04 07:38:25 +08:00
|
|
|
did_purge_lazy = false;
|
|
|
|
did_purge_forced = false;
|
2016-06-06 13:30:31 +08:00
|
|
|
tried_split = false;
|
2015-08-13 06:21:07 +08:00
|
|
|
did_split = false;
|
2016-06-01 05:50:21 +08:00
|
|
|
xallocx_success_a = (xallocx(p, large0, 0, flags) == large0);
|
2016-04-26 11:26:03 +08:00
|
|
|
assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
|
|
|
0, "Unexpected arena.%u.purge error", arena_ind);
|
2015-08-13 06:21:07 +08:00
|
|
|
if (xallocx_success_a) {
|
|
|
|
assert_true(did_dalloc, "Expected dalloc");
|
|
|
|
assert_false(did_decommit, "Unexpected decommit");
|
2016-12-04 07:38:25 +08:00
|
|
|
assert_true(did_purge_lazy || did_purge_forced,
|
|
|
|
"Expected purge");
|
2015-08-13 06:21:07 +08:00
|
|
|
}
|
2016-06-06 13:30:31 +08:00
|
|
|
assert_true(tried_split, "Expected split");
|
2016-04-26 11:26:03 +08:00
|
|
|
dallocx(p, flags);
|
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
|
|
|
do_dalloc = true;
|
|
|
|
|
|
|
|
/* Test decommit/commit and observe split/merge. */
|
|
|
|
do_dalloc = false;
|
|
|
|
do_decommit = true;
|
2016-06-01 05:50:21 +08:00
|
|
|
p = mallocx(large0 * 2, flags);
|
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
|
|
|
assert_ptr_not_null(p, "Unexpected mallocx() error");
|
|
|
|
did_decommit = false;
|
|
|
|
did_commit = false;
|
2016-06-06 13:30:31 +08:00
|
|
|
tried_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);
|
2016-04-26 11:26:03 +08:00
|
|
|
assert_d_eq(mallctlbymib(purge_mib, purge_miblen, NULL, NULL, NULL, 0),
|
|
|
|
0, "Unexpected arena.%u.purge error", arena_ind);
|
2015-08-13 06:21:07 +08:00
|
|
|
if (xallocx_success_b)
|
|
|
|
assert_true(did_split, "Expected split");
|
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) {
|
|
|
|
assert_b_eq(did_decommit, did_commit,
|
|
|
|
"Expected decommit/commit match");
|
|
|
|
}
|
2015-08-13 06:21:07 +08:00
|
|
|
if (xallocx_success_b && xallocx_success_c)
|
|
|
|
assert_true(did_merge, "Expected merge");
|
2016-04-26 11:26:03 +08:00
|
|
|
dallocx(p, flags);
|
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
|
|
|
do_dalloc = true;
|
|
|
|
do_decommit = false;
|
|
|
|
|
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);
|
2015-03-19 09:55:33 +08:00
|
|
|
assert_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
|
|
|
}
|
|
|
|
|
|
|
|
TEST_BEGIN(test_extent_manual_hook)
|
|
|
|
{
|
|
|
|
unsigned arena_ind;
|
|
|
|
size_t old_size, new_size, sz;
|
|
|
|
size_t hooks_mib[3];
|
|
|
|
size_t hooks_miblen;
|
|
|
|
|
|
|
|
sz = sizeof(unsigned);
|
2017-01-04 00:21:29 +08:00
|
|
|
assert_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);
|
|
|
|
assert_d_eq(mallctlnametomib("arena.0.extent_hooks", hooks_mib,
|
|
|
|
&hooks_miblen), 0, "Unexpected mallctlnametomib() failure");
|
|
|
|
hooks_mib[1] = (size_t)arena_ind;
|
|
|
|
old_size = sizeof(extent_hooks_t *);
|
|
|
|
new_size = sizeof(extent_hooks_t *);
|
|
|
|
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
|
|
|
&old_size, (void *)&new_hooks, new_size), 0,
|
|
|
|
"Unexpected extent_hooks error");
|
|
|
|
orig_hooks = old_hooks;
|
|
|
|
assert_ptr_ne(old_hooks->alloc, extent_alloc, "Unexpected alloc error");
|
|
|
|
assert_ptr_ne(old_hooks->dalloc, extent_dalloc,
|
|
|
|
"Unexpected dalloc error");
|
|
|
|
assert_ptr_ne(old_hooks->commit, extent_commit,
|
|
|
|
"Unexpected commit error");
|
|
|
|
assert_ptr_ne(old_hooks->decommit, extent_decommit,
|
|
|
|
"Unexpected decommit error");
|
|
|
|
assert_ptr_ne(old_hooks->purge_lazy, extent_purge_lazy,
|
|
|
|
"Unexpected purge_lazy error");
|
|
|
|
assert_ptr_ne(old_hooks->purge_forced, extent_purge_forced,
|
|
|
|
"Unexpected purge_forced error");
|
|
|
|
assert_ptr_ne(old_hooks->split, extent_split, "Unexpected split error");
|
|
|
|
assert_ptr_ne(old_hooks->merge, extent_merge, "Unexpected merge error");
|
|
|
|
|
|
|
|
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. */
|
2016-04-26 11:26:03 +08:00
|
|
|
assert_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");
|
|
|
|
assert_d_eq(mallctlbymib(hooks_mib, hooks_miblen, (void *)&old_hooks,
|
|
|
|
&old_size, NULL, 0), 0, "Unexpected extent_hooks error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks, orig_hooks, "Unexpected hooks error");
|
|
|
|
assert_ptr_eq(old_hooks->alloc, orig_hooks->alloc,
|
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
|
|
|
"Unexpected alloc error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks->dalloc, orig_hooks->dalloc,
|
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
|
|
|
"Unexpected dalloc error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks->commit, orig_hooks->commit,
|
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
|
|
|
"Unexpected commit error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks->decommit, orig_hooks->decommit,
|
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
|
|
|
"Unexpected decommit error");
|
2016-12-04 07:38:25 +08:00
|
|
|
assert_ptr_eq(old_hooks->purge_lazy, orig_hooks->purge_lazy,
|
|
|
|
"Unexpected purge_lazy error");
|
|
|
|
assert_ptr_eq(old_hooks->purge_forced, orig_hooks->purge_forced,
|
|
|
|
"Unexpected purge_forced error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks->split, orig_hooks->split,
|
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
|
|
|
"Unexpected split error");
|
2016-06-04 03:05:53 +08:00
|
|
|
assert_ptr_eq(old_hooks->merge, orig_hooks->merge,
|
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
|
|
|
"Unexpected merge error");
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|
|
|
|
TEST_END
|
|
|
|
|
2016-12-23 06:39:10 +08:00
|
|
|
TEST_BEGIN(test_extent_auto_hook)
|
|
|
|
{
|
|
|
|
unsigned arena_ind;
|
|
|
|
size_t new_size, sz;
|
|
|
|
|
|
|
|
sz = sizeof(unsigned);
|
|
|
|
new_size = sizeof(extent_hooks_t *);
|
2017-01-04 00:21:29 +08:00
|
|
|
assert_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");
|
|
|
|
|
|
|
|
test_extent_body(arena_ind);
|
|
|
|
}
|
|
|
|
TEST_END
|
|
|
|
|
2014-05-06 06:16:56 +08:00
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
|
2016-12-23 06:39:10 +08:00
|
|
|
return (test(
|
|
|
|
test_extent_manual_hook,
|
|
|
|
test_extent_auto_hook));
|
2014-05-06 06:16:56 +08:00
|
|
|
}
|