bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next 2/4] selftests/bpf: adopt attach_probe selftest to work on old kernels
Date: Tue, 21 Sep 2021 13:48:20 -0700	[thread overview]
Message-ID: <CAADnVQKs1gP8_+_uFps3L3ZHDX8yLCW3fyAm0FuZbkSAQ2EYfA@mail.gmail.com> (raw)
In-Reply-To: <CAEf4BzZH1NP9n7H4vA1usoThrL8Zaa1_KdVQkAdE_88K+yOnfA@mail.gmail.com>

On Tue, Sep 21, 2021 at 1:47 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Tue, Sep 21, 2021 at 1:34 PM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Mon, Sep 20, 2021 at 4:18 PM Andrii Nakryiko <andrii@kernel.org> wrote:
> > >
> > > Make sure to not use ref_ctr_off feature when running on old kernels
> > > that don't support this feature. This allows to test libbpf's legacy
> > > kprobe and uprobe logic on old kernels.
> > >
> > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> > > ---
> > >  .../selftests/bpf/prog_tests/attach_probe.c      | 16 ++++++++++++----
> > >  1 file changed, 12 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > index bf307bb9e446..cbd6b6175d5c 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > @@ -14,6 +14,12 @@ void test_attach_probe(void)
> > >         struct test_attach_probe* skel;
> > >         size_t uprobe_offset;
> > >         ssize_t base_addr, ref_ctr_offset;
> > > +       bool legacy;
> > > +
> > > +       /* check is new-style kprobe/uprobe API is supported */
> > > +       legacy = access("/sys/bus/event_source/devices/kprobe/type", F_OK) != 0;
> > > +
> > > +       legacy = true;
> >
> > What is the idea of the above?
> > One of them is a leftover?
>
> Oh, sorry, `legacy = true` was me locally testing, forgot to remove
> that. This will be properly tested in libbpf CI where we have 4.9
> kernel, I was just trying to simulate this locally on modern kernel.
> I'll re-submit with this removed.

Got it.
Could you explain how access() works to detect it?

  reply	other threads:[~2021-09-21 20:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-20 23:16 [PATCH bpf-next 0/4] libbpf: add legacy uprobe support Andrii Nakryiko
2021-09-20 23:16 ` [PATCH bpf-next 1/4] libbpf: fix memory leak in legacy kprobe attach logic Andrii Nakryiko
2021-09-20 23:16 ` [PATCH bpf-next 2/4] selftests/bpf: adopt attach_probe selftest to work on old kernels Andrii Nakryiko
2021-09-21 20:34   ` Alexei Starovoitov
2021-09-21 20:46     ` Andrii Nakryiko
2021-09-21 20:48       ` Alexei Starovoitov [this message]
2021-09-21 20:53         ` Andrii Nakryiko
2021-09-20 23:16 ` [PATCH bpf-next 3/4] libbpf: refactor and simplify legacy kprobe code Andrii Nakryiko
2021-09-20 23:16 ` [PATCH bpf-next 4/4] libbpf: add legacy uprobe attaching support Andrii Nakryiko

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=CAADnVQKs1gP8_+_uFps3L3ZHDX8yLCW3fyAm0FuZbkSAQ2EYfA@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@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;
as well as URLs for NNTP newsgroup(s).