mbox series

[RFC,0/8] perf/bpf: Add batch support for [ku]probes attach

Message ID 20211124084119.260239-1-jolsa@kernel.org (mailing list archive)
Headers show
Series perf/bpf: Add batch support for [ku]probes attach | expand

Message

Jiri Olsa Nov. 24, 2021, 8:41 a.m. UTC
hi,
adding support to create multiple kprobes/uprobes within single
perf event. This way we can associate single bpf program with
multiple kprobes.

Sending this as RFC because I'm not completely sure I haven't
missed anything in the trace/events area.

Also it needs following uprobe fix to work properly:
  https://lore.kernel.org/lkml/20211123142801.182530-1-jolsa@kernel.org/

Also available at:
  https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  bpf/kuprobe_batch

thanks,
jirka


---
Jiri Olsa (8):
      perf/kprobe: Add support to create multiple probes
      perf/uprobe: Add support to create multiple probes
      libbpf: Add libbpf__kallsyms_parse function
      libbpf: Add struct perf_event_open_args
      libbpf: Add support to attach multiple [ku]probes
      libbpf: Add support for k[ret]probe.multi program section
      selftest/bpf: Add kprobe multi attach test
      selftest/bpf: Add uprobe multi attach test

 include/uapi/linux/perf_event.h                            |   1 +
 kernel/trace/trace_event_perf.c                            | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 kernel/trace/trace_kprobe.c                                |  47 ++++++++++++++++---
 kernel/trace/trace_probe.c                                 |   2 +-
 kernel/trace/trace_probe.h                                 |   6 ++-
 kernel/trace/trace_uprobe.c                                |  43 +++++++++++++++--
 tools/include/uapi/linux/perf_event.h                      |   1 +
 tools/lib/bpf/libbpf.c                                     | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
 tools/lib/bpf/libbpf.h                                     |  25 +++++++++-
 tools/lib/bpf/libbpf_internal.h                            |   5 ++
 tools/testing/selftests/bpf/prog_tests/multi_kprobe_test.c |  83 +++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/multi_uprobe_test.c |  97 ++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/multi_kprobe.c           |  58 +++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/multi_uprobe.c           |  26 +++++++++++
 14 files changed, 765 insertions(+), 78 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/multi_kprobe_test.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/multi_uprobe_test.c
 create mode 100644 tools/testing/selftests/bpf/progs/multi_kprobe.c
 create mode 100644 tools/testing/selftests/bpf/progs/multi_uprobe.c

Comments

Masami Hiramatsu (Google) Nov. 28, 2021, 10:34 a.m. UTC | #1
Hi Jiri,

On Wed, 24 Nov 2021 09:41:11 +0100
Jiri Olsa <jolsa@redhat.com> wrote:

> hi,
> adding support to create multiple kprobes/uprobes within single
> perf event. This way we can associate single bpf program with
> multiple kprobes.

Thanks for the change, basically, you can repeatedly call the
create_local_trace_kprobe() and register it.

> 
> Sending this as RFC because I'm not completely sure I haven't
> missed anything in the trace/events area.

OK let me check that.

Thanks,

> 
> Also it needs following uprobe fix to work properly:
>   https://lore.kernel.org/lkml/20211123142801.182530-1-jolsa@kernel.org/
> 
> Also available at:
>   https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   bpf/kuprobe_batch
> 
> thanks,
> jirka
> 
> 
> ---
> Jiri Olsa (8):
>       perf/kprobe: Add support to create multiple probes
>       perf/uprobe: Add support to create multiple probes
>       libbpf: Add libbpf__kallsyms_parse function
>       libbpf: Add struct perf_event_open_args
>       libbpf: Add support to attach multiple [ku]probes
>       libbpf: Add support for k[ret]probe.multi program section
>       selftest/bpf: Add kprobe multi attach test
>       selftest/bpf: Add uprobe multi attach test
> 
>  include/uapi/linux/perf_event.h                            |   1 +
>  kernel/trace/trace_event_perf.c                            | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
>  kernel/trace/trace_kprobe.c                                |  47 ++++++++++++++++---
>  kernel/trace/trace_probe.c                                 |   2 +-
>  kernel/trace/trace_probe.h                                 |   6 ++-
>  kernel/trace/trace_uprobe.c                                |  43 +++++++++++++++--
>  tools/include/uapi/linux/perf_event.h                      |   1 +
>  tools/lib/bpf/libbpf.c                                     | 235 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
>  tools/lib/bpf/libbpf.h                                     |  25 +++++++++-
>  tools/lib/bpf/libbpf_internal.h                            |   5 ++
>  tools/testing/selftests/bpf/prog_tests/multi_kprobe_test.c |  83 +++++++++++++++++++++++++++++++++
>  tools/testing/selftests/bpf/prog_tests/multi_uprobe_test.c |  97 ++++++++++++++++++++++++++++++++++++++
>  tools/testing/selftests/bpf/progs/multi_kprobe.c           |  58 +++++++++++++++++++++++
>  tools/testing/selftests/bpf/progs/multi_uprobe.c           |  26 +++++++++++
>  14 files changed, 765 insertions(+), 78 deletions(-)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/multi_kprobe_test.c
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/multi_uprobe_test.c
>  create mode 100644 tools/testing/selftests/bpf/progs/multi_kprobe.c
>  create mode 100644 tools/testing/selftests/bpf/progs/multi_uprobe.c
>