diff mbox series

[bpf] selftests/bpf: Fix massive output from test_maps

Message ID 159842985651.1050885.2154399297503372406.stgit@firesoul
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf] selftests/bpf: Fix massive output from test_maps | expand

Commit Message

Jesper Dangaard Brouer Aug. 26, 2020, 8:17 a.m. UTC
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(+)

Comments

Jesper Dangaard Brouer Aug. 26, 2020, 8:29 a.m. UTC | #1
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/
Daniel Borkmann Aug. 28, 2020, noon UTC | #2
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/
>
diff mbox series

Patch

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