From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>
Subject: Re: [PATCH bpf-next 2/4] libbpf: Add uprobe syscall feature detection
Date: Wed, 26 Nov 2025 09:29:52 +0100 [thread overview]
Message-ID: <aSa6gA2o-2-0YMQW@krava> (raw)
In-Reply-To: <CAEf4BzaXac7JyAOXA8+cFj7ZgORHdVxCHceFv417t1xqAe94HA@mail.gmail.com>
On Mon, Nov 24, 2025 at 09:29:05AM -0800, Andrii Nakryiko wrote:
> On Mon, Nov 17, 2025 at 12:36 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding uprobe syscall feature detection that will be used
> > in following changes.
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> > tools/lib/bpf/features.c | 22 ++++++++++++++++++++++
> > tools/lib/bpf/libbpf_internal.h | 2 ++
> > 2 files changed, 24 insertions(+)
> >
> > diff --git a/tools/lib/bpf/features.c b/tools/lib/bpf/features.c
> > index b842b83e2480..587571c21d2d 100644
> > --- a/tools/lib/bpf/features.c
> > +++ b/tools/lib/bpf/features.c
> > @@ -506,6 +506,25 @@ static int probe_kern_arg_ctx_tag(int token_fd)
> > return probe_fd(prog_fd);
> > }
> >
> > +#ifdef __x86_64__
>
> nit: <empty line here>, give the code a bit of breathing room :)
ok :)
> > +#ifndef __NR_uprobe
> > +#define __NR_uprobe 336
> > +#endif
>
> <empty line>
>
> > +static int probe_uprobe_syscall(int token_fd)
> > +{
> > + /*
> > + * When not executed from executed kernel provided trampoline,
>
> "executed from executed kernel"? Maybe: "If kernel supports uprobe()
> syscall, it will return -ENXIO when called from the outside of a
> kernel-generated uprobe trampoline."? Otherwise it will be -ENOSYS or
> something like this, right?
ugh, yep
>
> > + * the uprobe syscall returns ENXIO error.
> > + */
> > + return syscall(__NR_uprobe) == -1 && errno == ENXIO;
>
> nit: please use < 0 check for consistency with other error checking
> logic everywhere else
ok
thanks,
jirka
>
>
> > +}
> > +#else
> > +static int probe_uprobe_syscall(int token_fd)
> > +{
> > + return 0;
> > +}
> > +#endif
> > +
> > typedef int (*feature_probe_fn)(int /* token_fd */);
> >
> > static struct kern_feature_cache feature_cache;
> > @@ -581,6 +600,9 @@ static struct kern_feature_desc {
> > [FEAT_BTF_QMARK_DATASEC] = {
> > "BTF DATASEC names starting from '?'", probe_kern_btf_qmark_datasec,
> > },
> > + [FEAT_UPROBE_SYSCALL] = {
> > + "Kernel supports uprobe syscall", probe_uprobe_syscall,
> > + },
> > };
> >
> > bool feat_supported(struct kern_feature_cache *cache, enum kern_feature_id feat_id)
> > diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
> > index fc59b21b51b5..69aa61c038a9 100644
> > --- a/tools/lib/bpf/libbpf_internal.h
> > +++ b/tools/lib/bpf/libbpf_internal.h
> > @@ -392,6 +392,8 @@ enum kern_feature_id {
> > FEAT_ARG_CTX_TAG,
> > /* Kernel supports '?' at the front of datasec names */
> > FEAT_BTF_QMARK_DATASEC,
> > + /* Kernel supports uprobe syscall */
> > + FEAT_UPROBE_SYSCALL,
> > __FEAT_CNT,
> > };
> >
> > --
> > 2.51.1
> >
next prev parent reply other threads:[~2025-11-26 8:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 8:35 [PATCH bpf-next 0/4] libbpf: Make optimized uprobes backward compatible Jiri Olsa
2025-11-17 8:35 ` [PATCH bpf-next 1/4] selftests/bpf: Emit nop,nop5 instructions for x86_64 usdt probe Jiri Olsa
2025-11-24 17:29 ` Andrii Nakryiko
2025-11-26 8:29 ` Jiri Olsa
2025-11-17 8:35 ` [PATCH bpf-next 2/4] libbpf: Add uprobe syscall feature detection Jiri Olsa
2025-11-24 17:29 ` Andrii Nakryiko
2025-11-26 8:29 ` Jiri Olsa [this message]
2025-11-17 8:35 ` [PATCH bpf-next 3/4] libbpf: Add support to parse extra info in usdt note record Jiri Olsa
2025-11-24 17:29 ` Andrii Nakryiko
2025-11-26 8:30 ` Jiri Olsa
2025-11-17 8:35 ` [PATCH bpf-next 4/4] selftests/bpf: Add test for checking correct nop of optimized usdt Jiri Olsa
2025-11-24 17:34 ` Andrii Nakryiko
2025-11-26 8:29 ` 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=aSa6gA2o-2-0YMQW@krava \
--to=olsajiri@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=john.fastabend@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.com \
/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