From 4610ffa942a00d80a8e8af2365069bed7d561415 Mon Sep 17 00:00:00 2001 From: "David T. Goldblatt" Date: Fri, 20 Apr 2018 19:12:45 -0700 Subject: [PATCH] Bootstrapping: Parse MALLOC_CONF before using slab sizes. I.e., parse before booting the bin module or sz module. This lets us tweak size class settings before committing to them by letting them leak into other modules. This commit does not actually do any tweaking of the size classes; it *just* chanchanges bootstrapping order; this may help bisecting any bootstrapping failures on poorly-tested architectures. --- src/jemalloc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jemalloc.c b/src/jemalloc.c index 664c5f89..902bf9c3 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1295,14 +1295,21 @@ static bool malloc_init_hard_a0_locked() { malloc_initializer = INITIALIZER; + /* + * Ordering here is somewhat tricky; we need sc_boot() first, since that + * determines what the size classes will be, and then + * malloc_conf_init(), since any slab size tweaking will need to be done + * before sz_boot and bin_boot, which assume that the values they read + * out of sc_data_global are final. + */ sc_boot(); + malloc_conf_init(); sz_boot(&sc_data_global); bin_boot(&sc_data_global); if (config_prof) { prof_boot0(); } - malloc_conf_init(); if (opt_stats_print) { /* Print statistics at exit. */ if (atexit(stats_print_atexit) != 0) {