From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-kernel@vger.kernel.org, x86@kernel.org,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Quentin Monnet <qmo@kernel.org>,
Alan Maguire <almagui@kernel.org>
Subject: [PATCH RFC bpf-next 19/31] libbpf: Add inline options to bpf_kprobe_multi_opts
Date: Wed, 2 Dec 2026 13:30:23 +0100 [thread overview]
Message-ID: <20261202123035.10335-20-jolsa@kernel.org> (raw)
In-Reply-To: <20261202123035.10335-1-jolsa@kernel.org>
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@kernel.org>
---
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
next prev parent reply other threads:[~2026-12-02 12:33 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:30 [PATCH RFC bpf-next 00/31] bpf: Attach kprobe multi link to inlined functions Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 01/31] x86/ptrace: Add regs_get_dwarf_register function Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 02/31] kprobes: Make the kprobe hash table size configurable Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 03/31] kprobes: Add enable_kprobes to enable multiple kprobes at once Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 04/31] module: Add module_sect_addr function Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 05/31] bpf: Add bpf_get_btf_vmlinux_inline function Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 06/31] bpf: Use goto labels for error path in bpf_kprobe_multi_link_attach Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 07/31] bpf: Add support to attach inlined functions with kprobe multi link Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 08/31] bpf: Add cookie support for kprobe multi inlined functions Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 09/31] bpf: Add link info " Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 10/31] bpf: Add fdinfo " Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 11/31] bpf: Add btf_for_each_module_inline function Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 12/31] bpf: Change get_modules_for_addrs to use struct modules_array Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 13/31] tbpf: Add support to attach inlined functions in modules with kprobe multi link Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 14/31] bpf: Add BPF_F_KPROBE_MULTI_INLINE_STRICT flag for " Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 15/31] bpf: Add get_func_arg[_cnt] support for kprobe multi functions Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 16/31] bpf: Add get_func_arg[_cnt] support for kprobe multi inlined functions Jiri Olsa
2026-12-02 12:55 ` sashiko-bot
2026-12-02 12:30 ` [PATCH RFC bpf-next 17/31] bpf: Add log messages for kprobe multi inline attach Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 18/31] bpf: Add inlined functions for kprobe multi inline tests Jiri Olsa
2026-12-02 12:51 ` sashiko-bot
2026-12-02 12:30 ` Jiri Olsa [this message]
2026-12-02 12:30 ` [PATCH RFC bpf-next 20/31] libbpf: Print kernel log for failed kprobe multi attach Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 21/31] bpftool: Display inlined functions for kprobe multi link Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 22/31] selftests/bpf: Add inlined functions to bpf_testmod Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 23/31] selftests/bpf: Add kprobe multi inline attach test Jiri Olsa
2026-12-02 12:50 ` sashiko-bot
2026-12-02 12:30 ` [PATCH RFC bpf-next 24/31] selftests/bpf: Add kprobe multi inline mixed test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 25/31] selftests/bpf: Add kprobe multi inline skip test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 26/31] selftests/bpf: Add kprobe multi inline fails test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 27/31] selftests/bpf: Add kprobe multi inline module test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 28/31] selftests/bpf: Add kprobe multi inline strict test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 29/31] selftests/bpf: Add kprobe multi inline args test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 30/31] selftests/bpf: Add kprobe multi inline bench attach test Jiri Olsa
2026-12-02 12:30 ` [PATCH RFC bpf-next 31/31] selftests/bpf: Add kprobe multi inline link info test Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202123035.10335-20-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=almagui@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=qmo@kernel.org \
--cc=song@kernel.org \
--cc=x86@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox