From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Tao Chen <chen.dylane@linux.dev>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, haoluo@google.com, qmo@kernel.org,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
chen.dylane@gmail.com
Subject: Re: [PATCH bpf-next v8 4/5] libbpf: Init kprobe prog expected_attach_type for kfunc probe
Date: Wed, 26 Feb 2025 12:12:43 +0100 [thread overview]
Message-ID: <Z773KxMF0N1nEFsH@krava> (raw)
In-Reply-To: <CAEf4BzY85DmfwRruD4tnTj+UiRTk64k1N5vO69cdL1T7H+QTXw@mail.gmail.com>
On Tue, Feb 25, 2025 at 09:04:58AM -0800, Andrii Nakryiko wrote:
> On Mon, Feb 24, 2025 at 9:44 PM Tao Chen <chen.dylane@linux.dev> wrote:
> >
> > 在 2025/2/25 09:15, Andrii Nakryiko 写道:
> > > On Mon, Feb 24, 2025 at 9:03 AM Tao Chen <chen.dylane@linux.dev> wrote:
> > >>
> > >> Kprobe prog type kfuncs like bpf_session_is_return and
> > >> bpf_session_cookie will check the expected_attach_type,
> > >> so init the expected_attach_type here.
> > >>
> > >> Signed-off-by: Tao Chen <chen.dylane@linux.dev>
> > >> ---
> > >> tools/lib/bpf/libbpf_probes.c | 1 +
> > >> 1 file changed, 1 insertion(+)
> > >>
> > >> diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
> > >> index 8efebc18a215..bb5b457ddc80 100644
> > >> --- a/tools/lib/bpf/libbpf_probes.c
> > >> +++ b/tools/lib/bpf/libbpf_probes.c
> > >> @@ -126,6 +126,7 @@ static int probe_prog_load(enum bpf_prog_type prog_type,
> > >> break;
> > >> case BPF_PROG_TYPE_KPROBE:
> > >> opts.kern_version = get_kernel_version();
> > >> + opts.expected_attach_type = BPF_TRACE_KPROBE_SESSION;
> > >
> > > so KPROBE_SESSION is relative recent feature, if we unconditionally
> > > specify this, we'll regress some feature probes for old kernels where
> > > KPROBE_SESSION isn't supported, no?
> > >
> >
> > Yeah, maybe we can detect the kernel version first, will fix it.
>
> Hold on. I think the entire probing API is kind of unfortunately
> inadequate. Just the fact that we randomly pick some specific
> expected_attach_type to do helpers/kfunc compatibility detection is
> telling. expected_attach_type can change a set of available helpers,
> and yet it's not even an input parameter for either
> libbpf_probe_bpf_helper() or kfunc variant you are trying to add.
could we use the libbpf_probe_bpf_kfunc opts argument and
allow to specify and override expected_attach_type?
jirka
>
> Basically, I'm questioning the validity of even adding this API to
> libbpf. It feels like this kind of detection is simple enough for
> application to do on its own.
>
> >
> > + if (opts.kern_version >= KERNEL_VERSION(6, 12, 0))
> > + opts.expected_attach_type =BPF_TRACE_KPROBE_SESSION;
>
> no, we shouldn't hard-code kernel version for feature detection (but
> also see above, I'm not sure this API should be added in the first
> place)
>
> >
> > > pw-bot: cr
> > >
> > >> break;
> > >> case BPF_PROG_TYPE_LIRC_MODE2:
> > >> opts.expected_attach_type = BPF_LIRC_MODE2;
> > >> --
> > >> 2.43.0
> > >>
> >
> >
> > --
> > Best Regards
> > Tao Chen
next prev parent reply other threads:[~2025-02-26 11:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 16:59 [PATCH bpf-next v8 0/5] Add prog_kfunc feature probe Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 1/5] libbpf: Extract prog load type check from libbpf_probe_bpf_helper Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 2/5] libbpf: Init fd_array when prog probe load Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 3/5] libbpf: Add libbpf_probe_bpf_kfunc API Tao Chen
2025-02-25 1:15 ` Andrii Nakryiko
2025-02-25 5:47 ` Tao Chen
2025-02-25 17:01 ` Andrii Nakryiko
2025-02-24 16:59 ` [PATCH bpf-next v8 4/5] libbpf: Init kprobe prog expected_attach_type for kfunc probe Tao Chen
2025-02-25 1:15 ` Andrii Nakryiko
2025-02-25 5:44 ` Tao Chen
2025-02-25 17:04 ` Andrii Nakryiko
2025-02-26 11:12 ` Jiri Olsa [this message]
2025-02-26 16:10 ` Tao Chen
2025-02-24 16:59 ` [PATCH bpf-next v8 5/5] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests Tao Chen
2025-02-24 17:13 ` [PATCH bpf-next v8 0/5] Add prog_kfunc feature probe Tao Chen
2025-02-25 1:28 ` Eduard Zingerman
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=Z773KxMF0N1nEFsH@krava \
--to=olsajiri@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chen.dylane@gmail.com \
--cc=chen.dylane@linux.dev \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=qmo@kernel.org \
/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