public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
To: Leon Hwang <hffilwlqm@gmail.com>
Cc: <bpf@vger.kernel.org>, <andrii@kernel.org>, <ast@kernel.org>,
	<daniel@iogearbox.net>, <jakub@cloudflare.com>,
	<kernel-patches-bot@fb.com>
Subject: Re: [PATCH bpf-next] selftests/bpf: Correct map_fd to data_fd in tailcalls
Date: Wed, 6 Sep 2023 22:49:42 +0200	[thread overview]
Message-ID: <ZPjl5is9OKK7Anjs@boxer> (raw)
In-Reply-To: <20230906154256.95461-1-hffilwlqm@gmail.com>

On Wed, Sep 06, 2023 at 11:42:56PM +0800, Leon Hwang wrote:
> Get and check data_fd. It should not check map_fd again.
> 
> Meanwhile, correct some 'return' to 'goto out'.
> 
> Thank the suggestion from Maciej in "bpf, x64: Fix tailcall infinite
> loop"[0] discussions.
> 
> [0] https://lore.kernel.org/bpf/e496aef8-1f80-0f8e-dcdd-25a8c300319a@gmail.com/T/#m7d3b601066ba66400d436b7e7579b2df4a101033

in the subject of the patch you should have 'bpf', not 'bpf-next'.

Fix this and send v2 please. You can also include my:
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> 
> Fixes: 79d49ba048ec ("bpf, testing: Add various tail call test cases")
> Fixes: 3b0379111197 ("selftests/bpf: Add tailcall_bpf2bpf tests")
> Fixes: 5e0b0a4c52d3 ("selftests/bpf: Test tail call counting with bpf2bpf and data on stack")
> Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
> ---
>  .../selftests/bpf/prog_tests/tailcalls.c      | 32 +++++++++----------
>  1 file changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/tailcalls.c b/tools/testing/selftests/bpf/prog_tests/tailcalls.c
> index 58fe2c586ed76..09c189761926c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/tailcalls.c
> +++ b/tools/testing/selftests/bpf/prog_tests/tailcalls.c
> @@ -271,11 +271,11 @@ static void test_tailcall_count(const char *which)
>  
>  	data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
>  	if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
> -		return;
> +		goto out;
>  
>  	data_fd = bpf_map__fd(data_map);
> -	if (CHECK_FAIL(map_fd < 0))
> -		return;
> +	if (CHECK_FAIL(data_fd < 0))
> +		goto out;
>  
>  	i = 0;
>  	err = bpf_map_lookup_elem(data_fd, &i, &val);
> @@ -352,11 +352,11 @@ static void test_tailcall_4(void)
>  
>  	data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
>  	if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
> -		return;
> +		goto out;
>  
>  	data_fd = bpf_map__fd(data_map);
> -	if (CHECK_FAIL(map_fd < 0))
> -		return;
> +	if (CHECK_FAIL(data_fd < 0))
> +		goto out;
>  
>  	for (i = 0; i < bpf_map__max_entries(prog_array); i++) {
>  		snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
> @@ -442,11 +442,11 @@ static void test_tailcall_5(void)
>  
>  	data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
>  	if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
> -		return;
> +		goto out;
>  
>  	data_fd = bpf_map__fd(data_map);
> -	if (CHECK_FAIL(map_fd < 0))
> -		return;
> +	if (CHECK_FAIL(data_fd < 0))
> +		goto out;
>  
>  	for (i = 0; i < bpf_map__max_entries(prog_array); i++) {
>  		snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
> @@ -631,11 +631,11 @@ static void test_tailcall_bpf2bpf_2(void)
>  
>  	data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
>  	if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
> -		return;
> +		goto out;
>  
>  	data_fd = bpf_map__fd(data_map);
> -	if (CHECK_FAIL(map_fd < 0))
> -		return;
> +	if (CHECK_FAIL(data_fd < 0))
> +		goto out;
>  
>  	i = 0;
>  	err = bpf_map_lookup_elem(data_fd, &i, &val);
> @@ -805,11 +805,11 @@ static void test_tailcall_bpf2bpf_4(bool noise)
>  
>  	data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
>  	if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
> -		return;
> +		goto out;
>  
>  	data_fd = bpf_map__fd(data_map);
> -	if (CHECK_FAIL(map_fd < 0))
> -		return;
> +	if (CHECK_FAIL(data_fd < 0))
> +		goto out;
>  
>  	i = 0;
>  	val.noise = noise;
> @@ -872,7 +872,7 @@ static void test_tailcall_bpf2bpf_6(void)
>  	ASSERT_EQ(topts.retval, 0, "tailcall retval");
>  
>  	data_fd = bpf_map__fd(obj->maps.bss);
> -	if (!ASSERT_GE(map_fd, 0, "bss map fd"))
> +	if (!ASSERT_GE(data_fd, 0, "bss map fd"))
>  		goto out;
>  
>  	i = 0;
> 
> base-commit: 05ae0b55e72dca3e22598c7f231b86b6c3b69d83
> -- 
> 2.41.0
> 

  reply	other threads:[~2023-09-06 20:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-06 15:42 [PATCH bpf-next] selftests/bpf: Correct map_fd to data_fd in tailcalls Leon Hwang
2023-09-06 20:49 ` Maciej Fijalkowski [this message]
2023-09-06 23:01   ` Alexei Starovoitov
2023-09-12  0: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=ZPjl5is9OKK7Anjs@boxer \
    --to=maciej.fijalkowski@intel.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=hffilwlqm@gmail.com \
    --cc=jakub@cloudflare.com \
    --cc=kernel-patches-bot@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