diff options
| author | Christophe Leroy <[email protected]> | 2022-03-22 15:40:20 +0000 |
|---|---|---|
| committer | Michael Ellerman <[email protected]> | 2022-05-11 13:06:39 +0000 |
| commit | b033767848c4115e486b1a51946de3bee2ac0fa6 (patch) | |
| tree | 92673a5723ab58269ac2e7d458fa8f4e45643796 /arch/powerpc/lib/code-patching.c | |
| parent | powerpc/code-patching: Don't call is_vmalloc_or_module_addr() without CONFIG_... (diff) | |
| download | kernel-b033767848c4115e486b1a51946de3bee2ac0fa6.tar.gz kernel-b033767848c4115e486b1a51946de3bee2ac0fa6.zip | |
powerpc/code-patching: Use jump_label for testing freed initmem
Once init is done, initmem is freed forever so no need to
test system_state at every call to patch_instruction().
Use jump_label.
This reduces by 2% the time needed to activate ftrace on an 8xx.
Signed-off-by: Christophe Leroy <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/0aee964721cab7316cffde21a2ca223cee14d373.1647962456.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/lib/code-patching.c')
| -rw-r--r-- | arch/powerpc/lib/code-patching.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/powerpc/lib/code-patching.c b/arch/powerpc/lib/code-patching.c index f970f189875b..1ecd166091c9 100644 --- a/arch/powerpc/lib/code-patching.c +++ b/arch/powerpc/lib/code-patching.c @@ -8,6 +8,7 @@ #include <linux/init.h> #include <linux/cpuhotplug.h> #include <linux/uaccess.h> +#include <linux/jump_label.h> #include <asm/tlbflush.h> #include <asm/page.h> @@ -188,10 +189,12 @@ static int do_patch_instruction(u32 *addr, ppc_inst_t instr) #endif /* CONFIG_STRICT_KERNEL_RWX */ +__ro_after_init DEFINE_STATIC_KEY_FALSE(init_mem_is_free); + int patch_instruction(u32 *addr, ppc_inst_t instr) { /* Make sure we aren't patching a freed init section */ - if (system_state >= SYSTEM_FREEING_INITMEM && init_section_contains(addr, 4)) + if (static_branch_likely(&init_mem_is_free) && init_section_contains(addr, 4)) return 0; return do_patch_instruction(addr, instr); |
