From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15F962FFFB8 for ; Sun, 31 May 2026 05:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780205272; cv=none; b=qVdqv2PeG69HT4dxhhoOUv2zhxGCP0fwzerWOUsB5N4TeLNQ17a6C5ljf2MEi18R4Vz3KM4TKjIAPV40mZN4UwyJRW90nSAMo7RyoniYEMwYxdA3AFKTycdCrcaa7MVGahnkGE2A934WLQRFfeBgJNXgr3CRbD4pojRcGR91fc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780205272; c=relaxed/simple; bh=/azyC5haL/dW3FyM5Jqt2igHjHSKZJUmmyQs5uzvvOk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ioyWAuVeKvEOmVAgEPGTsV2rt7vXGDZFj9i6ZEhp5ZZmQlwY0T9cZIKY7TsCXy/jTNghbu77RpP8ueOszcjNhKuykaANBPI86GncCDAGXGvArChcV9KFVg2f6mRAjajYisOWetIRcRaXGFdeQ0ITZngb2c+T4oGJFTxOlkRnAOQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=N2tcYugM; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="N2tcYugM" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-13537722193so9334920c88.0 for ; Sat, 30 May 2026 22:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780205270; x=1780810070; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Q+GhNtvHRszsHjww/0M7hnUe+VTtWAqYrR6ygiuNBHE=; b=N2tcYugM9gf7RDa0jMC/T17O8ads43nVPKrjtlI/DVjU+cS4xZRd9JIiSKXNIPKEjn HOL7LqeX28txSiLQEO+vFAuHXGy3Jkl4PEMWpjpQqEzbOBdSuFdR9Psn99OLOGIwDPx2 HOl4LnTIhUWvTzjb9gnkTekL+7Pi9Gs3/cEyH1r5/ZakVuFsgZVoV4nVuduv1r60vqem MRkWaQiLEuQfynsNEVa41H/VVhFzXmqnYmVyD/2qfg8QDz38AxR7QQYWlQBaF5mTMlt6 86FuNXltRsdgUymjvGsZa90n2DvCY9CTFYV1RpnfdieTy6y/jqaL9D+dWtrb7awYKseh DsyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780205270; x=1780810070; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Q+GhNtvHRszsHjww/0M7hnUe+VTtWAqYrR6ygiuNBHE=; b=OR5yg9X0q+4JVCu7UZ8iYMwzhgc1YbAGCAJpCyEOlpxd46KvF7RybhrpAyvo4Gc4CT INajgBTmLV3J7AfUpilgKhe34epDjyTuvEKrBrW9pgxFf4xNdjDG6GNi6g4tcx4G8FaH oYIHrA5z8UHWX6pad94aHxPmSykQeLAT1cLDVIA7l6S92CjQTKDWIVVa08XIWv3nzuA6 k/q4LhJBEAPDvFKEolmxxoeKBqqWMV7iIHhwDHqoCeRe+2Q9QWT5+L0+mS2hCSTniDAc 7syD7SdQ6j/ivaeKeMen+6FJetNZoh27wN2FTqTfpd16NseSSOmQ6dy3Uf6H1wlGKhm/ GoZw== X-Forwarded-Encrypted: i=1; AFNElJ/tjSazQB4eCMqBWw6+ylKioB4Rfo4G7EDHpqZUWKk793B9KEeUpFaGCXbg0i0Kzmi2uDmEOCwt5MyZbls=@vger.kernel.org X-Gm-Message-State: AOJu0YwIHyenGVb6a4qphklsGjodBsJyUgxGNpYHUdC1UpooZeH9FxFn fHnG0k1X8InWQ0Da65xUzKN8I0eE0UwrR7ExV2rU4pDwb+EQ2Kh8BlDwbeK8GFXRVIXTW+2fjFD VxkkV+jHZOQ== X-Received: from dlee6.prod.google.com ([2002:a05:7022:6286:b0:135:7fdc:4c00]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:11f:b0:128:ce44:be8f with SMTP id a92af1059eb24-137d3c10cd3mr3154246c88.2.1780205270057; Sat, 30 May 2026 22:27:50 -0700 (PDT) Date: Sat, 30 May 2026 22:27:29 -0700 In-Reply-To: <20260531052740.796087-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260513230450.529380-1-irogers@google.com> <20260531052740.796087-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531052740.796087-4-irogers@google.com> Subject: [PATCH v2 03/14] perf test: Drain pipe after child finishes to avoid losing output From: Ian Rogers To: irogers@google.com, acme@kernel.org, adrian.hunter@intel.com, namhyung@kernel.org Cc: alexander.shishkin@linux.intel.com, james.clark@linaro.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, mingo@redhat.com, peterz@infradead.org Content-Type: text/plain; charset="UTF-8" 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 --- tools/perf/tests/builtin-test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index f2c135891477..7946878195b7 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -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); -- 2.54.0.823.g6e5bcc1fc9-goog