From 366a2cd9c03b865b297a9e59be0a96829a1e884a Mon Sep 17 00:00:00 2001 From: Slobodan Predolac Date: Thu, 21 May 2026 14:11:40 -0700 Subject: [PATCH] Internalize malloc_conf_2_conf_harder ctl --- include/jemalloc/internal/jemalloc_internal_externs.h | 1 + src/ctl.c | 8 +------- src/stats.c | 7 +++---- test/unit/malloc_conf_2.c | 7 ------- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/jemalloc/internal/jemalloc_internal_externs.h b/include/jemalloc/internal/jemalloc_internal_externs.h index b5b12e91..cd458ff8 100644 --- a/include/jemalloc/internal/jemalloc_internal_externs.h +++ b/include/jemalloc/internal/jemalloc_internal_externs.h @@ -46,6 +46,7 @@ extern bool opt_disable_large_size_classes; extern const char *opt_malloc_conf_symlink; extern const char *opt_malloc_conf_env_var; +extern const char *je_malloc_conf_2_conf_harder; /* Escape free-fastpath when ptr & mask == 0 (for sanitization purpose). */ extern uintptr_t san_cache_bin_nonfast_mask; diff --git a/src/ctl.c b/src/ctl.c index 592f764b..2112c26e 100644 --- a/src/ctl.c +++ b/src/ctl.c @@ -173,7 +173,6 @@ CTL_PROTO(opt_process_madvise_max_batch) CTL_PROTO(opt_malloc_conf_symlink) CTL_PROTO(opt_malloc_conf_env_var) CTL_PROTO(opt_malloc_conf_global_var) -CTL_PROTO(opt_malloc_conf_global_var_2_conf_harder) CTL_PROTO(tcache_create) CTL_PROTO(tcache_flush) CTL_PROTO(tcache_destroy) @@ -468,9 +467,7 @@ static const ctl_named_node_t config_node[] = { static const ctl_named_node_t opt_malloc_conf_node[] = { {NAME("symlink"), CTL(opt_malloc_conf_symlink)}, {NAME("env_var"), CTL(opt_malloc_conf_env_var)}, - {NAME("global_var"), CTL(opt_malloc_conf_global_var)}, - {NAME("global_var_2_conf_harder"), - CTL(opt_malloc_conf_global_var_2_conf_harder)}}; + {NAME("global_var"), CTL(opt_malloc_conf_global_var)}}; static const ctl_named_node_t opt_node[] = {{NAME("abort"), CTL(opt_abort)}, {NAME("abort_conf"), CTL(opt_abort_conf)}, @@ -2304,9 +2301,6 @@ CTL_RO_NL_CGEN(opt_malloc_conf_env_var, opt_malloc_conf_env_var, opt_malloc_conf_env_var, const char *) CTL_RO_NL_CGEN( je_malloc_conf, opt_malloc_conf_global_var, je_malloc_conf, const char *) -CTL_RO_NL_CGEN(je_malloc_conf_2_conf_harder, - opt_malloc_conf_global_var_2_conf_harder, je_malloc_conf_2_conf_harder, - const char *) /******************************************************************************/ diff --git a/src/stats.c b/src/stats.c index 65583393..5fa37529 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1708,10 +1708,9 @@ stats_general_print(emitter_t *emitter) { MALLOC_CONF_WRITE("global_var", "Global variable malloc_conf"); MALLOC_CONF_WRITE("symlink", "Symbolic link malloc.conf"); MALLOC_CONF_WRITE("env_var", "Environment variable MALLOC_CONF"); - /* As this config is unofficial, skip the output if it's NULL */ - if (je_mallctl("opt.malloc_conf.global_var_2_conf_harder", (void *)&cpv, - &cpsz, NULL, 0) - == 0) { + /* As this config is unofficial, skip the output if it's NULL. */ + if (je_malloc_conf_2_conf_harder != NULL) { + cpv = je_malloc_conf_2_conf_harder; emitter_kv(emitter, "global_var_2_conf_harder", "Global " "variable malloc_conf_2_conf_harder", diff --git a/test/unit/malloc_conf_2.c b/test/unit/malloc_conf_2.c index 667e7006..eb6856c8 100644 --- a/test/unit/malloc_conf_2.c +++ b/test/unit/malloc_conf_2.c @@ -39,13 +39,6 @@ TEST_BEGIN(test_mallctl_global_var) { expect_str_eq(mc, malloc_conf, "Unexpected value for the global variable " "malloc_conf"); - - expect_d_eq(mallctl("opt.malloc_conf.global_var_2_conf_harder", - (void *)&mc, &sz, NULL, 0), - 0, "Unexpected mallctl() failure"); - expect_str_eq(mc, malloc_conf_2_conf_harder, - "Unexpected value for the " - "global variable malloc_conf_2_conf_harder"); } TEST_END