[PATCH] LoongArch: Move jump_label_init() before parse_early_param()

Kanglong Wang posted 1 patch 2 days, 11 hours ago
arch/loongarch/kernel/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] LoongArch: Move jump_label_init() before parse_early_param()
Posted by Kanglong Wang 2 days, 11 hours ago
When enabling CONFIG_MEM_ALLOC_PROFILING=y and
CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, then diabling memory
profiling by adding the boot parameter 'sysctl.vm.mem_profiling=0', will
cause the kernel failed to boot.

After analysis, this is because jump_label_init() must be called before
parse_early_param(), early param handlers may modify static keys by
static_branch_enable/disable().

Fix this by moving jump_label_init() before parse_early_param(). The
solution is similar to other architectures.

Cc: <stable@vger.kernel.org>
Signed-off-by: Kanglong Wang <wangkanglong@loongson.cn>
---
 arch/loongarch/kernel/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index eaebb52bd36e..deeff4a1b411 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -603,6 +603,7 @@ void __init setup_arch(char **cmdline_p)
 	memblock_init();
 	pagetable_init();
 	bootcmdline_init(cmdline_p);
+	jump_label_init(); /* Initialise the static keys for parse_early_param */
 	parse_early_param();
 	reserve_initrd_mem();
 
@@ -610,7 +611,6 @@ void __init setup_arch(char **cmdline_p)
 	arch_mem_init(cmdline_p);
 
 	resource_init();
-	jump_label_init(); /* Initialise the static keys for paravirtualization */
 
 #ifdef CONFIG_SMP
 	plat_smp_setup();
-- 
2.20.1