public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
	Kui-Feng Lee <kuifeng@fb.com>,
	bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCHv2 bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Date: Thu, 6 Oct 2022 21:04:42 +0200	[thread overview]
Message-ID: <Yz8myqU6xXtyFzv+@krava> (raw)
In-Reply-To: <CAEf4BzahD0UwnoRRMZYUQ+n1oGXd6Bwcm5mp2sAUG7SAokEHWQ@mail.gmail.com>

On Thu, Oct 06, 2022 at 10:36:08AM -0700, Andrii Nakryiko wrote:
> On Thu, Oct 6, 2022 at 10:21 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
> >
> > On 10/6/22 1:31 AM, Jiri Olsa wrote:
> > > Adding missing bpf_iter_vma_offset__destroy call and using in-skeletin
> > > link pointer so we don't need extra bpf_link__destroy call.
> > >
> > > Fixes: b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")
> > > Cc: Kui-Feng Lee <kuifeng@fb.com>
> > > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > > ---
> > >   v2 changes:
> > >   - use in-skeletin link pointer and destroy call [Martin]
> > >
> > >   tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 13 +++++++------
> > >   1 file changed, 7 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > > index 3369c5ec3a17..d4437a2bba28 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
> > > @@ -1498,7 +1498,6 @@ static noinline int trigger_func(int arg)
> > >   static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool one_proc)
> > >   {
> > >       struct bpf_iter_vma_offset *skel;
> > > -     struct bpf_link *link;
> > >       char buf[16] = {};
> > >       int iter_fd, len;
> > >       int pgsz, shift;
> > > @@ -1513,11 +1512,13 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
> > >               ;
> > >       skel->bss->page_shift = shift;
> > >
> > > -     link = bpf_program__attach_iter(skel->progs.get_vma_offset, opts);
> > > -     if (!ASSERT_OK_PTR(link, "attach_iter"))
> > > -             return;
> > > +     skel->links.get_vma_offset = bpf_program__attach_iter(skel->progs.get_vma_offset, opts);
> > > +     if (!ASSERT_OK_PTR(skel->links.get_vma_offset, "attach_iter")) {
> > > +             skel->links.get_vma_offset = NULL;
> >
> > Applied with this NULL assignment removed.  bpf_link__destroy() can handle err
> > ptr.  Thanks.
> >
> 
> It's even better, with libbpf 1.0 there is no err ptr, it's NULL on
> error. So good call for removing this!

great, thanks :)

jirka

> 
> >
> > > +             goto exit;
> > > +     }
> > >
> > > -     iter_fd = bpf_iter_create(bpf_link__fd(link));
> > > +     iter_fd = bpf_iter_create(bpf_link__fd(skel->links.get_vma_offset));
> > >       if (!ASSERT_GT(iter_fd, 0, "create_iter"))
> > >               goto exit;
> > >
> > > @@ -1535,7 +1536,7 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
> > >       close(iter_fd);
> > >
> > >   exit:
> > > -     bpf_link__destroy(link);
> > > +     bpf_iter_vma_offset__destroy(skel);
> > >   }
> > >
> > >   static void test_task_vma_offset(void)
> >

  reply	other threads:[~2022-10-06 19:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-06  8:31 [PATCHv2 bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call Jiri Olsa
2022-10-06 17:21 ` Martin KaFai Lau
2022-10-06 17:36   ` Andrii Nakryiko
2022-10-06 19:04     ` Jiri Olsa [this message]
2022-10-06 17:30 ` patchwork-bot+netdevbpf

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=Yz8myqU6xXtyFzv+@krava \
    --to=olsajiri@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=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=kuifeng@fb.com \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --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