[PATCH v2 0/5] LoongArch: ftrace: Add direct call support and code simplification

From: Youling Tang
Date: Wed Apr 26 2023 - 22:13:47 EST


[Patch 1-2]: Fix build errors and simplify code.

[Patch 3-4]:
This series adds DYNAMIC_FTRACE_WITH_DIRECT_CALLS support for LoongArch.
SAMPLE_FTRACE_DIRECT and SAMPLE_FTRACE_DIRECT_MULTI are also included
here as the samples for testing DIRECT_CALLS related interface.

Part of the code refers to arm64 and riscv.

The following tests have been passed in my local 3A5000 machine.
- ftrace*.ko
- tools/testing/selftests/ftrace/

eg:
[loongson@linux linux]$ sudo insmod samples/ftrace/ftrace-direct-too.ko
[root@linux linux]# cat /sys/kernel/debug/tracing/trace | tail
rmmod-4552 [001] ..... 3166.654540: 0xffff800002094040: handle mm fault vma=00000000d0dbdb16 address=7ffff2a793e8 flags=254
rmmod-4552 [001] ..... 3166.654550: 0xffff800002094040: handle mm fault vma=0000000047694d8b address=555570700008 flags=255
rmmod-4552 [001] ..... 3166.654557: 0xffff800002094040: handle mm fault vma=00000000d0dbdb16 address=7ffff29e6eb0 flags=254
rmmod-4552 [001] ..... 3166.654561: 0xffff800002094040: handle mm fault vma=00000000d0dbdb16 address=7ffff297d480 flags=254

[Patch 5]: Abstract DYNAMIC_FTRACE_WITH_ARGS accesses.
Note: This patch depends on regs_set_return_value() in the patch
"LoongArch: Add support for function error injection".


Changes in v2:
- Rewrite commit message.

Qing Zhang (1):
LoongArch: Abstract DYNAMIC_FTRACE_WITH_ARGS accesses

Youling Tang (4):
LoongArch: Fix build error if CONFIG_DYNAMIC_FTRACE_WITH_REGS is not
set
LoongArch: ftrace: Implement ftrace_find_callable_addr() to simplify
code
LoongArch: ftrace: Add direct call support
LoongArch: ftrace: Add direct call trampoline samples support

arch/loongarch/Kconfig | 3 +
arch/loongarch/include/asm/ftrace.h | 37 ++++++
arch/loongarch/kernel/ftrace_dyn.c | 132 +++++++++++---------
arch/loongarch/kernel/mcount_dyn.S | 7 +-
samples/ftrace/ftrace-direct-modify.c | 34 +++++
samples/ftrace/ftrace-direct-multi-modify.c | 41 ++++++
samples/ftrace/ftrace-direct-multi.c | 25 ++++
samples/ftrace/ftrace-direct-too.c | 27 ++++
samples/ftrace/ftrace-direct.c | 23 ++++
9 files changed, 266 insertions(+), 63 deletions(-)

--
2.37.1