On Thu, Jun 22, 2023 at 05:18:10PM -0700, Andrii Nakryiko wrote: > On Tue, Jun 20, 2023 at 1:36 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > > > Adding support to specify cookies array for uprobe_multi link. > > > > The cookies array share indexes and length with other uprobe_multi > > arrays (offsets/ref_ctr_offsets). > > > > The cookies[i] value defines cookie for i-the uprobe and will be > > returned by bpf_get_attach_cookie helper when called from ebpf > > program hooked to that specific uprobe. > > > > Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > --- > > include/uapi/linux/bpf.h | 1 + > > kernel/bpf/syscall.c | 2 +- > > kernel/trace/bpf_trace.c | 48 +++++++++++++++++++++++++++++++--- > > tools/include/uapi/linux/bpf.h | 1 + > > 4 files changed, 47 insertions(+), 5 deletions(-) > > > > [...] > > > @@ -3026,6 +3045,16 @@ uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, s > > return uprobe_prog_run(uprobe, func, regs); > > } > > > > +static u64 bpf_uprobe_multi_cookie(struct bpf_run_ctx *ctx) > > +{ > > + struct bpf_uprobe_multi_run_ctx *run_ctx; > > + > > + if (!ctx) > > + return 0; > > can't happen, let's crash if it does happen? ok, will remove jirka > > > > + run_ctx = container_of(current->bpf_ctx, struct bpf_uprobe_multi_run_ctx, run_ctx); > > + return run_ctx->uprobe->cookie; > > +} > > + > > [...]