From nobody Mon Jun 8 04:16:11 2026 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (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 2444737EFF8 for ; Tue, 2 Jun 2026 07:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780385511; cv=none; b=KG8YujRe84R9k/TfQ4pXNFRovp9EZ6ZRjx195nrzZRkB/exH0V7IsCHecBWrN3d7k0O696RSNEC99g4zuOWtZB9nMWw1+t8r8/FyjnJwvai3qEz4djdlE1A67I5psjvPx7R62TZVTv+4DGK+jUk4FBBkmEip8tX5FJYZMZzaWxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780385511; c=relaxed/simple; bh=64S2aayJ99hXOemnhzucwrwM0vOILIeQ2ZILfYR6sJU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DbSF/1vSXU52aX+BVSgMHPk3PI6rVP9rWywbLJ0hqp2V/tLGt5NgFRSJDPwHDldHp8t5ed6Cf31vhcicICjJ6wYdXyMP5LJ3AIUg3vsawZDco3tZNcZSWTF4SseNnHLZ93u6zafYZduM3fOjtBKPUUrTIX6r2R1SvRM2fjG/tCM= 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=mhEvFuE9; arc=none smtp.client-ip=74.125.82.202 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="mhEvFuE9" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-304b8d0ee63so9007997eec.0 for ; Tue, 02 Jun 2026 00:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780385507; x=1780990307; 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=inYIMUya0beoL7FJV5FWOzzAQLvU+uxd6nfrd81kpuo=; b=mhEvFuE9lPk2mznxqC3TwPVJUr6G0xA7wvrCSkc9bz0WBPAkyDrfKzVuJf55jc96+A 5MNws5exXAQvtP5Co8dF33G1ymbf0OSO06zdv0qG1CxB91F5uUm55ZLv5+xAVdyIj9Wd MT+W2J7CC0kDqtTpbcawYZwpZHtkHD6bgKVfXzpU9eXZ55T/0zIas0iTgwItYQvb8T5W 7IJL42iIKWI3nJWr8r5sHXya2QGU/JmThj+R4//fwSC9NYfOLtZRagBo643wkoyIegPa m9RDP2ZtyIvwsrptu4+unZYvaPTqOUPA6taGGQ1y0A4VbttKMsERCyPEbgdPfFFOnHRt 7auw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780385507; x=1780990307; 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=inYIMUya0beoL7FJV5FWOzzAQLvU+uxd6nfrd81kpuo=; b=bswOSTdmPotPxU4HB7tQ3CFTO6GGtRmVWw1FkQ9cXvK5fSWF5ni16wO4I9YX5m388w lAWUhC/jM1QHzfy7TDNje3fDMsxL3lfXxXYL+LAxLnoOGAKwOLPRS3155LnsEnaLmDAl HQGRLdNxmm3tEdVuh+KT1E+m0mSiXiy+yKCpllp6CtRB2Mgly12xK0ShLW0OTte66GX4 rOf9h7rslYwG110YpepMdWIAaTl5lc9CK7mZNN4YSlwsoW62L6NX1StizyfPPI76Ik/I OdG2kaCRoEIEQiAuHSL9edx2fEP1t3+hYZg6BNUEHQD3YgmwLAACYKwd6iiprr1TeEck xedw== X-Forwarded-Encrypted: i=1; AFNElJ8YdaFX6gwX0bJ7Mjs8tGNL0PHMVRdWU9qNbsETdhF3z3kHOlpUdy/Noi4yRpmLu6y0tZPFYu8axo8/2NY=@vger.kernel.org X-Gm-Message-State: AOJu0YwmyCxPX1qceGZleOcXFYe8sjMKlTqdKrjzebo/sgXMBxUawu6r KzGzH+LSKrnJVRYZF9X37GGRN85BNjtMdYfHfC7YlOfYF1oEjAKmgwiS5j5P+jdGyOft0McZ6bh mK7brNIT9mA== X-Received: from dybtx1.prod.google.com ([2002:a05:7300:f281:b0:304:dc92:9a62]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:a44c:b0:2da:a813:a5fd with SMTP id 5a478bee46e88-304fa5a7ac4mr6717364eec.22.1780385506875; Tue, 02 Jun 2026 00:31:46 -0700 (PDT) Date: Tue, 2 Jun 2026 00:31:19 -0700 In-Reply-To: <20260602073132.2653307-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: <20260601061401.1541457-1-irogers@google.com> <20260602073132.2653307-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.929.g9b7fa37559-goog Message-ID: <20260602073132.2653307-5-irogers@google.com> Subject: [PATCH v7] perf test: Drain pipe after child finishes to avoid losing output From: Ian Rogers To: irogers@google.com, acme@kernel.org, namhyung@kernel.org Cc: adrian.hunter@intel.com, 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-Transfer-Encoding: quoted-printable 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-tes= t.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_test= s, int running_test, int c if (err_done) err_done =3D 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 =3D read(err, buf, sizeof(buf) - 1)) > 0) { + buf[len] =3D '\0'; + strbuf_addstr(&err_output, buf); + } + } if (perf_use_color_default && last_running !=3D -1) { /* Erase "Running (.. active)" line printed before poll/sleep. */ fprintf(debug_file(), PERF_COLOR_DELETE_LINE); --=20 2.54.0.929.g9b7fa37559-goog