linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 00/12] tracing: fprobe: rethook: Use ftrace_regs instead of pt_regs
@ 2023-09-24 13:35 Masami Hiramatsu (Google)
  2023-09-24 13:35 ` [PATCH v5 01/12] riscv: ftrace: Fix to pass correct ftrace_regs to ftrace_func_t functions Masami Hiramatsu (Google)
                   ` (12 more replies)
  0 siblings, 13 replies; 24+ messages in thread
From: Masami Hiramatsu (Google) @ 2023-09-24 13:35 UTC (permalink / raw)
  To: Alexei Starovoitov, Steven Rostedt, Florent Revest
  Cc: linux-trace-kernel, LKML, Martin KaFai Lau, bpf, Sven Schnelle,
	Alexei Starovoitov, Jiri Olsa, Arnaldo Carvalho de Melo,
	Daniel Borkmann, Alan Maguire, Mark Rutland, Peter Zijlstra,
	Thomas Gleixner, Guo Ren

Hi,

Here is the 5th version of the series to use ftrace_regs instead of pt_regs
in fprobe.
The previous version is here;

https://lore.kernel.org/all/169280372795.282662.9784422934484459769.stgit@devnote2/

In this version, I decided to use perf's own per-cpu pt_regs array to
copy the required registers[8/12]. Thus this version adds a patch which
adds a new ftrace_fill_perf_regs() API. So the ftrace_partial_regs() will
be used for BPF and ftrace_fill_perf_regs() is used for perf events.

This also adds a fix for RISCV ftrace[1/12]. When kernel is built with
disabling CONFIG_DYNAMIC_FTRACE_WITH_REGS on RISCV, it stores partial
registers on the stack, but it doesn't make it fit to struct ftrace_regs.
But since the 4th argument of ftrace_func_t is ftrace_regs *, it breaks
the ABI. So fixing it to save registers on ftrace_regs (== pt_regs on RISCV).

Another new patch [3/12] is adding a comment about the requirements for
the ftrace_regs.

 - RISCV ftrace fix to save registers on struct ftrace_regs correctly.
 - Document fix for the current fprobe callback prototype.
 - Add a comment of requirement for the ftrace_regs.
 - Simply replace pt_regs in fprobe_entry_handler with ftrace_regs.
 - Expose ftrace_regs even if CONFIG_FUNCTION_TRACER=n.
 - Introduce ftrace_partial_regs(). (This changes ARM64 which needs a custom
   implementation)
 - Introduce ftrace_fill_perf_regs() for perf pt_regs.
 - Replace pt_regs in rethook and fprobe_exit_handler with ftrace_regs. This
   introduce a new HAVE_PT_REGS_TO_FTRACE_REGS_CAST which means ftrace_regs is
   just a wrapper of pt_regs (except for arm64, other architectures do this)
 - Update fprobe-events to use ftrace_regs natively.
 - Update bpf multi-kprobe handler use ftrace_partial_regs().
 - Update document for new fprobe callbacks.
 - Add notes for the $argN and $retval.

This series can be applied against the trace-v6.6-rc2 on linux-trace tree.

This series can also be found below branch.

https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git/log/?h=topic/fprobe-ftrace-regs

Thank you,

---

Masami Hiramatsu (Google) (12):
      riscv: ftrace: Fix to pass correct ftrace_regs to ftrace_func_t functions
      Documentation: probes: Add a new ret_ip callback parameter
      tracing: Add a comment about the requirements of the ftrace_regs
      fprobe: Use ftrace_regs in fprobe entry handler
      tracing: Expose ftrace_regs regardless of CONFIG_FUNCTION_TRACER
      fprobe: rethook: Use ftrace_regs in fprobe exit handler and rethook
      tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs
      tracing: Add ftrace_fill_perf_regs() for perf event
      tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS
      bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled
      Documentation: probes: Update fprobe document to use ftrace_regs
      Documentation: tracing: Add a note about argument and retval access


 Documentation/trace/fprobe.rst      |   18 +++--
 Documentation/trace/fprobetrace.rst |    8 ++
 Documentation/trace/kprobetrace.rst |    8 ++
 arch/Kconfig                        |    1 
 arch/arm64/include/asm/ftrace.h     |   18 +++++
 arch/loongarch/Kconfig              |    1 
 arch/loongarch/kernel/rethook.c     |   10 +--
 arch/loongarch/kernel/rethook.h     |    4 +
 arch/powerpc/include/asm/ftrace.h   |    7 ++
 arch/riscv/kernel/mcount-dyn.S      |   67 ++++++++----------
 arch/riscv/kernel/probes/rethook.c  |   12 ++-
 arch/riscv/kernel/probes/rethook.h  |    6 +-
 arch/s390/Kconfig                   |    1 
 arch/s390/include/asm/ftrace.h      |    9 ++
 arch/s390/kernel/rethook.c          |   10 ++-
 arch/s390/kernel/rethook.h          |    2 -
 arch/x86/Kconfig                    |    1 
 arch/x86/include/asm/ftrace.h       |    7 ++
 arch/x86/kernel/rethook.c           |   13 ++--
 include/linux/fprobe.h              |    4 +
 include/linux/ftrace.h              |  128 +++++++++++++++++++++++++++++------
 include/linux/rethook.h             |   11 ++-
 kernel/kprobes.c                    |   10 ++-
 kernel/trace/Kconfig                |    9 ++
 kernel/trace/bpf_trace.c            |   14 ++--
 kernel/trace/fprobe.c               |   10 +--
 kernel/trace/rethook.c              |   16 ++--
 kernel/trace/trace_fprobe.c         |   70 +++++++++++--------
 kernel/trace/trace_probe_tmpl.h     |    2 -
 lib/test_fprobe.c                   |   10 +--
 samples/fprobe/fprobe_example.c     |    4 +
 31 files changed, 327 insertions(+), 164 deletions(-)

--
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2023-10-02 15:39 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-24 13:35 [PATCH v5 00/12] tracing: fprobe: rethook: Use ftrace_regs instead of pt_regs Masami Hiramatsu (Google)
2023-09-24 13:35 ` [PATCH v5 01/12] riscv: ftrace: Fix to pass correct ftrace_regs to ftrace_func_t functions Masami Hiramatsu (Google)
2023-09-24 13:36 ` [PATCH v5 02/12] Documentation: probes: Add a new ret_ip callback parameter Masami Hiramatsu (Google)
2023-09-24 13:36 ` [PATCH v5 03/12] tracing: Add a comment about the requirements of the ftrace_regs Masami Hiramatsu (Google)
2023-09-24 13:36 ` [PATCH v5 04/12] fprobe: Use ftrace_regs in fprobe entry handler Masami Hiramatsu (Google)
2023-09-25 10:41   ` Jiri Olsa
2023-09-25 12:15     ` Masami Hiramatsu
2023-09-25 22:14       ` Jiri Olsa
2023-09-26  0:20         ` Masami Hiramatsu
2023-09-26  7:23           ` Jiri Olsa
2023-09-26 11:49             ` Jiri Olsa
2023-09-26 14:47               ` Masami Hiramatsu
2023-09-24 13:36 ` [PATCH v5 05/12] tracing: Expose ftrace_regs regardless of CONFIG_FUNCTION_TRACER Masami Hiramatsu (Google)
2023-09-24 13:37 ` [PATCH v5 06/12] fprobe: rethook: Use ftrace_regs in fprobe exit handler and rethook Masami Hiramatsu (Google)
2023-09-24 13:37 ` [PATCH v5 07/12] tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs Masami Hiramatsu (Google)
2023-09-24 13:37 ` [PATCH v5 08/12] tracing: Add ftrace_fill_perf_regs() for perf event Masami Hiramatsu (Google)
2023-09-24 13:37 ` [PATCH v5 09/12] tracing/fprobe: Enable fprobe events with CONFIG_DYNAMIC_FTRACE_WITH_ARGS Masami Hiramatsu (Google)
2023-09-24 13:37 ` [PATCH v5 10/12] bpf: Enable kprobe_multi feature if CONFIG_FPROBE is enabled Masami Hiramatsu (Google)
2023-09-24 13:38 ` [PATCH v5 11/12] Documentation: probes: Update fprobe document to use ftrace_regs Masami Hiramatsu (Google)
2023-09-24 13:38 ` [PATCH v5 12/12] Documentation: tracing: Add a note about argument and retval access Masami Hiramatsu (Google)
2023-09-29  1:21 ` [PATCH v5 00/12] tracing: fprobe: rethook: Use ftrace_regs instead of pt_regs Masami Hiramatsu
2023-09-30  0:12   ` Alexei Starovoitov
2023-09-30  9:14     ` Masami Hiramatsu
2023-10-02 15:39       ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).