selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Subsystems (3)
Jiri Olsa
reviewerPATCH 1/1 selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Adding missing bpf_iter_vma_offset__destroy call to test_task_vma_offset_common function and related goto jumps.
--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5 -3
@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + goto exit_skel; iter_fd =bpf_iter_create (bpf_link__fd (link));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) - goto exit; + goto exit_link;while ((len =read (iter_fd, buf,sizeof (buf))) >0 ) ;
@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); -exit: +exit_link:bpf_link__destroy (link); +exit_skel: +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Signature · 1 line
2.37.3
Martin KaFai Lau
reviewerQuoted 15 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall totest_task_vma_offset_commonfunction and related goto jumps.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0
tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1516
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);
Thanks for the fix.
A nit. Instead of adding a new goto label. How about doing
skel->links.get_vma_offset = bpf_program_attach_iter(...)
and bpf_iter_vma_offset__destroy(skel) will take care of the link destroy. The earlier test_task_vma_common() is doing that also.
Kui-Feng, please also take a look.
Quoted 23 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5
-3if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + goto exit_skel; iter_fd =bpf_iter_create (bpf_link__fd (link));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) - goto exit; + goto exit_link;while ((len =read (iter_fd, buf,sizeof (buf))) >0 ) ;@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); -exit: +exit_link:bpf_link__destroy (link); +exit_skel: +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 20 lines · Martin KaFai Lau
Quoted 15 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall totest_task_vma_offset_commonfunction and related goto jumps.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1515
Quoted 1 line
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);Thanks for the fix.
Quoted 6 lines
A nit. Instead of adding a new goto label. How about doing
skel->links.get_vma_offset = bpf_program_attach_iter(...)and
bpf_iter_vma_offset__destroy(skel)will take care of the link destroy. The earliertest_task_vma_common()is doing that also.
right, I forgot destroy would do that.. it'll be simpler change
thanks,
jirka
Quoted 22 lines
Kui-Feng, please also take a look.
Quoted 18 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5
-3if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + goto exit_skel; iter_fd =bpf_iter_create (bpf_link__fd (link));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) - goto exit; + goto exit_link;while ((len =read (iter_fd, buf,sizeof (buf))) >0 ) ;@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); -exit: +exit_link:bpf_link__destroy (link); +exit_skel: +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 21 lines · Jiri Olsa
Quoted 20 lines · Martin KaFai Lau
Quoted 15 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall totest_task_vma_offset_commonfunction and related goto jumps.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1515
Quoted 1 line
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);Thanks for the fix.
Quoted 8 lines
Quoted 6 lines
A nit. Instead of adding a new goto label. How about doing
skel->links.get_vma_offset = bpf_program_attach_iter(...)and
bpf_iter_vma_offset__destroy(skel)will take care of the link destroy. The earliertest_task_vma_common()is doing that also.right, I forgot destroy would do that.. it'll be simpler change
ugh actually no ;-) it's outside (of skeleton) link, so it won't get closed in bpf_iter_vma_offset__destroy
the earlier test_task_vma_common does not create such link
jirka
Quoted 26 lines
thanks,
jirkaQuoted 22 lines
Kui-Feng, please also take a look.
Quoted 18 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5
-3if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + goto exit_skel; iter_fd =bpf_iter_create (bpf_link__fd (link));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) - goto exit; + goto exit_link;while ((len =read (iter_fd, buf,sizeof (buf))) >0 ) ;@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); -exit: +exit_link:bpf_link__destroy (link); +exit_skel: +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 27 lines · Jiri Olsa
Quoted 25 lines · Jiri Olsa
Quoted 24 lines · Martin KaFai Lau
Quoted 15 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall totest_task_vma_offset_commonfunction and related goto jumps.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1515
Quoted 1 line
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);Thanks for the fix.
A nit. Instead of adding a new goto label. How about doing
skel->links.get_vma_offset = bpf_program_attach_iter(...)
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
and
bpf_iter_vma_offset__destroy(skel)will take care of the link destroy. The earliertest_task_vma_common()is doing that also.right, I forgot destroy would do that.. it'll be simpler change
ugh actually no ;-) it's outside (of skeleton) link, so it won't get closed in
bpf_iter_vma_offset__destroy
Martin's point was that if you assign it to skel->links.get_vma_offset it will be closed by skeleton's destroy method. So let's do that?
Quoted 31 lines
the earlier
test_task_vma_commondoes not create such linkjirka
Quoted 26 lines
thanks,
jirkaQuoted 22 lines
Kui-Feng, please also take a look.
Quoted 18 lines
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +5
-3if (!ASSERT_OK_PTR (link,"attach_iter" )) -return ; + goto exit_skel; iter_fd =bpf_iter_create (bpf_link__fd (link));if (!ASSERT_GT (iter_fd,0 ,"create_iter" )) - goto exit; + goto exit_link;while ((len =read (iter_fd, buf,sizeof (buf))) >0 ) ;@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, boolclose (iter_fd); -exit: +exit_link:bpf_link__destroy (link); +exit_skel: +bpf_iter_vma_offset__destroy (skel); }static void test_task_vma_offset (void )
Quoted 31 lines · Andrii Nakryiko
Quoted 30 lines · Jiri Olsa
Quoted 28 lines · Jiri Olsa
Quoted 26 lines · Martin KaFai Lau
Quoted 15 lines · Jiri Olsa
Adding missing
bpf_iter_vma_offset__destroycall totest_task_vma_offset_commonfunction and related goto jumps.Fixes b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")Cc Kui-Feng Lee <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0tools/testing/selftests/bpf/prog_tests/bpf_iter.c static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool · line 1515
Quoted 1 line
tools/testing/selftests/bpf/prog_tests/bpf_iter.c +0
-0@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool link =bpf_program__attach_iter (skel->progs.get_vma_offset, opts);Thanks for the fix.
A nit. Instead of adding a new goto label. How about doing
skel->links.get_vma_offset = bpf_program_attach_iter(...)and
bpf_iter_vma_offset__destroy(skel)will take care of the link destroy. The earliertest_task_vma_common()is doing that also.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
right, I forgot destroy would do that.. it'll be simpler change
ugh actually no ;-) it's outside (of skeleton) link, so it won't get closed in
bpf_iter_vma_offset__destroyMartin's point was that if you assign it to
skel->links.get_vma_offsetit will be closed by skeleton's destroy method. So let's do that?
ah ok, will send new version
thanks,
jirka