From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF72A2EBB84; Sat, 12 Sep 2026 07:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789198214; cv=none; b=TMJGez86TZHH6wW8FD7hTRY1TWAkAhMDkLbfJKRRa+DmGkLS6SAf1gApwJF3sbWh1gNXW2oapdIfHuo++1TUsCOT7udfme7+6vUnYsCt/Ygmnqkm5JC6jlQthtY3s2upXCWZz1iTA6WyeRXIdhb0CYAb7U1k8op+5UYAR+tN9tU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789198214; c=relaxed/simple; bh=kbVR0oQLY8vUMDviYOv6eyaFaJqpSdBrORxru0gAXk4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TYxjXMyf12f881hU64itH9xrhyK28A+8z/iADMw95f8w+NW6Ra/QTL9RTQzbQam26ger7pNQVXnJNyViMyKPrmwx8c6Nn+2j8NJ1pbrGolHWsx5KURVkgCypxCcb0XTOJblbVO50dkUcC3acLD7aZfiSZKo4nInwbrrr90D1xK0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ug0dZ0kA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ug0dZ0kA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D664D1F000FF; Sat, 12 Sep 2026 07:30:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789198212; bh=HXQNJ81AZHrjw5P6KCU1JbCurXfwsbMPOAWGH0oklg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ug0dZ0kAlRhv+AZAXnUp4Pvp7Exz9GWCaAzgqj8taZoIY3gd8IoE2T+eLIxdAACBh nUnB1cssSOAdH5PXQaraHH2vfqHhQCizO/jvfa12PifuKVEVyIzlzw6ZMV4X09PxWp 0teFvA82C0H2c3cgbMVXPZ/5HK2tCjnFJzEzpQHU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ian Rogers , Namhyung Kim , Sasha Levin Subject: [PATCH 7.2 0335/1815] perf record: Fix teardown hang on system-wide multi-threaded sessions Date: Sat, 12 Sep 2026 08:34:45 +0200 Message-ID: <20260912065656.786387686@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ian Rogers [ Upstream commit fb4751e79c45cb48cff1c1d86b10a9cc6f6612fe ] Under system-wide (-a) parallel streaming mode (--threads=cpu), background recording threads can be inundated by a continuous firehose of hardware samples generated by the OS. In this state, a background thread's local hit count remains unequal to its sample count, causing it to bypass the blocking fdarray__poll() call entirely on each iteration of its recording loop. Because the termination check relies on the POLLHUP event status populated specifically by fdarray__poll(), bypassing it prevents the background thread from ever recognizing that its control pipe was closed by the main thread. This traps the background thread in an infinite recording loop, hanging the main thread indefinitely as it awaits a termination acknowledgment that never arrives. Ensure teardown completion by adding explicit evlist__disable() calls in the main thread's cleanup paths at out_child: and out_child_no_flush:. Additionally, patch fdarray__filter() to respect the fdarray_flag__nonfilterable flag, preventing it from incorrectly setting the background thread's control pipe file descriptor to -1 and clearing its revents mask upon processing termination POLLHUP signals. Fixes: f94563fac269 ("perf record: fix poll storm when monitored threads exit") Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Ian Rogers Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- tools/lib/api/fd/array.c | 6 ++++-- tools/perf/builtin-record.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/lib/api/fd/array.c b/tools/lib/api/fd/array.c index ffe8272af59b2..16a047f1906ee 100644 --- a/tools/lib/api/fd/array.c +++ b/tools/lib/api/fd/array.c @@ -115,6 +115,9 @@ int fdarray__filter(struct fdarray *fda, short revents, return 0; for (fd = 0; fd < fda->nr; ++fd) { + if (fda->priv[fd].flags & fdarray_flag__nonfilterable) + continue; + if (!fda->entries[fd].events) continue; @@ -132,8 +135,7 @@ int fdarray__filter(struct fdarray *fda, short revents, continue; } - if (!(fda->priv[fd].flags & fdarray_flag__nonfilterable)) - ++nr; + ++nr; } return nr; diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index ebd3ed0c9b3e8..d1276382b77a2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -2890,11 +2890,13 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) record__synthesize_workload(rec, true); out_child: + evlist__disable(rec->evlist); record__stop_threads(rec); record__mmap_read_all(rec, true); goto out_free_threads; out_child_no_flush: /* mmap read already failed — retrying would just fail again */ + evlist__disable(rec->evlist); record__stop_threads(rec); out_free_threads: record__free_thread_data(rec); -- 2.53.0