SC: Remove global data.
The global data is mostly only used at initialization, or for easy access to values we could compute statically. Instead of consuming that space (and risking TLB misses), we can just pass around a pointer to stack data during bootstrapping.
This commit is contained in:
committed by
David Goldblatt
parent
4bc48718b2
commit
3aba072cef
@@ -129,8 +129,7 @@ TEST_END
|
||||
|
||||
TEST_BEGIN(test_junk_large) {
|
||||
test_skip_if(!config_fill);
|
||||
test_junk(SC_SMALL_MAXCLASS + 1,
|
||||
(1U << (sc_data_global.lg_large_minclass + 1)));
|
||||
test_junk(SC_SMALL_MAXCLASS + 1, (1U << (SC_LG_LARGE_MINCLASS + 1)));
|
||||
}
|
||||
TEST_END
|
||||
|
||||
|
@@ -581,7 +581,7 @@ TEST_BEGIN(test_arena_i_retain_grow_limit) {
|
||||
|
||||
assert_d_eq(mallctlbymib(mib, miblen, &default_limit, &sz, NULL, 0), 0,
|
||||
"Unexpected mallctl() failure");
|
||||
assert_zu_eq(default_limit, sz_pind2sz(sc_data_global.npsizes - 1),
|
||||
assert_zu_eq(default_limit, SC_LARGE_MAXCLASS,
|
||||
"Unexpected default for retain_grow_limit");
|
||||
|
||||
new_limit = PAGE - 1;
|
||||
|
@@ -29,12 +29,12 @@ TEST_BEGIN(test_gdump) {
|
||||
prof_dump_open = prof_dump_open_intercept;
|
||||
|
||||
did_prof_dump_open = false;
|
||||
p = mallocx((1U << sc_data_global.lg_large_minclass), 0);
|
||||
p = mallocx((1U << SC_LG_LARGE_MINCLASS), 0);
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
assert_true(did_prof_dump_open, "Expected a profile dump");
|
||||
|
||||
did_prof_dump_open = false;
|
||||
q = mallocx((1U << sc_data_global.lg_large_minclass), 0);
|
||||
q = mallocx((1U << SC_LG_LARGE_MINCLASS), 0);
|
||||
assert_ptr_not_null(q, "Unexpected mallocx() failure");
|
||||
assert_true(did_prof_dump_open, "Expected a profile dump");
|
||||
|
||||
@@ -45,7 +45,7 @@ TEST_BEGIN(test_gdump) {
|
||||
"Unexpected mallctl failure while disabling prof.gdump");
|
||||
assert(gdump_old);
|
||||
did_prof_dump_open = false;
|
||||
r = mallocx((1U << sc_data_global.lg_large_minclass), 0);
|
||||
r = mallocx((1U << SC_LG_LARGE_MINCLASS), 0);
|
||||
assert_ptr_not_null(q, "Unexpected mallocx() failure");
|
||||
assert_false(did_prof_dump_open, "Unexpected profile dump");
|
||||
|
||||
@@ -56,7 +56,7 @@ TEST_BEGIN(test_gdump) {
|
||||
"Unexpected mallctl failure while enabling prof.gdump");
|
||||
assert(!gdump_old);
|
||||
did_prof_dump_open = false;
|
||||
s = mallocx((1U << sc_data_global.lg_large_minclass), 0);
|
||||
s = mallocx((1U << SC_LG_LARGE_MINCLASS), 0);
|
||||
assert_ptr_not_null(q, "Unexpected mallocx() failure");
|
||||
assert_true(did_prof_dump_open, "Expected a profile dump");
|
||||
|
||||
|
@@ -108,8 +108,13 @@ TEST_BEGIN(test_psize_classes) {
|
||||
size_class, sz_psz2ind(size_class),
|
||||
sz_pind2sz(sz_psz2ind(size_class)));
|
||||
|
||||
assert_u_eq(pind+1, sz_psz2ind(size_class+1),
|
||||
"Next size_class does not round up properly");
|
||||
if (size_class == SC_LARGE_MAXCLASS) {
|
||||
assert_u_eq(SC_NPSIZES, sz_psz2ind(size_class + 1),
|
||||
"Next size_class does not round up properly");
|
||||
} else {
|
||||
assert_u_eq(pind + 1, sz_psz2ind(size_class + 1),
|
||||
"Next size_class does not round up properly");
|
||||
}
|
||||
|
||||
assert_zu_eq(size_class, (pind > 0) ?
|
||||
sz_psz2u(sz_pind2sz(pind-1)+1) : sz_psz2u(1),
|
||||
@@ -156,16 +161,13 @@ TEST_BEGIN(test_overflow) {
|
||||
assert_zu_eq(sz_s2u(SIZE_T_MAX), 0,
|
||||
"sz_s2u() should return 0 on overflow");
|
||||
|
||||
assert_u_eq(sz_psz2ind(max_size_class+1), sc_data_global.npsizes,
|
||||
assert_u_eq(sz_psz2ind(max_size_class+1), SC_NPSIZES,
|
||||
"sz_psz2ind() should return NPSIZES on overflow");
|
||||
assert_u_eq(sz_psz2ind(ZU(PTRDIFF_MAX)+1), sc_data_global.npsizes,
|
||||
assert_u_eq(sz_psz2ind(ZU(PTRDIFF_MAX)+1), SC_NPSIZES,
|
||||
"sz_psz2ind() should return NPSIZES on overflow");
|
||||
assert_u_eq(sz_psz2ind(SIZE_T_MAX), sc_data_global.npsizes,
|
||||
assert_u_eq(sz_psz2ind(SIZE_T_MAX), SC_NPSIZES,
|
||||
"sz_psz2ind() should return NPSIZES on overflow");
|
||||
|
||||
assert_u_le(sc_data_global.npsizes, SC_NPSIZES_MAX,
|
||||
"Dynamic value of npsizes is higher than static bound.");
|
||||
|
||||
assert_zu_eq(sz_psz2u(max_size_class+1), max_psz,
|
||||
"sz_psz2u() should return (LARGE_MAXCLASS + PAGE) for unsupported"
|
||||
" size");
|
||||
|
@@ -76,7 +76,7 @@ TEST_BEGIN(test_stats_arenas_summary) {
|
||||
|
||||
little = mallocx(SC_SMALL_MAXCLASS, MALLOCX_ARENA(0));
|
||||
assert_ptr_not_null(little, "Unexpected mallocx() failure");
|
||||
large = mallocx((1U << sc_data_global.lg_large_minclass),
|
||||
large = mallocx((1U << SC_LG_LARGE_MINCLASS),
|
||||
MALLOCX_ARENA(0));
|
||||
assert_ptr_not_null(large, "Unexpected mallocx() failure");
|
||||
|
||||
@@ -192,7 +192,7 @@ TEST_BEGIN(test_stats_arenas_large) {
|
||||
uint64_t epoch, nmalloc, ndalloc;
|
||||
int expected = config_stats ? 0 : ENOENT;
|
||||
|
||||
p = mallocx((1U << sc_data_global.lg_large_minclass), MALLOCX_ARENA(0));
|
||||
p = mallocx((1U << SC_LG_LARGE_MINCLASS), MALLOCX_ARENA(0));
|
||||
assert_ptr_not_null(p, "Unexpected mallocx() failure");
|
||||
|
||||
assert_d_eq(mallctl("epoch", NULL, NULL, (void *)&epoch, sizeof(epoch)),
|
||||
|
@@ -47,8 +47,7 @@ TEST_END
|
||||
|
||||
TEST_BEGIN(test_zero_large) {
|
||||
test_skip_if(!config_fill);
|
||||
test_zero(SC_SMALL_MAXCLASS + 1,
|
||||
1U << (sc_data_global.lg_large_minclass + 1));
|
||||
test_zero(SC_SMALL_MAXCLASS + 1, 1U << (SC_LG_LARGE_MINCLASS + 1));
|
||||
}
|
||||
TEST_END
|
||||
|
||||
|
Reference in New Issue
Block a user