On Mon, Jul 22, 2024 at 1:28 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > Adding test that attaches/detaches multiple consumers on > single uprobe and verifies all were hit as expected. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > --- > .../bpf/prog_tests/uprobe_multi_test.c | 213 ++++++++++++++++++ > .../bpf/progs/uprobe_multi_consumers.c | 39 ++++ > 2 files changed, 252 insertions(+) > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_consumers.c > [...] > + } else { > + /* > + * uprobe return is tricky ;-) > + * > + * to trigger uretprobe consumer, the uretprobe needs to be installed, > + * which means one of the 'return' uprobes was alive when probe was hit: > + * > + * idxs: 2/3 uprobe return in 'installed' mask > + * > + * in addition if 'after' state removes everything that was installed in > + * 'before' state, then uprobe kernel object goes away and return uprobe > + * is not installed and we won't hit it even if it's in 'after' state. > + */ > + unsigned long had_uretprobes = before & 0b1100; // is uretprobe installed > + unsigned long probe_preserved = before & after; // did uprobe go away fixed C++-style comments, pushed to bpf-next > + > + if (had_uretprobes && probe_preserved && test_bit(idx, after)) > + val++; > + fmt = "idx 2/3: uretprobe"; > + } > + > + ASSERT_EQ(skel->bss->uprobe_result[idx], val, fmt); > + skel->bss->uprobe_result[idx] = 0; > + } > + > +cleanup: > + for (idx = 0; idx < 4; idx++) > + uprobe_detach(skel, idx); > +} [...]