aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include/asm/module.h
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2021-07-28 23:25:46 +0200
committerHeiko Carstens <hca@linux.ibm.com>2021-08-03 14:31:40 +0200
commitde5012b41e5c900a8a3875c7a825394c5f624c05 (patch)
treef600d606c61f8254975b82c70466adfdb7a1e325 /arch/s390/include/asm/module.h
parentftrace: Introduce ftrace_need_init_nop() (diff)
downloadlinux-dev-de5012b41e5c900a8a3875c7a825394c5f624c05.tar.xz
linux-dev-de5012b41e5c900a8a3875c7a825394c5f624c05.zip
s390/ftrace: implement hotpatching
s390 allows hotpatching the mask of a conditional jump instruction. Make use of this feature in order to avoid the expensive stop_machine() call. The new trampolines are split in 3 stages: - A first stage is a 6-byte relative conditional long branch located at each function's entry point. Its offset always points to the second stage for the corresponding function, and its mask is either all 0s (ftrace off) or all 1s (ftrace on). The code for flipping the mask is borrowed from ftrace_{enable,disable}_ftrace_graph_caller. After flipping, ftrace_arch_code_modify_post_process() syncs with all the other CPUs by sending SIGPs. - Second stages for vmlinux are stored in a separate part of the .text section reserved by the linker script, and in dynamically allocated memory for modules. This prevents the icache pollution. The total size of second stages is about 1.5% of that of the kernel image. Putting second stages in the .bss section is possible and decreases the size of the non-compressed vmlinux, but splits the kernel 1:1 mapping, which is a bad tradeoff. Each second stage contains a call to the third stage, a pointer to the part of the intercepted function right after the first stage, and a pointer to an interceptor function (e.g. ftrace_caller). Second stages are 8-byte aligned for the future direct calls implementation. - There are only two copies of the third stage: in the .text section for vmlinux and in dynamically allocated memory for modules. It can be an expoline, which is relatively large, so inlining it into each second stage is prohibitively expensive. As a result of this organization, phoronix-test-suite with ftrace off does not show any performance degradation. Suggested-by: Sven Schnelle <svens@linux.ibm.com> Suggested-by: Vasily Gorbik <gor@linux.ibm.com> Co-developed-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Link: https://lore.kernel.org/r/20210728212546.128248-3-iii@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/include/asm/module.h')
-rw-r--r--arch/s390/include/asm/module.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/s390/include/asm/module.h b/arch/s390/include/asm/module.h
index 71e57b8af757..9f1eea15872c 100644
--- a/arch/s390/include/asm/module.h
+++ b/arch/s390/include/asm/module.h
@@ -28,6 +28,14 @@ struct mod_arch_specific {
int nsyms;
/* Additional symbol information (got and plt offsets). */
struct mod_arch_syminfo *syminfo;
+#ifdef CONFIG_FUNCTION_TRACER
+ /* Start of memory reserved for ftrace hotpatch trampolines. */
+ struct ftrace_hotpatch_trampoline *trampolines_start;
+ /* End of memory reserved for ftrace hotpatch trampolines. */
+ struct ftrace_hotpatch_trampoline *trampolines_end;
+ /* Next unused ftrace hotpatch trampoline slot. */
+ struct ftrace_hotpatch_trampoline *next_trampoline;
+#endif /* CONFIG_FUNCTION_TRACER */
};
#endif /* _ASM_S390_MODULE_H */