[PATCH RFC bpf-next 19/31] libbpf: Add inline options to bpf_kprobe_multi_opts

From: Jiri Olsa

Date: Wed Dec 02 2026 - 07:34:06 EST


Add inlined and inlined_strict options to struct bpf_kprobe_multi_opts
to attach the link with BPF_F_KPROBE_MULTI_INLINE[_STRICT] flags.

The inlined instances are resolved by kernel from function names,
so the options work only with syms array or with pattern without
wildcards.

Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/lib/bpf/libbpf.c | 18 +++++++++++++++++-
tools/lib/bpf/libbpf.h | 6 +++++-
2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 61a388868373..885383def114 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -13159,7 +13159,7 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
struct bpf_link *link = NULL;
const unsigned long *addrs;
int err, link_fd, prog_fd;
- bool retprobe, session, unique_match;
+ bool retprobe, session, unique_match, inlined, inlined_strict;
const __u64 *cookies;
const char **syms;
size_t cnt;
@@ -13179,6 +13179,8 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
cnt = OPTS_GET(opts, cnt, false);
cookies = OPTS_GET(opts, cookies, false);
unique_match = OPTS_GET(opts, unique_match, false);
+ inlined = OPTS_GET(opts, inlined, false);
+ inlined_strict = OPTS_GET(opts, inlined_strict, false);

if (!pattern && !addrs && !syms)
return libbpf_err_ptr(-EINVAL);
@@ -13190,6 +13192,14 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
return libbpf_err_ptr(-EINVAL);
if (addrs && syms)
return libbpf_err_ptr(-EINVAL);
+ /*
+ * Inlined instances are resolved by kernel from function names,
+ * so we can't use addresses or pattern resolved to addresses.
+ */
+ if (inlined && (addrs || unique_match || (pattern && strpbrk(pattern, "*?"))))
+ return libbpf_err_ptr(-EINVAL);
+ if (inlined_strict && !inlined)
+ return libbpf_err_ptr(-EINVAL);

/*
* Exact function name (no wildcards) without unique_match:
@@ -13224,6 +13234,8 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,

if (retprobe && session)
return libbpf_err_ptr(-EINVAL);
+ if (inlined && (retprobe || session))
+ return libbpf_err_ptr(-EINVAL);

attach_type = session ? BPF_TRACE_KPROBE_SESSION : BPF_TRACE_KPROBE_MULTI;

@@ -13232,6 +13244,10 @@ bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
lopts.kprobe_multi.cookies = cookies;
lopts.kprobe_multi.cnt = cnt;
lopts.kprobe_multi.flags = retprobe ? BPF_F_KPROBE_MULTI_RETURN : 0;
+ if (inlined)
+ lopts.kprobe_multi.flags |= BPF_F_KPROBE_MULTI_INLINE;
+ if (inlined_strict)
+ lopts.kprobe_multi.flags |= BPF_F_KPROBE_MULTI_INLINE_STRICT;

link = calloc(1, sizeof(*link));
if (!link) {
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 56300be81016..286512037a68 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -648,10 +648,14 @@ struct bpf_kprobe_multi_opts {
bool session;
/* enforce unique match */
bool unique_match;
+ /* attach also to inlined instances of functions */
+ bool inlined;
+ /* fail if any inlined instance can't be attached, needs inlined */
+ bool inlined_strict;
size_t :0;
};

-#define bpf_kprobe_multi_opts__last_field unique_match
+#define bpf_kprobe_multi_opts__last_field inlined_strict

LIBBPF_API struct bpf_link *
bpf_program__attach_kprobe_multi_opts(const struct bpf_program *prog,
--
2.56.1