hi, this patchset is adding support for session uprobe attachment and using it through bpf link for bpf programs. The session means that the uprobe consumer is executed on entry and return of probed function with additional control: - entry callback can control execution of the return callback - entry and return callbacks can share data/cookie On more details please see patch #2. The patchset is based on Peter's perf/core [1] tree merged in bpf-next/master. There's an proposal from Andrii how to get this merged in [2]: > I think uprobe parts should stay in tip/perf/core (if that's where all > uprobe code goes in), as we have a bunch of ongoing work that all will > conflict a bit with each other, if it lands across multiple trees. > > So that means that patches #1 and #2 ideally land in tip/perf/core. > But you have a lot of BPF-specific things that would be inconvenient > to route through tip, so I'd say those should go through bpf-next. > > What we can do, if Ingo and Peter are OK with that, is to create a > stable (non-rebaseable) branch off of your first two patches (applied > in tip/perf/core), which we'll merge into bpf-next/master and land the > rest of your patch set there. We've done that with recent struct fd > changes, and there were few other similar cases in the past, and that > all worked well. > > Peter, Ingo, are you guys OK with that approach? v7 changes: - added acks [Andrii, Oleg] - merged patch 14/15 into one change, plus another small change [Andrii] thanks, jirka [1] git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git perf/core [2] https://lore.kernel.org/bpf/CAEf4BzY8tGCstcD4BVBLPd0V92p--b_vUmQyWydObRJHZPgCLA@xxxxxxxxxxxxxx/ --- Jiri Olsa (15): uprobe: Add data pointer to consumer handlers uprobe: Add support for session consumer bpf: Allow return values 0 and 1 for kprobe session bpf: Force uprobe bpf program to always return 0 bpf: Add support for uprobe multi session attach bpf: Add support for uprobe multi session context libbpf: Add support for uprobe multi session attach selftests/bpf: Add uprobe session test selftests/bpf: Add uprobe session cookie test selftests/bpf: Add uprobe session recursive test selftests/bpf: Add uprobe session verifier test for return value selftests/bpf: Add kprobe session verifier test for return value selftests/bpf: Add uprobe session single consumer test selftests/bpf: Add uprobe sessions to consumer test selftests/bpf: Add threads to consumer test include/linux/uprobes.h | 25 ++++++- include/uapi/linux/bpf.h | 1 + kernel/bpf/syscall.c | 9 ++- kernel/bpf/verifier.c | 10 +++ kernel/events/uprobes.c | 148 +++++++++++++++++++++++++++++-------- kernel/trace/bpf_trace.c | 63 +++++++++++----- kernel/trace/trace_uprobe.c | 12 ++- tools/include/uapi/linux/bpf.h | 1 + tools/lib/bpf/bpf.c | 1 + tools/lib/bpf/libbpf.c | 19 ++++- tools/lib/bpf/libbpf.h | 4 +- tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2 +- tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c | 2 + tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- tools/testing/selftests/bpf/progs/kprobe_multi_verifier.c | 31 ++++++++ tools/testing/selftests/bpf/progs/uprobe_multi_consumers.c | 6 +- tools/testing/selftests/bpf/progs/uprobe_multi_session.c | 71 ++++++++++++++++++ tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c | 48 ++++++++++++ tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c | 44 +++++++++++ tools/testing/selftests/bpf/progs/uprobe_multi_session_single.c | 44 +++++++++++ tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c | 31 ++++++++ 21 files changed, 808 insertions(+), 100 deletions(-) create mode 100644 tools/testing/selftests/bpf/progs/kprobe_multi_verifier.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_session.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_session_cookie.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_session_recursive.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_session_single.c create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c