Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/code-patching: Use jump_label to check if poking_init() is done

It's only during early startup that poking_init() is not done yet,
for instance when calling ftrace_init().

Once poking_init() has been called there must be a poking area, no
need to check it everytime patch_instruction() is called.

ftrace activation time is reduced by 7% with the change on an 8xx.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8d6088aca7b63247377b6d9e4897d08d935fbe93.1647962456.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
17512892 b0337678

+4 -1
+4 -1
arch/powerpc/lib/code-patching.c
··· 79 79 return 0; 80 80 } 81 81 82 + static __ro_after_init DEFINE_STATIC_KEY_FALSE(poking_init_done); 83 + 82 84 /* 83 85 * Although BUG_ON() is rude, in this case it should only happen if ENOMEM, and 84 86 * we judge it as being preferable to a kernel that will crash later when ··· 91 89 BUG_ON(!cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, 92 90 "powerpc/text_poke:online", text_area_cpu_up, 93 91 text_area_cpu_down)); 92 + static_branch_enable(&poking_init_done); 94 93 } 95 94 96 95 /* ··· 174 171 * when text_poke_area is not ready, but we still need 175 172 * to allow patching. We just do the plain old patching 176 173 */ 177 - if (!this_cpu_read(text_poke_area)) 174 + if (!static_branch_likely(&poking_init_done)) 178 175 return raw_patch_instruction(addr, instr); 179 176 180 177 local_irq_save(flags);