diff mbox series

[bpf-next] selftests/bpf: Correct map_fd to data_fd in tailcalls

Message ID 20230906154256.95461-1-hffilwlqm@gmail.com (mailing list archive)
State Accepted
Commit 96daa9874211d5497aa70fa409b67afc29f0cb86
Delegated to: BPF
Headers show
Series [bpf-next] selftests/bpf: Correct map_fd to data_fd in tailcalls | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 11 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org martin.lau@linux.dev jolsa@kernel.org haoluo@google.com kpsingh@kernel.org sdf@google.com john.fastabend@gmail.com yonghong.song@linux.dev mykolal@fb.com song@kernel.org
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 78 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 fail Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 fail Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-16 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 fail Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-28 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-15 fail Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-7 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-1 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-0 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for set-matrix

Commit Message

Leon Hwang Sept. 6, 2023, 3:42 p.m. UTC
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

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(-)


base-commit: 05ae0b55e72dca3e22598c7f231b86b6c3b69d83

Comments

Fijalkowski, Maciej Sept. 6, 2023, 8:49 p.m. UTC | #1
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
>
Alexei Starovoitov Sept. 6, 2023, 11:01 p.m. UTC | #2
On Wed, Sep 6, 2023 at 1:50 PM Maciej Fijalkowski
<maciej.fijalkowski@intel.com> wrote:
>
> 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:

No need to resend just to tweak the subject.

Also this is not a fix that is worth sending to bpf tree.
Selftests are typically bpf-next.

> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Thanks
patchwork-bot+netdevbpf@kernel.org Sept. 12, 2023, 12:30 a.m. UTC | #3
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Wed,  6 Sep 2023 23:42:56 +0800 you 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.
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests/bpf: Correct map_fd to data_fd in tailcalls
    https://git.kernel.org/bpf/bpf-next/c/96daa9874211

You are awesome, thank you!
diff mbox series

Patch

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;