From: Jiri Olsa <olsajiri@gmail.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
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: Re: [PATCH RFC bpf-next 00/31] bpf: Attach kprobe multi link to inlined functions
Date: Thu, 3 Dec 2026 15:20:51 +0100 [thread overview]
Message-ID: <axF6w9jOkUL2IJD8@krava> (raw)
In-Reply-To: <DNAQ3Q8ARTHT.OWF2VDJ3X7T8@gmail.com>
On Thu, Dec 03, 2026 at 01:57:14AM +0000, Alexei Starovoitov wrote:
> On Wed, Dec 02, 2026 at 04:30 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > This patchset adds BPF_F_KPROBE_MULTI_INLINE flag that attaches also
> > the inlined instances of the functions in the syms array. The
> > instances are resolved from inline BTF (CONFIG_DEBUG_INFO_BTF_INLINE)
> > of vmlinux and modules and each gets its own kprobe.
>
> I like the idea. kprobes behind the kprobe multi link is the piece
> that was missing.
> But the lookup by name in the kernel is kinda heavy.
>
> In Alan's RFC thread I leaned towards the kernel doing the whole thing.
> The reason: kprobe multi could not attach to arbitrary IPs.
> Patch 7 shows that it can. That changes the trade off.
>
> Lets start with the mechanism only.
> addrs[] takes any address that kprobes accept.
> fprobe gets the ftrace locations. Every other address gets a kprobe.
> Such addrs fail with -ENOENT in fprobe_init() today, so no need for
> a flag.
> User space reads vmlinux.inline from sysfs and passes the sites.
ok, makes sense, more comments below
>
> libbpf works this way already. It resolves "tcp_*" in user space and
> passes addrs. In this series wildcards can't use inline (patch 19).
> To match fully inlined functions libbpf has to read vmlinux.inline
> anyway.
>
> this series addrs[]
> ----------------- ----------------------- -------------------------
> name -> sites kernel, exact names user space, wildcards too
> subset of sites no yes
> vmlinux.inline 2nd copy, ~10 Mbytes, mmap in user space
> never freed
> cookie per function per site
> args bpf_get_func_arg() cookie -> arg spec, like
> usdt.bpf.h
> arch x86-64 any with kprobes
> link info 5 new fields as is
> fdinfo 2 new lines as is, %pS
> bpftool new table, BTF lookup print sym+off
> new flags 2 0
>
> Your use case from Alan's v2 thread works too: trace foo() only where
> it is inlined in bar(). User space picks the sites.
>
> Then there is no need for BTF parsing in the kernel, module_sect_addr(),
> regs_get_dwarf_register(), inline_* in bpf_link_info, STRICT, etc.
> Patches 2 and 3 stay.
>
> If tracers show that the lookup has to be in the kernel we add it
> on top of addrs[]. uapi doesn't go the other way.
initially I thought that doing the lookup in user space might be a
security concern for shirudo, but it's probably just more work for
the loader, not a security risk
>
> What the diff doesn't do:
> It is all or none. imo that's the right default.
> It doesn't say which address kprobes refuse. The link_create log can
> name it. A flag to skip such addresses can come later. link info shows
> what is attached.
I think we need the skip flag. kprobes refuse some of the inlined
sites (jump label, static call, bug table, NOKPROBE_SYMBOL, noinstr)
and finding those in user space would need vmlinux and a copy of
the kprobe checks, which seems too much
I changed the bench test to print out the stats:
inlined instances 20695
attached 19947
skipped, notrace function 563
skipped, refused by kprobes 185
it's the worst case, normal attach with just a few functions would
hit much less, but it's still inconvenient, because user space has
to retry the attach for each address the log names
> It calls register_kprobes(). enable_kprobes() goes on top.
ok
> Two functions inlined at one address share one cookie.
I think we can still allow same addresses having their own cookie,
if we keep the cookie in the kprobe struct and pass it through the
run context instead of looking it up by the address
it's probably needed for the arg specs too, two inline functions
on the same address would otherwise end up with the same spec
thanks,
jirka
prev parent reply other threads:[~2026-12-03 14:20 UTC|newest]
Thread overview: 39+ 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-03 1:50 ` Alexei Starovoitov
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-03 1:51 ` Alexei Starovoitov
2026-12-03 14:21 ` 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-03 1:53 ` Alexei Starovoitov
2026-12-03 14:42 ` 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: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:30 ` [PATCH RFC bpf-next 19/31] libbpf: Add inline options to bpf_kprobe_multi_opts Jiri Olsa
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: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
2026-12-03 1:57 ` [PATCH RFC bpf-next 00/31] bpf: Attach kprobe multi link to inlined functions Alexei Starovoitov
2026-12-03 14:20 ` Jiri Olsa [this message]
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=axF6w9jOkUL2IJD8@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=almagui@kernel.org \
--cc=andrii@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