PA: Parameterize emap. Move emap_global to arena.

This lets us test the PA module without interfering with the global emap used by
the real allocator (the one not under test).
This commit is contained in:
David Goldblatt
2020-03-14 10:49:34 -07:00
committed by David Goldblatt
parent f730577277
commit 294b276fc7
19 changed files with 211 additions and 184 deletions

View File

@@ -61,8 +61,8 @@ get_large_size(size_t ind) {
static size_t
vsalloc(tsdn_t *tsdn, const void *ptr) {
emap_full_alloc_ctx_t full_alloc_ctx;
bool missing = emap_full_alloc_ctx_try_lookup(tsdn, &emap_global, ptr,
&full_alloc_ctx);
bool missing = emap_full_alloc_ctx_try_lookup(tsdn, &arena_emap_global,
ptr, &full_alloc_ctx);
if (missing) {
return 0;
}

View File

@@ -62,12 +62,12 @@ thd_start(void *varg) {
ptr = mallocx(1, MALLOCX_TCACHE_NONE);
ptr2 = mallocx(129, MALLOCX_TCACHE_NONE);
edata = emap_edata_lookup(tsdn, &emap_global, ptr);
edata = emap_edata_lookup(tsdn, &arena_emap_global, ptr);
shard1 = edata_binshard_get(edata);
dallocx(ptr, 0);
expect_u_lt(shard1, 16, "Unexpected bin shard used");
edata = emap_edata_lookup(tsdn, &emap_global, ptr2);
edata = emap_edata_lookup(tsdn, &arena_emap_global, ptr2);
shard2 = edata_binshard_get(edata);
dallocx(ptr2, 0);
expect_u_lt(shard2, 4, "Unexpected bin shard used");

View File

@@ -103,7 +103,7 @@ TEST_END
static void
confirm_malloc(void *p) {
assert_ptr_not_null(p, "malloc failed unexpectedly");
edata_t *e = emap_edata_lookup(TSDN_NULL, &emap_global, p);
edata_t *e = emap_edata_lookup(TSDN_NULL, &arena_emap_global, p);
assert_ptr_not_null(e, "NULL edata for living pointer");
prof_recent_t *n = edata_prof_recent_alloc_get_no_lock(e);
assert_ptr_not_null(n, "Record in edata should not be NULL");