mbox series

[v12,bpf-next,00/12] fprobe: Introduce fprobe function entry/exit probe

Message ID 164735281449.1084943.12438881786173547153.stgit@devnote2 (mailing list archive)
Headers show
Series fprobe: Introduce fprobe function entry/exit probe | expand

Message

Masami Hiramatsu (Google) March 15, 2022, 2 p.m. UTC
Hi,

Here is the 12th version of fprobe. This version fixes a possible gcc-11 issue which
was reported as kretprobes on arm issue, and also I updated the fprobe document.

The previous version (v11) is here[1];

[1] https://lore.kernel.org/all/164701432038.268462.3329725152949938527.stgit@devnote2/T/#u

This series introduces the fprobe, the function entry/exit probe
with multiple probe point support for x86, arm64 and powerpc64le.
This also introduces the rethook for hooking function return as same as
the kretprobe does. This abstraction will help us to generalize the fgraph
tracer, because we can just switch to it from the rethook in fprobe,
depending on the kernel configuration.

The patch [1/12] is from Jiri's series[2].

[2] https://lore.kernel.org/all/20220104080943.113249-1-jolsa@kernel.org/T/#u

And the patch [9/10] adds the FPROBE_FL_KPROBE_SHARED flag for the case
if user wants to share the same code (or share a same resource) on the
fprobe and the kprobes.

I forcibly updated my kprobes/fprobe branch, you can pull this series
from:

 https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git kprobes/fprobe

Thank you,

---

Jiri Olsa (1):
      ftrace: Add ftrace_set_filter_ips function

Masami Hiramatsu (11):
      fprobe: Add ftrace based probe APIs
      rethook: Add a generic return hook
      rethook: x86: Add rethook x86 implementation
      arm64: rethook: Add arm64 rethook implementation
      powerpc: Add rethook support
      ARM: rethook: Add rethook arm implementation
      fprobe: Add exit_handler support
      fprobe: Add sample program for fprobe
      fprobe: Introduce FPROBE_FL_KPROBE_SHARED flag for fprobe
      docs: fprobe: Add fprobe description to ftrace-use.rst
      fprobe: Add a selftest for fprobe


 Documentation/trace/fprobe.rst                |  174 +++++++++++++
 Documentation/trace/index.rst                 |    1 
 arch/arm/Kconfig                              |    1 
 arch/arm/include/asm/stacktrace.h             |    4 
 arch/arm/kernel/stacktrace.c                  |    6 
 arch/arm/probes/Makefile                      |    1 
 arch/arm/probes/rethook.c                     |  103 ++++++++
 arch/arm64/Kconfig                            |    1 
 arch/arm64/include/asm/stacktrace.h           |    2 
 arch/arm64/kernel/probes/Makefile             |    1 
 arch/arm64/kernel/probes/rethook.c            |   25 ++
 arch/arm64/kernel/probes/rethook_trampoline.S |   87 +++++++
 arch/arm64/kernel/stacktrace.c                |    7 -
 arch/powerpc/Kconfig                          |    1 
 arch/powerpc/kernel/Makefile                  |    1 
 arch/powerpc/kernel/rethook.c                 |   72 +++++
 arch/x86/Kconfig                              |    1 
 arch/x86/include/asm/unwind.h                 |    8 +
 arch/x86/kernel/Makefile                      |    1 
 arch/x86/kernel/kprobes/common.h              |    1 
 arch/x86/kernel/rethook.c                     |  119 +++++++++
 include/linux/fprobe.h                        |  105 ++++++++
 include/linux/ftrace.h                        |    3 
 include/linux/kprobes.h                       |    3 
 include/linux/rethook.h                       |  100 ++++++++
 include/linux/sched.h                         |    3 
 kernel/exit.c                                 |    2 
 kernel/fork.c                                 |    3 
 kernel/trace/Kconfig                          |   26 ++
 kernel/trace/Makefile                         |    2 
 kernel/trace/fprobe.c                         |  332 +++++++++++++++++++++++++
 kernel/trace/ftrace.c                         |   58 ++++
 kernel/trace/rethook.c                        |  317 ++++++++++++++++++++++++
 lib/Kconfig.debug                             |   12 +
 lib/Makefile                                  |    2 
 lib/test_fprobe.c                             |  174 +++++++++++++
 samples/Kconfig                               |    7 +
 samples/Makefile                              |    1 
 samples/fprobe/Makefile                       |    3 
 samples/fprobe/fprobe_example.c               |  120 +++++++++
 40 files changed, 1876 insertions(+), 14 deletions(-)
 create mode 100644 Documentation/trace/fprobe.rst
 create mode 100644 arch/arm/probes/rethook.c
 create mode 100644 arch/arm64/kernel/probes/rethook.c
 create mode 100644 arch/arm64/kernel/probes/rethook_trampoline.S
 create mode 100644 arch/powerpc/kernel/rethook.c
 create mode 100644 arch/x86/kernel/rethook.c
 create mode 100644 include/linux/fprobe.h
 create mode 100644 include/linux/rethook.h
 create mode 100644 kernel/trace/fprobe.c
 create mode 100644 kernel/trace/rethook.c
 create mode 100644 lib/test_fprobe.c
 create mode 100644 samples/fprobe/Makefile
 create mode 100644 samples/fprobe/fprobe_example.c

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

Comments

Masami Hiramatsu (Google) March 15, 2022, 2:42 p.m. UTC | #1
On Tue, 15 Mar 2022 23:00:14 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:

> Hi,
> 
> Here is the 12th version of fprobe. This version fixes a possible gcc-11 issue which
> was reported as kretprobes on arm issue, and also I updated the fprobe document.

Here is the gcc-11 build issue thread for reference.

https://lore.kernel.org/all/202203150516.KTorSVVU-lkp@intel.com/T/#u

Thank you,

> 
> The previous version (v11) is here[1];
> 
> [1] https://lore.kernel.org/all/164701432038.268462.3329725152949938527.stgit@devnote2/T/#u
> 
> This series introduces the fprobe, the function entry/exit probe
> with multiple probe point support for x86, arm64 and powerpc64le.
> This also introduces the rethook for hooking function return as same as
> the kretprobe does. This abstraction will help us to generalize the fgraph
> tracer, because we can just switch to it from the rethook in fprobe,
> depending on the kernel configuration.
> 
> The patch [1/12] is from Jiri's series[2].
> 
> [2] https://lore.kernel.org/all/20220104080943.113249-1-jolsa@kernel.org/T/#u
> 
> And the patch [9/10] adds the FPROBE_FL_KPROBE_SHARED flag for the case
> if user wants to share the same code (or share a same resource) on the
> fprobe and the kprobes.
> 
> I forcibly updated my kprobes/fprobe branch, you can pull this series
> from:
> 
>  https://git.kernel.org/pub/scm/linux/kernel/git/mhiramat/linux.git kprobes/fprobe
> 
> Thank you,
> 
> ---
> 
> Jiri Olsa (1):
>       ftrace: Add ftrace_set_filter_ips function
> 
> Masami Hiramatsu (11):
>       fprobe: Add ftrace based probe APIs
>       rethook: Add a generic return hook
>       rethook: x86: Add rethook x86 implementation
>       arm64: rethook: Add arm64 rethook implementation
>       powerpc: Add rethook support
>       ARM: rethook: Add rethook arm implementation
>       fprobe: Add exit_handler support
>       fprobe: Add sample program for fprobe
>       fprobe: Introduce FPROBE_FL_KPROBE_SHARED flag for fprobe
>       docs: fprobe: Add fprobe description to ftrace-use.rst
>       fprobe: Add a selftest for fprobe
> 
> 
>  Documentation/trace/fprobe.rst                |  174 +++++++++++++
>  Documentation/trace/index.rst                 |    1 
>  arch/arm/Kconfig                              |    1 
>  arch/arm/include/asm/stacktrace.h             |    4 
>  arch/arm/kernel/stacktrace.c                  |    6 
>  arch/arm/probes/Makefile                      |    1 
>  arch/arm/probes/rethook.c                     |  103 ++++++++
>  arch/arm64/Kconfig                            |    1 
>  arch/arm64/include/asm/stacktrace.h           |    2 
>  arch/arm64/kernel/probes/Makefile             |    1 
>  arch/arm64/kernel/probes/rethook.c            |   25 ++
>  arch/arm64/kernel/probes/rethook_trampoline.S |   87 +++++++
>  arch/arm64/kernel/stacktrace.c                |    7 -
>  arch/powerpc/Kconfig                          |    1 
>  arch/powerpc/kernel/Makefile                  |    1 
>  arch/powerpc/kernel/rethook.c                 |   72 +++++
>  arch/x86/Kconfig                              |    1 
>  arch/x86/include/asm/unwind.h                 |    8 +
>  arch/x86/kernel/Makefile                      |    1 
>  arch/x86/kernel/kprobes/common.h              |    1 
>  arch/x86/kernel/rethook.c                     |  119 +++++++++
>  include/linux/fprobe.h                        |  105 ++++++++
>  include/linux/ftrace.h                        |    3 
>  include/linux/kprobes.h                       |    3 
>  include/linux/rethook.h                       |  100 ++++++++
>  include/linux/sched.h                         |    3 
>  kernel/exit.c                                 |    2 
>  kernel/fork.c                                 |    3 
>  kernel/trace/Kconfig                          |   26 ++
>  kernel/trace/Makefile                         |    2 
>  kernel/trace/fprobe.c                         |  332 +++++++++++++++++++++++++
>  kernel/trace/ftrace.c                         |   58 ++++
>  kernel/trace/rethook.c                        |  317 ++++++++++++++++++++++++
>  lib/Kconfig.debug                             |   12 +
>  lib/Makefile                                  |    2 
>  lib/test_fprobe.c                             |  174 +++++++++++++
>  samples/Kconfig                               |    7 +
>  samples/Makefile                              |    1 
>  samples/fprobe/Makefile                       |    3 
>  samples/fprobe/fprobe_example.c               |  120 +++++++++
>  40 files changed, 1876 insertions(+), 14 deletions(-)
>  create mode 100644 Documentation/trace/fprobe.rst
>  create mode 100644 arch/arm/probes/rethook.c
>  create mode 100644 arch/arm64/kernel/probes/rethook.c
>  create mode 100644 arch/arm64/kernel/probes/rethook_trampoline.S
>  create mode 100644 arch/powerpc/kernel/rethook.c
>  create mode 100644 arch/x86/kernel/rethook.c
>  create mode 100644 include/linux/fprobe.h
>  create mode 100644 include/linux/rethook.h
>  create mode 100644 kernel/trace/fprobe.c
>  create mode 100644 kernel/trace/rethook.c
>  create mode 100644 lib/test_fprobe.c
>  create mode 100644 samples/fprobe/Makefile
>  create mode 100644 samples/fprobe/fprobe_example.c
> 
> --
> Masami Hiramatsu (Linaro) <mhiramat@kernel.org>
patchwork-bot+netdevbpf@kernel.org March 18, 2022, 3:50 a.m. UTC | #2
Hello:

This series was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Tue, 15 Mar 2022 23:00:14 +0900 you wrote:
> Hi,
> 
> Here is the 12th version of fprobe. This version fixes a possible gcc-11 issue which
> was reported as kretprobes on arm issue, and also I updated the fprobe document.
> 
> The previous version (v11) is here[1];
> 
> [...]

Here is the summary with links:
  - [v12,bpf-next,01/12] ftrace: Add ftrace_set_filter_ips function
    https://git.kernel.org/bpf/bpf-next/c/4f554e955614
  - [v12,bpf-next,02/12] fprobe: Add ftrace based probe APIs
    https://git.kernel.org/bpf/bpf-next/c/cad9931f64dc
  - [v12,bpf-next,03/12] rethook: Add a generic return hook
    https://git.kernel.org/bpf/bpf-next/c/54ecbe6f1ed5
  - [v12,bpf-next,04/12] rethook: x86: Add rethook x86 implementation
    https://git.kernel.org/bpf/bpf-next/c/75caf33eda24
  - [v12,bpf-next,05/12] arm64: rethook: Add arm64 rethook implementation
    https://git.kernel.org/bpf/bpf-next/c/83acdce68949
  - [v12,bpf-next,06/12] powerpc: Add rethook support
    https://git.kernel.org/bpf/bpf-next/c/02752bd99dc2
  - [v12,bpf-next,07/12] ARM: rethook: Add rethook arm implementation
    https://git.kernel.org/bpf/bpf-next/c/515a49173b80
  - [v12,bpf-next,08/12] fprobe: Add exit_handler support
    https://git.kernel.org/bpf/bpf-next/c/5b0ab78998e3
  - [v12,bpf-next,09/12] fprobe: Add sample program for fprobe
    https://git.kernel.org/bpf/bpf-next/c/6ee64cc3020b
  - [v12,bpf-next,10/12] fprobe: Introduce FPROBE_FL_KPROBE_SHARED flag for fprobe
    https://git.kernel.org/bpf/bpf-next/c/ab51e15d535e
  - [v12,bpf-next,11/12] docs: fprobe: Add fprobe description to ftrace-use.rst
    https://git.kernel.org/bpf/bpf-next/c/aba09b44a985
  - [v12,bpf-next,12/12] fprobe: Add a selftest for fprobe
    https://git.kernel.org/bpf/bpf-next/c/f4616fabab39

You are awesome, thank you!