When extracting from central, hugify_eager is different than start_as_huge

This commit is contained in:
Slobodan Predolac 2025-10-13 11:37:49 -07:00
parent 0f8a8d7ebe
commit 6ced85a8e5
13 changed files with 235 additions and 9 deletions

View file

@ -98,6 +98,7 @@ CTL_PROTO(opt_abort_conf)
CTL_PROTO(opt_cache_oblivious)
CTL_PROTO(opt_debug_double_free_max_scan)
CTL_PROTO(opt_trust_madvise)
CTL_PROTO(opt_experimental_hpa_start_huge_if_thp_always)
CTL_PROTO(opt_confirm_conf)
CTL_PROTO(opt_hpa)
CTL_PROTO(opt_hpa_slab_max_alloc)
@ -464,6 +465,8 @@ static const ctl_named_node_t opt_node[] = {{NAME("abort"), CTL(opt_abort)},
{NAME("abort_conf"), CTL(opt_abort_conf)},
{NAME("cache_oblivious"), CTL(opt_cache_oblivious)},
{NAME("trust_madvise"), CTL(opt_trust_madvise)},
{NAME("experimental_hpa_start_huge_if_thp_always"),
CTL(opt_experimental_hpa_start_huge_if_thp_always)},
{NAME("confirm_conf"), CTL(opt_confirm_conf)}, {NAME("hpa"), CTL(opt_hpa)},
{NAME("hpa_slab_max_alloc"), CTL(opt_hpa_slab_max_alloc)},
{NAME("hpa_hugification_threshold"), CTL(opt_hpa_hugification_threshold)},
@ -2131,6 +2134,8 @@ CTL_RO_NL_GEN(opt_cache_oblivious, opt_cache_oblivious, bool)
CTL_RO_NL_GEN(
opt_debug_double_free_max_scan, opt_debug_double_free_max_scan, unsigned)
CTL_RO_NL_GEN(opt_trust_madvise, opt_trust_madvise, bool)
CTL_RO_NL_GEN(opt_experimental_hpa_start_huge_if_thp_always,
opt_experimental_hpa_start_huge_if_thp_always, bool)
CTL_RO_NL_GEN(opt_confirm_conf, opt_confirm_conf, bool)
/* HPA options. */

View file

@ -28,6 +28,8 @@ static uint64_t hpa_time_until_deferred_work(tsdn_t *tsdn, pai_t *self);
const char *const hpa_hugify_style_names[] = {"auto", "none", "eager", "lazy"};
bool opt_experimental_hpa_start_huge_if_thp_always = true;
bool
hpa_hugepage_size_exceeds_limit(void) {
return HUGEPAGE > HUGEPAGE_MAX_EXPECTED_SIZE;
@ -113,6 +115,9 @@ hpa_central_extract(tsdn_t *tsdn, hpa_central_t *central, size_t size,
*oom = false;
hpdata_t *ps = NULL;
bool start_as_huge = hugify_eager
|| (init_system_thp_mode == system_thp_mode_always
&& opt_experimental_hpa_start_huge_if_thp_always);
/* Is eden a perfect fit? */
if (central->eden != NULL && central->eden_len == HUGEPAGE) {
@ -122,7 +127,7 @@ hpa_central_extract(tsdn_t *tsdn, hpa_central_t *central, size_t size,
malloc_mutex_unlock(tsdn, &central->grow_mtx);
return NULL;
}
hpdata_init(ps, central->eden, age, hugify_eager);
hpdata_init(ps, central->eden, age, start_as_huge);
central->eden = NULL;
central->eden_len = 0;
malloc_mutex_unlock(tsdn, &central->grow_mtx);
@ -170,7 +175,7 @@ hpa_central_extract(tsdn_t *tsdn, hpa_central_t *central, size_t size,
assert(central->eden_len % HUGEPAGE == 0);
assert(HUGEPAGE_ADDR2BASE(central->eden) == central->eden);
hpdata_init(ps, central->eden, age, hugify_eager);
hpdata_init(ps, central->eden, age, start_as_huge);
char *eden_char = (char *)central->eden;
eden_char += HUGEPAGE;

View file

@ -1302,6 +1302,9 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
CONF_HANDLE_BOOL(opt_abort_conf, "abort_conf")
CONF_HANDLE_BOOL(opt_cache_oblivious, "cache_oblivious")
CONF_HANDLE_BOOL(opt_trust_madvise, "trust_madvise")
CONF_HANDLE_BOOL(
opt_experimental_hpa_start_huge_if_thp_always,
"experimental_hpa_start_huge_if_thp_always")
CONF_HANDLE_BOOL(
opt_huge_arena_pac_thp, "huge_arena_pac_thp")
if (strncmp("metadata_thp", k, klen) == 0) {
@ -1647,7 +1650,8 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
if (strncmp("hpa_hugify_style", k, klen) == 0) {
bool match = false;
for (int m = 0; m < hpa_hugify_style_limit; m++) {
for (int m = 0; m < hpa_hugify_style_limit;
m++) {
if (strncmp(hpa_hugify_style_names[m],
v, vlen)
== 0) {

View file

@ -1604,6 +1604,7 @@ stats_general_print(emitter_t *emitter) {
OPT_WRITE_BOOL("abort_conf")
OPT_WRITE_BOOL("cache_oblivious")
OPT_WRITE_BOOL("confirm_conf")
OPT_WRITE_BOOL("experimental_hpa_start_huge_if_thp_always")
OPT_WRITE_BOOL("retain")
OPT_WRITE_CHAR_P("dss")
OPT_WRITE_UNSIGNED("narenas")