WSL2-Linux-Kernel/arch/s390
Ilya Leoshkevich de5012b41e 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>
2021-08-03 14:31:40 +02:00
..
appldata
boot s390: move the install rule to arch/s390/Makefile 2021-07-30 17:09:36 +02:00
configs s390: update defconfigs 2021-07-20 17:59:40 +02:00
crypto
hypfs s390/hypfs: use register pair instead of register asm 2021-06-28 11:18:28 +02:00
include s390/ftrace: implement hotpatching 2021-08-03 14:31:40 +02:00
kernel s390/ftrace: implement hotpatching 2021-08-03 14:31:40 +02:00
kvm s390 updates for the 5.14 merge window 2021-07-04 12:17:38 -07:00
lib s390/delay: get rid of not needed header includes 2021-07-27 09:39:22 +02:00
mm s390: add kfence region to pagetable dumper 2021-07-30 17:09:02 +02:00
net s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1] 2021-07-15 19:47:25 +02:00
pci s390: make PCI mio support a machine flag 2021-07-27 09:39:19 +02:00
purgatory s390: enable KCSAN 2021-07-30 17:09:23 +02:00
tools s390/disassembler: add instructions 2021-07-27 09:39:19 +02:00
Kbuild
Kconfig s390: enable KCSAN 2021-07-30 17:09:23 +02:00
Kconfig.debug
Makefile s390: move the install rule to arch/s390/Makefile 2021-07-30 17:09:36 +02:00