On Tue, Jul 02, 2024 at 02:34:34PM -0700, Andrii Nakryiko wrote: > On Mon, Jul 1, 2024 at 9:42 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > > > Adding support to attach program in uprobe session mode > > with bpf_program__attach_uprobe_multi function. > > > > Adding session bool to bpf_uprobe_multi_opts struct that allows > > to load and attach the bpf program via uprobe session. > > the attachment to create uprobe multi session. > > > > Also adding new program loader section that allows: > > SEC("uprobe.session/bpf_fentry_test*") > > > > and loads/attaches uprobe program as uprobe session. > > > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > --- > > tools/lib/bpf/bpf.c | 1 + > > tools/lib/bpf/libbpf.c | 50 ++++++++++++++++++++++++++++++++++++++++-- > > tools/lib/bpf/libbpf.h | 4 +++- > > 3 files changed, 52 insertions(+), 3 deletions(-) > > > > [...] > > > @@ -9362,6 +9363,7 @@ static const struct bpf_sec_def section_defs[] = { > > SEC_DEF("kprobe.session+", KPROBE, BPF_TRACE_KPROBE_SESSION, SEC_NONE, attach_kprobe_session), > > SEC_DEF("uprobe.multi+", KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_NONE, attach_uprobe_multi), > > SEC_DEF("uretprobe.multi+", KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_NONE, attach_uprobe_multi), > > + SEC_DEF("uprobe.session+", KPROBE, BPF_TRACE_UPROBE_SESSION, SEC_NONE, attach_uprobe_session), > > sleepable ones as well? ah right, forgot.. will add > > > SEC_DEF("uprobe.multi.s+", KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_SLEEPABLE, attach_uprobe_multi), > > SEC_DEF("uretprobe.multi.s+", KPROBE, BPF_TRACE_UPROBE_MULTI, SEC_SLEEPABLE, attach_uprobe_multi), > > SEC_DEF("ksyscall+", KPROBE, 0, SEC_NONE, attach_ksyscall), > > @@ -11698,6 +11700,40 @@ static int attach_uprobe_multi(const struct bpf_program *prog, long cookie, stru > > return ret; > > } > > > > +static int attach_uprobe_session(const struct bpf_program *prog, long cookie, struct bpf_link **link) > > +{ > > + char *binary_path = NULL, *func_name = NULL; > > + LIBBPF_OPTS(bpf_uprobe_multi_opts, opts, > > + .session = true, > > + ); > > nit: keep a single line? ok > > > + int n, ret = -EINVAL; > > + const char *spec; > > + > > + *link = NULL; > > + > > + spec = prog->sec_name + sizeof("uprobe.session/") - 1; > > + n = sscanf(spec, "%m[^:]:%m[^\n]", > > + &binary_path, &func_name); > > single line, wrapping lines is a necessary evil, please ok thanks, jirka