selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Subsystems (3)
Jiri Olsa
reviewerPATCH v2 1/1 selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Adding missing bpf_iter_vma_offset__destroy call and using in-skeletin link pointer so we don't need extra bpf_link__destroy call.
---
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(-)
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +7 -6
@@ -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 ; + 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, boolclose (iter_fd); exit: -bpf_link__destroy (link); +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Signature · 1 line
2.37.3
Martin KaFai Lau
reviewerQuoted 26 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall and using in-skeletin link pointer so we don't need extrabpf_link__destroycall.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>---
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(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-1@@ -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;
tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1517
Quoted 9 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +3
-3@@ -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.
Quoted 17 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +4
-2+ 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, boolclose (iter_fd); exit: -bpf_link__destroy (link); +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 31 lines · Martin KaFai Lau
Quoted 29 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall and using in-skeletin link pointer so we don't need extrabpf_link__destroycall.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>---
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(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-1@@ -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;
Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1517
Quoted 6 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +3
-3- 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!
Quoted 19 lines
Quoted 18 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +4
-2+ 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, boolclose (iter_fd); exit: -bpf_link__destroy (link); +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 43 lines · Andrii Nakryiko
Quoted 31 lines · Martin KaFai Lau
Quoted 29 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall and using in-skeletin link pointer so we don't need extrabpf_link__destroycall.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>---
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(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-1@@ -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;Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1517
Quoted 6 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +3
-3- 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.
Quoted 2 lines
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
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +4
-2+ 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, boolclose (iter_fd); exit: -bpf_link__destroy (link); +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:
Quoted 8 lines · On Thu, 6 Oct 2022 10:31:06 +0200 you wrote:
Adding missing
bpf_iter_vma_offset__destroycall and using in-skeletin link pointer so we don't need extrabpf_link__destroycall.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>[...]
Here is the summary with links:
- [PATCHv2,bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
https://git.kernel.org/bpf/bpf-next/c/1d2d941bc140
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html