bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] selftests/bpf: Fix massive output from test_maps
@ 2020-08-26  8:17 Jesper Dangaard Brouer
  2020-08-26  8:29 ` Jesper Dangaard Brouer
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2020-08-26  8:17 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, bpf
  Cc: Daniel Borkmann, Alexei Starovoitov, ykaliuta, zsun, vkabatov

When stdout output from the selftests tool 'test_maps' gets redirected
into e.g file or pipe, then the output lines increase a lot (from 21
to 33949 lines).  This is caused by the printf that happens before the
fork() call, and there are user-space buffered printf data that seems
to be duplicated into the forked process.

To fix this fflush() stdout before the fork loop in __run_parallel().

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 tools/testing/selftests/bpf/test_maps.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
index 754cf611723e..0d92ebcb335d 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -1274,6 +1274,8 @@ static void __run_parallel(unsigned int tasks,
 	pid_t pid[tasks];
 	int i;
 
+	fflush(stdout);
+
 	for (i = 0; i < tasks; i++) {
 		pid[i] = fork();
 		if (pid[i] == 0) {



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

* Re: [PATCH bpf] selftests/bpf: Fix massive output from test_maps
  2020-08-26  8:17 [PATCH bpf] selftests/bpf: Fix massive output from test_maps Jesper Dangaard Brouer
@ 2020-08-26  8:29 ` Jesper Dangaard Brouer
  2020-08-28 12:00   ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2020-08-26  8:29 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, bpf
  Cc: Daniel Borkmann, Alexei Starovoitov, ykaliuta, zsun, vkabatov

On Wed, 26 Aug 2020 10:17:36 +0200
Jesper Dangaard Brouer <brouer@redhat.com> wrote:

> When stdout output from the selftests tool 'test_maps' gets redirected
> into e.g file or pipe, then the output lines increase a lot (from 21
> to 33949 lines).  This is caused by the printf that happens before the
> fork() call, and there are user-space buffered printf data that seems
> to be duplicated into the forked process.
> 
> To fix this fflush() stdout before the fork loop in __run_parallel().
> 
> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>

Fixes: 1a97cf1fe503 ("selftests/bpf: speedup test_maps")

I forgot to add the fixes line to the patch, I hope patchwork[1] will
pick it up for maintainers.

[1] http://patchwork.ozlabs.org/project/netdev/patch/159842985651.1050885.2154399297503372406.stgit@firesoul/
-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


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

* Re: [PATCH bpf] selftests/bpf: Fix massive output from test_maps
  2020-08-26  8:29 ` Jesper Dangaard Brouer
@ 2020-08-28 12:00   ` Daniel Borkmann
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2020-08-28 12:00 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, bpf
  Cc: Daniel Borkmann, Alexei Starovoitov, ykaliuta, zsun, vkabatov

On 8/26/20 10:29 AM, Jesper Dangaard Brouer wrote:
> On Wed, 26 Aug 2020 10:17:36 +0200
> Jesper Dangaard Brouer <brouer@redhat.com> wrote:
> 
>> When stdout output from the selftests tool 'test_maps' gets redirected
>> into e.g file or pipe, then the output lines increase a lot (from 21
>> to 33949 lines).  This is caused by the printf that happens before the
>> fork() call, and there are user-space buffered printf data that seems
>> to be duplicated into the forked process.
>>
>> To fix this fflush() stdout before the fork loop in __run_parallel().
>>
>> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
> 
> Fixes: 1a97cf1fe503 ("selftests/bpf: speedup test_maps")
> 
> I forgot to add the fixes line to the patch, I hope patchwork[1] will
> pick it up for maintainers.

It won't but I've just added it manually. Applied, thanks!

> [1] http://patchwork.ozlabs.org/project/netdev/patch/159842985651.1050885.2154399297503372406.stgit@firesoul/
> 


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

end of thread, other threads:[~2020-08-28 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-26  8:17 [PATCH bpf] selftests/bpf: Fix massive output from test_maps Jesper Dangaard Brouer
2020-08-26  8:29 ` Jesper Dangaard Brouer
2020-08-28 12:00   ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).