From: Zhenghui Hao <zhenghui.hao@qq.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-parisc@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Helge Deller <deller@gmx.de>,
Christian Brauner <brauner@kernel.org>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
Breno Leitao <leitao@debian.org>, Kees Cook <kees@kernel.org>,
Ryan Roberts <ryan.roberts@arm.com>,
Lillian Berry <lillian@star-ark.net>,
Douglas Anderson <dianders@chromium.org>
Subject: [PATCH 1/2] init: parse early parameters before memory initialization
Date: Thu, 17 Sep 2026 14:55:56 +0800 [thread overview]
Message-ID: <tencent_5B0AF81532EB30CCA672E144A475625EAB08@qq.com> (raw)
In-Reply-To: <20260917065600.564083-1-zhenghui.hao@qq.com>
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@kernel.org>
Cc: Helge Deller <deller@gmx.de>
Signed-off-by: Zhenghui Hao <zhenghui.hao@qq.com>
---
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
next prev parent reply other threads:[~2026-09-17 6:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260917062837.558251-1-zhenghui.hao@qq.com>
2026-09-17 6:28 ` Zhenghui Hao
2026-09-17 6:28 ` [PATCH 2/2] hugetlb: report cmdline parameters recorded too late Zhenghui Hao
2026-09-17 6:55 ` [PATCH 0/2] init, hugetlb: fix early parameter ordering Zhenghui Hao
2026-09-17 7:41 ` Mike Rapoport
2026-09-17 9:19 ` zhenghui.hao
2026-09-17 9:45 ` Mike Rapoport
[not found] ` <tencent_B4700AD229B1E6D517FC751924185FD3BB07@qq.com>
2026-09-17 9:21 ` Mike Rapoport
[not found] ` <20260917065600.564083-1-zhenghui.hao@qq.com>
2026-09-17 6:55 ` Zhenghui Hao [this message]
2026-09-17 6:55 ` [PATCH 2/2] hugetlb: report cmdline parameters recorded too late Zhenghui Hao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_5B0AF81532EB30CCA672E144A475625EAB08@qq.com \
--to=zhenghui.hao@qq.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=deller@gmx.de \
--cc=dianders@chromium.org \
--cc=kees@kernel.org \
--cc=leitao@debian.org \
--cc=lillian@star-ark.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®