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 CFDCD9463 for ; Mon, 1 Jun 2026 00:06:02 +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=1780272365; cv=none; b=kL+lSUOpU7GuwrleYDVPuC37FZB9uXCcUkaTlEekn6w4AHkZVCYBCFefUMVCY+GreFnvxs65azisgz0LzATlMMkfliIdcaF82QGCfjB5b+bOHJ/KLx/Pan2VPwZ7mHa1xlIoOMq0YULHfKzfsu9vcM8YBkKnZYJ0VseIFqaqZwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780272365; c=relaxed/simple; bh=/azyC5haL/dW3FyM5Jqt2igHjHSKZJUmmyQs5uzvvOk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BRFqJ03StX7Rk3YMvQmbYjeRZpf2gI+6lqU74e3tSa4XzLZEw5O4MA//L1mFPH9w49FiCS5RlREOwUz0bFNJmdIKevYMdih3gKp4vn9yIymcpM5l9CGb0COdBFwFtuX3CuuiqR3peBfgvI+0h0+ZGrNDG/FjE96kD0itKY1EafM= 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=TMx1HpTb; 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="TMx1HpTb" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-304f23c55b2so2317020eec.0 for ; Sun, 31 May 2026 17:06:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780272362; x=1780877162; 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=TMx1HpTbNHtXKF4ZnBgNz4nJhDSSSHyzQxR+ww4l2n3krq9MYuTNTOD92BntHL5yB2 OTDqGPQzYizV4uwjARS/8rcu7C2jjSE5BhTmBdpqFJ0I988T9ArbnxVXeCMwt/9SfLEb 8wGPqoB0/EMbKpFpGJJrfVSllxaMZbgesK/fFy5uLUQ5NTXQDaJItswpG1zn+uhh882z SRW6G+Eu27NBXaCysjvCDJRs8p3VFS3qTAcZZArhzJTgfFeQEzQe+SmNRmbzyQweDCOJ 0l4pVIWNJlVl0nJ2LuISv+SLMMGpiQA9ceTkvKvncQcQqk5FdgZqVUCuvPtMKona2k9J awzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780272362; x=1780877162; 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=VTmp0iyuci/AKOMnubopoLUuTXvsnIAJwZfDcJWDqnyHUOfgcCtoceRC+y+Ma7PO1M PfjB0Ro0ltz8YXaguy0LwJj+UoZTgH+l5j9bItvJGtbLRoUVzrIQlAOIfKYihqDqtsND Q3K5onZ4K9L+inQHbJOt5pQVnl1QA8Ifm9o09AX8zKZeXXVgd4m6cOAop33MhQRmQ07Y 032WlHWBqh14rpBOzasMcqWLmQ1KOi6TgqsigMA9ipgCljG1d+xfxtv5oids8KA2d/GC kZpKjQrXS1/f1vJVXoDMkkkFZ5nIzlsdrHD2kVqckzaq3btKUPgLsHLChOIB+tELwOA0 ogDg== X-Forwarded-Encrypted: i=1; AFNElJ//Lc2M76KKBlg/hMWP3S9U3nZLQhOFD0JtPvGnrLZtjdjUOlzs+OBQ8xu1+rW0yo3qxftrsJ5O+hylt/I=@vger.kernel.org X-Gm-Message-State: AOJu0YzamDOeBchODV7RXa3LEMEFTLwkDTwBiPq7giZKnLvz9npwiY3u 5fRjA/kZUaULbEyvSybU7hSFi6ocbJYUR0Maf1UVwJcoANTwd+PY0TV7xMsajHIDNUi4W0RKdlr aeMYULyg0eA== X-Received: from dybmt7.prod.google.com ([2002:a05:7300:d587:b0:304:dc2f:9939]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7300:7495:b0:2dd:8ac2:9f7a with SMTP id 5a478bee46e88-304fa54e972mr4013073eec.11.1780272361644; Sun, 31 May 2026 17:06:01 -0700 (PDT) Date: Sun, 31 May 2026 17:05:36 -0700 In-Reply-To: <20260601000548.1195604-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: <20260531082235.940833-1-irogers@google.com> <20260601000548.1195604-1-irogers@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260601000548.1195604-4-irogers@google.com> Subject: [PATCH 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