public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jiri Olsa <jolsa@kernel.org>
Cc: 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 10:21:24 -0700	[thread overview]
Message-ID: <a9e767e6-b8ce-ec1e-47dc-74abfe828713@linux.dev> (raw)
In-Reply-To: <20221006083106.117987-1-jolsa@kernel.org>

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.


> +		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 17:21 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 [this message]
2022-10-06 17:36   ` Andrii Nakryiko
2022-10-06 19:04     ` Jiri Olsa
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=a9e767e6-b8ce-ec1e-47dc-74abfe828713@linux.dev \
    --to=martin.lau@linux.dev \
    --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=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=kuifeng@fb.com \
    --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