public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Fix kmem_cache iterator draining
@ 2025-04-28 18:02 T.J. Mercier
  2025-04-28 18:16 ` Song Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: T.J. Mercier @ 2025-04-28 18:02 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykola Lysenko, Shuah Khan, Namhyung Kim
  Cc: T.J. Mercier, bpf, linux-kselftest, linux-kernel

The closing parentheses around the read syscall is misplaced, causing
single byte reads from the iterator instead of buf sized reads. While
the end result is the same, many more read calls than necessary are
performed.

$ tools/testing/selftests/bpf/vmtest.sh  "./test_progs -t kmem_cache_iter"
145/1   kmem_cache_iter/check_task_struct:OK
145/2   kmem_cache_iter/check_slabinfo:OK
145/3   kmem_cache_iter/open_coded_iter:OK
145     kmem_cache_iter:OK
Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED

Fixes: a496d0cdc84d ("selftests/bpf: Add a test for kmem_cache_iter")
Signed-off-by: T.J. Mercier <tjmercier@google.com>
---
 tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
index 8e13a3416a21..1de14b111931 100644
--- a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
@@ -104,7 +104,7 @@ void test_kmem_cache_iter(void)
 		goto destroy;
 
 	memset(buf, 0, sizeof(buf));
-	while (read(iter_fd, buf, sizeof(buf) > 0)) {
+	while (read(iter_fd, buf, sizeof(buf)) > 0) {
 		/* Read out all contents */
 		printf("%s", buf);
 	}

base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e
-- 
2.49.0.906.g1f30a19c02-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: Fix kmem_cache iterator draining
  2025-04-28 18:02 [PATCH] selftests/bpf: Fix kmem_cache iterator draining T.J. Mercier
@ 2025-04-28 18:16 ` Song Liu
  2025-04-28 20:06 ` Namhyung Kim
  2025-04-29 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Song Liu @ 2025-04-28 18:16 UTC (permalink / raw)
  To: T.J. Mercier
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Mykola Lysenko,
	Shuah Khan, Namhyung Kim, bpf, linux-kselftest, linux-kernel

On Mon, Apr 28, 2025 at 11:03 AM T.J. Mercier <tjmercier@google.com> wrote:
>
> The closing parentheses around the read syscall is misplaced, causing
> single byte reads from the iterator instead of buf sized reads. While
> the end result is the same, many more read calls than necessary are
> performed.
>
> $ tools/testing/selftests/bpf/vmtest.sh  "./test_progs -t kmem_cache_iter"
> 145/1   kmem_cache_iter/check_task_struct:OK
> 145/2   kmem_cache_iter/check_slabinfo:OK
> 145/3   kmem_cache_iter/open_coded_iter:OK
> 145     kmem_cache_iter:OK
> Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
>
> Fixes: a496d0cdc84d ("selftests/bpf: Add a test for kmem_cache_iter")
> Signed-off-by: T.J. Mercier <tjmercier@google.com>

Acked-by: Song Liu <song@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: Fix kmem_cache iterator draining
  2025-04-28 18:02 [PATCH] selftests/bpf: Fix kmem_cache iterator draining T.J. Mercier
  2025-04-28 18:16 ` Song Liu
@ 2025-04-28 20:06 ` Namhyung Kim
  2025-04-29  3:00   ` T.J. Mercier
  2025-04-29 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Namhyung Kim @ 2025-04-28 20:06 UTC (permalink / raw)
  To: T.J. Mercier
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykola Lysenko, Shuah Khan, bpf, linux-kselftest, linux-kernel

Hello,

On Mon, Apr 28, 2025 at 06:02:54PM +0000, T.J. Mercier wrote:
> The closing parentheses around the read syscall is misplaced, causing
> single byte reads from the iterator instead of buf sized reads. While
> the end result is the same, many more read calls than necessary are
> performed.
> 
> $ tools/testing/selftests/bpf/vmtest.sh  "./test_progs -t kmem_cache_iter"
> 145/1   kmem_cache_iter/check_task_struct:OK
> 145/2   kmem_cache_iter/check_slabinfo:OK
> 145/3   kmem_cache_iter/open_coded_iter:OK
> 145     kmem_cache_iter:OK
> Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> 
> Fixes: a496d0cdc84d ("selftests/bpf: Add a test for kmem_cache_iter")
> Signed-off-by: T.J. Mercier <tjmercier@google.com>

Oops, thanks for fixing this.

Acked-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung

> ---
>  tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> index 8e13a3416a21..1de14b111931 100644
> --- a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> +++ b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> @@ -104,7 +104,7 @@ void test_kmem_cache_iter(void)
>  		goto destroy;
>  
>  	memset(buf, 0, sizeof(buf));
> -	while (read(iter_fd, buf, sizeof(buf) > 0)) {
> +	while (read(iter_fd, buf, sizeof(buf)) > 0) {
>  		/* Read out all contents */
>  		printf("%s", buf);
>  	}
> 
> base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e
> -- 
> 2.49.0.906.g1f30a19c02-goog
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: Fix kmem_cache iterator draining
  2025-04-28 20:06 ` Namhyung Kim
@ 2025-04-29  3:00   ` T.J. Mercier
  0 siblings, 0 replies; 5+ messages in thread
From: T.J. Mercier @ 2025-04-29  3:00 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykola Lysenko, Shuah Khan, bpf, linux-kselftest, linux-kernel

On Mon, Apr 28, 2025 at 1:06 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Mon, Apr 28, 2025 at 06:02:54PM +0000, T.J. Mercier wrote:
> > The closing parentheses around the read syscall is misplaced, causing
> > single byte reads from the iterator instead of buf sized reads. While
> > the end result is the same, many more read calls than necessary are
> > performed.
> >
> > $ tools/testing/selftests/bpf/vmtest.sh  "./test_progs -t kmem_cache_iter"
> > 145/1   kmem_cache_iter/check_task_struct:OK
> > 145/2   kmem_cache_iter/check_slabinfo:OK
> > 145/3   kmem_cache_iter/open_coded_iter:OK
> > 145     kmem_cache_iter:OK
> > Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> >
> > Fixes: a496d0cdc84d ("selftests/bpf: Add a test for kmem_cache_iter")
> > Signed-off-by: T.J. Mercier <tjmercier@google.com>
>
> Oops, thanks for fixing this.
>
> Acked-by: Namhyung Kim <namhyung@kernel.org>
>
> Thanks,
> Namhyung

No worries, thanks! It's been helpful reading through this code.

> > ---
> >  tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> > index 8e13a3416a21..1de14b111931 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/kmem_cache_iter.c
> > @@ -104,7 +104,7 @@ void test_kmem_cache_iter(void)
> >               goto destroy;
> >
> >       memset(buf, 0, sizeof(buf));
> > -     while (read(iter_fd, buf, sizeof(buf) > 0)) {
> > +     while (read(iter_fd, buf, sizeof(buf)) > 0) {
> >               /* Read out all contents */
> >               printf("%s", buf);
> >       }
> >
> > base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e
> > --
> > 2.49.0.906.g1f30a19c02-goog
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: Fix kmem_cache iterator draining
  2025-04-28 18:02 [PATCH] selftests/bpf: Fix kmem_cache iterator draining T.J. Mercier
  2025-04-28 18:16 ` Song Liu
  2025-04-28 20:06 ` Namhyung Kim
@ 2025-04-29 20:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-29 20:40 UTC (permalink / raw)
  To: T.J. Mercier
  Cc: ast, daniel, andrii, martin.lau, eddyz87, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, mykolal, shuah,
	namhyung, bpf, linux-kselftest, linux-kernel

Hello:

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

On Mon, 28 Apr 2025 18:02:54 +0000 you wrote:
> The closing parentheses around the read syscall is misplaced, causing
> single byte reads from the iterator instead of buf sized reads. While
> the end result is the same, many more read calls than necessary are
> performed.
> 
> $ tools/testing/selftests/bpf/vmtest.sh  "./test_progs -t kmem_cache_iter"
> 145/1   kmem_cache_iter/check_task_struct:OK
> 145/2   kmem_cache_iter/check_slabinfo:OK
> 145/3   kmem_cache_iter/open_coded_iter:OK
> 145     kmem_cache_iter:OK
> Summary: 1/3 PASSED, 0 SKIPPED, 0 FAILED
> 
> [...]

Here is the summary with links:
  - selftests/bpf: Fix kmem_cache iterator draining
    https://git.kernel.org/bpf/bpf-next/c/38d976c32d85

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-29 20:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-28 18:02 [PATCH] selftests/bpf: Fix kmem_cache iterator draining T.J. Mercier
2025-04-28 18:16 ` Song Liu
2025-04-28 20:06 ` Namhyung Kim
2025-04-29  3:00   ` T.J. Mercier
2025-04-29 20:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox