From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 C1FFA3815D3 for ; Sun, 31 May 2026 08:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780215776; cv=none; b=bKtmkE4Mo+7UImlnhcI5YTXsSEeRGIJp8TGxa6XSZ/k7tssnxYuzx+ScHDQ7kxZczav16ZO3IwFKjYCANGgsudNQBqEiRyYzO4HqsekoBeHO3BUm8anpYVzGKTuEUOpg42Eh0v133HtgyGgMASf5rxRQZ5uMs3xQlGSLfCP+m7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780215776; c=relaxed/simple; bh=/azyC5haL/dW3FyM5Jqt2igHjHSKZJUmmyQs5uzvvOk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=tWAb5hYvUJyfkB1y/nk1OmJlKDUFrK5u9zRC9jVwx/l4qlpVEJHhxnef4q0p9ToIhYshJag4JYxgk+gszgUau8vdKNaee3Kmg8CnOCVD4X41Uuqh6DNYWtoKk7U9p3w1qBH3z9WY7V5aKKAYtQft4slD6ePOF9Xu48yvyRsJJ0A= 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=K3CPSt31; arc=none smtp.client-ip=74.125.82.201 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="K3CPSt31" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-304efad654dso6216270eec.1 for ; Sun, 31 May 2026 01:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780215774; x=1780820574; 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=K3CPSt31hRs0h3hOIxNFxccivnUjVLUATvtG3GQcy6S4rY8Ph4H6EQ30WRophVMq6S 1Y4NRwFkHKWzZ3DZ7rmX/ShioqpcL5LheNGQRnrekWimSkzt83l46qSHWXT5XVDCOf/J v7TkHpTHYqrEUiNePWGIyoP2c+eqsg+NZKqzYzYPDCNO86wS8dKuCzwV96Q1kB7aCYD5 uOlnplJj5JLiUwsAxpLqmIin0OXu6yUHcNsTY/s8UzLMfIQxRH6wPxxLujsaAzQ2N/Kg I/wyZnsxaNM0/g8OgLwRteKbl7owk5co1PFTnz/MHCxlog6pAuau0a3TMORAxTYsI5w/ XJRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780215774; x=1780820574; 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=D9k4KUngsUBFR4qR5V37CZaJnuSA3gzjr6WTBf+tQNdfkjJa3eRYFHbXZzQJulJnjZ Uiri3BnzK1yd1lYfSz5RKNsUjUeQiLmpQ1va3zI2OZq7UA4iHTRh2wEnwKbD8iZ+4o8W 9DVQ8j4kmQoT3ubTzIjQq5/TuKb/7FVf6vvLkTLI1yRuK5ZZwhCnX2DQGWGafFUY33Rw pcipW3V/M5NyLBjl7ToAYBberf39hnnobxLrP8MIdTXU/aEDEuVx2IH0DqJSj1CuUkLY 4HYOLANt+i07GRk3YpnGrFbwC0Frc1WRmhadOkWDwqGuA8WSt8hozC7G2BnfjTkVydhO 7n0g== X-Forwarded-Encrypted: i=1; AFNElJ8AjsmD+Zw3XWt82/hhkNAUGEtFtrjIzvahW/hbrYKqZVpa+/t5ilm5oQLiR997ypI9bWhXv36hRw+GdJU=@vger.kernel.org X-Gm-Message-State: AOJu0YwH8WvbWDhElHr5BANZoG1+NECA0bTOQdl5UddMPLvufENdnErQ ukFN+E/Va1+/qdxcDx51QXbkUTXMzidwhgkfxu3J/MNzY5MpRT0apEqSsFuXrxmXHvumQ74UW2i XT2phPdzqbw== X-Received: from dycoi10.prod.google.com ([2002:a05:7301:da8a:b0:304:e0af:c9aa]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:a44c:b0:2ef:8b91:212 with SMTP id 5a478bee46e88-304fa589a60mr3088796eec.14.1780215773609; Sun, 31 May 2026 01:22:53 -0700 (PDT) Date: Sun, 31 May 2026 01:22:23 -0700 In-Reply-To: <20260531082235.940833-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: <20260531063736.871777-1-irogers@google.com> <20260531082235.940833-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260531082235.940833-4-irogers@google.com> Subject: [PATCH v4 03/15] 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