]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf test: Drain pipe after child finishes to avoid losing output
authorIan Rogers <irogers@google.com>
Tue, 2 Jun 2026 17:41:15 +0000 (10:41 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 4 Jun 2026 14:36:09 +0000 (11:36 -0300)
When running tests in parallel, the parent process reads output from the
child's pipe. However, it might exit the loop as soon as the child is
detected as finished, potentially missing data that arrived in the pipe
just after the last poll or before the loop terminated.

Address this by draining the pipe after the main loop in finish_test.

Assisted-by: Gemini-CLI:Google Gemini 3
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/builtin-test.c

index f2c135891477c6d6e6e800859dda3e616a171d8b..7946878195b7d7868d533700e5db287181b251ba 100644 (file)
@@ -483,6 +483,16 @@ static void finish_test(struct child_test **child_tests, int running_test, int c
                if (err_done)
                        err_done = check_if_command_finished(&child_test->process);
        }
+       /* Drain any remaining data from the pipe. */
+       if (err > 0) {
+               char buf[512];
+               ssize_t len;
+
+               while ((len = read(err, buf, sizeof(buf) - 1)) > 0) {
+                       buf[len] = '\0';
+                       strbuf_addstr(&err_output, buf);
+               }
+       }
        if (perf_use_color_default && last_running != -1) {
                /* Erase "Running (.. active)" line printed before poll/sleep. */
                fprintf(debug_file(), PERF_COLOR_DELETE_LINE);