]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests/bpf: Fix massive output from test_maps
authorJesper Dangaard Brouer <brouer@redhat.com>
Wed, 26 Aug 2020 08:17:36 +0000 (10:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Sep 2020 17:12:27 +0000 (19:12 +0200)
[ Upstream commit fa4505675e093e895b7ec49a76d44f6b5ad9602e ]

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().

Fixes: 1a97cf1fe503 ("selftests/bpf: speedup test_maps")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/159842985651.1050885.2154399297503372406.stgit@firesoul
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/test_maps.c

index c812f0178b6431fd2a4a08e68d29fce3f7d900b0..1c4219ceced2f577588c8d076645b5cc462a733e 100644 (file)
@@ -1282,6 +1282,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) {