bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Jiri Olsa <olsajiri@gmail.com>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Thierry Treyer <ttreyer@meta.com>,
	Yonghong Song <yonghong.song@linux.dev>,
	Song Liu <song@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Quentin Monnet <qmo@kernel.org>,
	Ihor Solodrai <ihor.solodrai@linux.dev>,
	David Faust <david.faust@oracle.com>,
	"Jose E. Marchesi" <jose.marchesi@oracle.com>,
	bpf <bpf@vger.kernel.org>, Masami Hiramatsu <mhiramat@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC bpf-next 00/15] support inline tracing with BTF
Date: Wed, 15 Oct 2025 20:35:30 +0200	[thread overview]
Message-ID: <aO_pciIZnL_xdJQJ@krava> (raw)
In-Reply-To: <5fdfb3f8-8acb-405e-8171-bc57fca71210@oracle.com>

On Wed, Oct 15, 2025 at 04:19:29PM +0100, Alan Maguire wrote:
> On 15/10/2025 15:17, Jiri Olsa wrote:
> > On Tue, Oct 14, 2025 at 03:55:53PM +0100, Alan Maguire wrote:
> >> On 14/10/2025 12:52, Jiri Olsa wrote:
> >>> On Mon, Oct 13, 2025 at 05:12:45PM -0700, Alexei Starovoitov wrote:
> >>>> On Mon, Oct 13, 2025 at 12:38 AM Alan Maguire <alan.maguire@oracle.com> wrote:
> >>>>>
> >>>>>
> >>>>> I was trying to avoid being specific about inlines since the same
> >>>>> approach works for function sites with optimized-out parameters and they
> >>>>> could be easily added to the representation (and probably should be in a
> >>>>> future version of this series). Another "extra" source of info
> >>>>> potentially is the (non per-cpu) global variables that Stephen sent
> >>>>> patches for a while back and the feeling was it was too big to add to
> >>>>> vmlinux BTF proper.
> >>>>>
> >>>>> But extra is a terrible name. .BTF.aux for auxiliary info perhaps?
> >>>>
> >>>> aux is too abstract and doesn't convey any meaning.
> >>>> How about "BTF.func_info" ? It will cover inlined and optimized funcs.
> >>>>
> >>>> Thinking more about reuse of struct btf_type for these...
> >>>> After sleeping on it it feels a bit awkward today, since if they're
> >>>> types they suppose to be in one table with other types,
> >>>> searchable and so on, but we actually don't want them there.
> >>>> btf_find_*() isn't fast and people are trying to optimize it.
> >>>> Also if we teach the kernel to use these loc-s they probably
> >>>> should be in a separate table.
> >>>>
> >>>> global non per-cpu vars fit into current BTF's datasec concept,
> >>>> so they can be another kernel module with a different name.
> >>>>
> >>>> I guess one can argue that LOCSEC is similar to DATASEC.
> >>>> Both need their own search tables separate from the main type table.
> >>>>
> >>>>>
> >>>>>> The partially inlined functions were the biggest footgun so far.
> >>>>>> Missing fully inlined is painful, but it's not a footgun.
> >>>>>> So I think doing "kloc" and usdt-like bpf_loc_arg() completely in
> >>>>>> user space is not enough. It's great and, probably, can be supported,
> >>>>>> but the kernel should use this "BTF.inline_info" as well to
> >>>>>> preserve "backward compatibility" for functions that were
> >>>>>> not-inlined in an older kernel and got partially inlined in a new kernel.
> >>>>>>
> >>>>>
> >>>>> That would be great; we'd need to teach the kernel to handle multi-split
> >>>>> BTF but I would hope that wouldn't be too tricky.
> >>>>>
> >>>>>> If we could use kprobe-multi then usdt-like bpf_loc_arg() would
> >>>>>> make a lot of sense, but since libbpf has to attach a bunch
> >>>>>> of regular kprobes it seems to me the kernel support is more appropriate
> >>>>>> for the whole thing.
> >>>>>
> >>>>> I'm happy with either a userspace or kernel-based approach; the main aim
> >>>>> is to provide this functionality in as straightforward a form as
> >>>>> possible to tracers/libbpf. I have to confess I didn't follow the whole
> >>>>> kprobe multi progress, but at one stage that was more kprobe-based
> >>>>> right? Would there be any value in exploring a flavour of kprobe-multi
> >>>>> that didn't use fprobe and might work for this sort of use case? As you
> >>>>> say if we had that keeping a user-space based approach might be more
> >>>>> attractive as an option.
> >>>>
> >>>> Agree.
> >>>>
> >>>> Jiri,
> >>>> how hard would it be to make multi-kprobe work on arbitrary IPs ?
> >>>
> >>> multi-kprobe uses fprobe which uses ftrace/fgraph fast api to attach,
> >>> but it can do that only on the entry of ftrace-able functions which
> >>> have nop5 hooks at the entry
> >>>
> >>> attaching anywhere else requires standard kprobe and the attach time
> >>> (and execution time) will be bad
> >>>
> >>> would be great if inlined functions kept the nop5/fentry hooks ;-)
> >>> but that's probably not that simple
> >>>
> >>
> >> Yeah, if it was doable - and with metadata about inline sites it
> >> certainly _seems_ possible - it does seem to work against the reason we
> >> inline stuff (saving overheads). Steve mentioned this as a possibility
> >> at GNU cauldron too if I remember, so worth discussing of course!
> >>
> >> I was thinking about something simpler to be honest; a flavour of kprobe
> >> multi that used kprobes under the hood in kernel to be suitable for
> >> inline sites without any tweaking of the sites. So there is a kprobe
> >> performance penalty if you're tracing, but none otherwise.
> > 
> > so you mean we'd still use kprobe_multi api and its code would use fprobe
> > for ftrace-able functions and standard kprobe for the rest?
> > 
> > jirka
> 
> Yeah, if possible. For the kernel inline sites we'd be dealing in raw
> addresses rather than function names so that in itself might be enough
> of a hint that it's not an fprobe site, so I guess it could be framed as
> an extension of kprobe multi to support a mix of fprobe-able and
> non-fprobe-able sites. Not sure how feasible that is though.

that seems doable, kprobe-multi api already supports both symbols and addresses,
and because ftrace keeps track of each ftrace-able function we can tell which
is which via ftrace_location call

looks like there's also register_kprobes call that registers kprobes for multiple
addresses

I wonder what's the standard kprobe attach slowdow nowaday, it was substantial few
years back, will check to have an idea

jirka

  reply	other threads:[~2025-10-15 18:35 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 17:34 [RFC bpf-next 00/15] support inline tracing with BTF Alan Maguire
2025-10-08 17:34 ` [RFC bpf-next 01/15] bpf: Extend UAPI to support location information Alan Maguire
2025-10-16 18:36   ` Andrii Nakryiko
2025-10-17  8:43     ` Alan Maguire
2025-10-20 20:57       ` Andrii Nakryiko
2025-10-23  8:17         ` Alan Maguire
2025-11-05  0:43           ` Andrii Nakryiko
2025-10-23  0:56   ` Eduard Zingerman
2025-10-23  8:35     ` Alan Maguire
2025-10-08 17:34 ` [RFC bpf-next 02/15] libbpf: Add support for BTF kinds LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2025-10-23  0:57   ` Eduard Zingerman
2025-10-23 19:18   ` Eduard Zingerman
2025-10-23 19:59     ` Eduard Zingerman
2025-10-08 17:34 ` [RFC bpf-next 03/15] libbpf: Add option to retrieve map from old->new ids from btf__dedup() Alan Maguire
2025-10-16 18:39   ` Andrii Nakryiko
2025-10-17  8:56     ` Alan Maguire
2025-10-20 21:03       ` Andrii Nakryiko
2025-10-23  8:25         ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 04/15] libbpf: Fix parsing of multi-split BTF Alan Maguire
2025-10-16 18:36   ` Andrii Nakryiko
2025-10-17 13:47     ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 05/15] bpftool: Add ability to dump LOC_PARAM, LOC_PROTO and LOCSEC Alan Maguire
2025-10-23  0:57   ` Eduard Zingerman
2025-10-23  8:38     ` Alan Maguire
2025-10-23  8:50       ` Eduard Zingerman
2025-10-08 17:35 ` [RFC bpf-next 06/15] bpftool: Handle multi-split BTF by supporting multiple base BTFs Alan Maguire
2025-10-16 18:36   ` Andrii Nakryiko
2025-10-17 13:47     ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 07/15] selftests/bpf: Test helper support for BTF_KIND_LOC[_PARAM|_PROTO|SEC] Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 08/15] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to field iter tests Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 09/15] selftests/bpf: Add LOC_PARAM, LOC_PROTO, LOCSEC to dedup split tests Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 10/15] selftests/bpf: BTF distill tests to ensure LOC[_PARAM|_PROTO] add to split BTF Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 11/15] kbuild: Add support for extra BTF Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 12/15] kbuild, module, bpf: Support CONFIG_DEBUG_INFO_BTF_EXTRA=m Alan Maguire
2025-10-16 18:37   ` Andrii Nakryiko
2025-10-17 13:54     ` Alan Maguire
2025-10-20 21:05       ` Andrii Nakryiko
2025-10-23  0:58   ` Eduard Zingerman
2025-10-23 12:00     ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 13/15] libbpf: add API to load extra BTF Alan Maguire
2025-10-16 18:37   ` Andrii Nakryiko
2025-10-17 13:55     ` Alan Maguire
2025-10-08 17:35 ` [RFC bpf-next 14/15] libbpf: add support for BTF location attachment Alan Maguire
2025-10-16 18:36   ` Andrii Nakryiko
2025-10-17 14:02     ` Alan Maguire
2025-10-20 21:07       ` Andrii Nakryiko
2025-10-08 17:35 ` [RFC bpf-next 15/15] selftests/bpf: Add test tracing inline site using SEC("kloc") Alan Maguire
2025-10-12 23:45 ` [RFC bpf-next 00/15] support inline tracing with BTF Alexei Starovoitov
2025-10-13  7:38   ` Alan Maguire
2025-10-14  0:12     ` Alexei Starovoitov
2025-10-14  9:58       ` Alan Maguire
2025-10-16 18:36         ` Andrii Nakryiko
2025-10-23 14:37           ` Alan Maguire
2025-10-23 16:16             ` Andrii Nakryiko
2025-10-24 11:53               ` Alan Maguire
2025-10-14 11:52       ` Jiri Olsa
2025-10-14 14:55         ` Alan Maguire
2025-10-14 23:04           ` Masami Hiramatsu
2025-10-15 14:17           ` Jiri Olsa
2025-10-15 15:19             ` Alan Maguire
2025-10-15 18:35               ` Jiri Olsa [this message]
2025-10-23 22:32 ` Eduard Zingerman
2025-10-24 12:54   ` Alan Maguire

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=aO_pciIZnL_xdJQJ@krava \
    --to=olsajiri@gmail.com \
    --cc=acme@kernel.org \
    --cc=alan.maguire@oracle.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=david.faust@oracle.com \
    --cc=haoluo@google.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=jose.marchesi@oracle.com \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mhiramat@kernel.org \
    --cc=qmo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=ttreyer@meta.com \
    --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;
as well as URLs for NNTP newsgroup(s).