[PATCH 1/2] init: parse early parameters before memory initialization
From: Zhenghui Hao
Date: Thu Sep 17 2026 - 03:01:06 EST
The hugepages=, hugepagesz= and default_hugepagesz= parameters are
recorded by early_param() handlers and consumed by
hugetlb_bootmem_alloc(), which is called from mm_core_init_early().
Commit d49004c5f0c1 ("arch, mm: consolidate initialization of nodes,
zones and memory map") introduced mm_core_init_early() and placed it
immediately after setup_arch(), i.e. before the generic
parse_early_param() call in start_kernel(). Before that commit,
hugetlb_bootmem_alloc() was called from mm_core_init(), which runs
after parse_early_param().
Architectures that call parse_early_param() from setup_arch() are
unaffected, since parse_early_param() only does anything on the first
call. On parisc, which relies on the generic call, the parameters are
recorded after they have been consumed and are therefore silently
dropped: neither do_early_param() nor obsolete_checksetup() reports
them. hugetlb_cma= and hugetlb_free_vmemmap= are affected in the same
way, because hugetlb_cma_reserve() and sparse_init() also run from
mm_core_init_early().
Move parse_early_param() before mm_core_init_early(). To keep the
"parameters may set static keys" guarantee, move jump_label_init() and
static_call_init() up as well, so that they still run first. None of
the functions called from mm_core_init_early() uses static keys, so
running it after jump_label_init() is safe.
Moving the generic call, instead of adding a parse_early_param() call
to parisc setup_arch(), fixes all architectures at once and makes
"early parameters are parsed before memory initialization" an
invariant.
Not tested on parisc hardware.
Fixes: d49004c5f0c1 ("arch, mm: consolidate initialization of nodes, zones and memory map")
Cc: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
Cc: Helge Deller <deller@xxxxxx>
Signed-off-by: Zhenghui Hao <zhenghui.hao@xxxxxx>
---
init/main.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/init/main.c b/init/main.c
index 31f2bf54976a..bccf521910be 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1007,10 +1007,12 @@ void start_kernel(void)
page_address_init();
pr_notice("%s", linux_banner);
setup_arch(&command_line);
- mm_core_init_early();
- /* Static keys and static calls are needed by LSMs */
+ /* Static keys and static calls are needed by LSMs and early params */
jump_label_init();
static_call_init();
+ /* parameters may set static keys */
+ parse_early_param();
+ mm_core_init_early();
early_security_init();
setup_boot_config();
setup_command_line(command_line);
@@ -1021,8 +1023,6 @@ void start_kernel(void)
boot_cpu_hotplug_init();
print_kernel_cmdline(saved_command_line);
- /* parameters may set static keys */
- parse_early_param();
after_dashes = parse_args("Booting kernel",
static_command_line, __start___param,
__stop___param - __start___param,
--
2.53.0