Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH 1/9] perf header: Tolerate inconsistent HEADER_GROUP_DESC
@ 2026-08-03  9:06 Amir Ayupov
  2026-08-03  9:06 ` [PATCH 2/9] perf thread-stack: Report branch stack hw_idx as not available Amir Ayupov
                   ` (7 more replies)
  0 siblings, 8 replies; 13+ messages in thread
From: Amir Ayupov @ 2026-08-03  9:06 UTC (permalink / raw)
  To: linux-perf-users, coresight, linux-arm-kernel, Suzuki K Poulose,
	James Clark, Leo Yan, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	John Garry, Will Deacon
  Cc: linux-doc, Mike Leach, Jonathan Corbet, Shuah Khan,
	Swapnil Sapkal

process_group_desc() rejects the entire perf.data file ("invalid group
desc" -> "incompatible file format") whenever the group description is
inconsistent with the event list. Group information is optional metadata
and is not needed to decode samples, so a single bad group descriptor
should not make an otherwise valid file unreadable.

This is observable with AUX area recordings (Arm CoreSight ETM, Intel PT)
that use aux-action pause/resume: the aux-action regrouping inflates the
AUX group leader's nr_members, producing a group descriptor that the
strict reader rejects, even though the file is otherwise fine (older perf
and other tooling read it by rebuilding groups from event records).

Warn and fall back to a consistent ungrouped event list instead of
failing the read.

Signed-off-by: Amir Ayupov <aaupov@fb.com>
---
 tools/perf/util/header.c | 42 +++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index e90e541f546b4..ddc59624d639b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3373,6 +3373,19 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
 	i = nr = 0;
 	evlist__for_each_entry(session->evlist, evsel) {
 		if (i < nr_groups && evsel->core.idx == (int) desc[i].leader_idx) {
+			if (!desc[i].nr_members)
+				goto out_inconsistent;
+
+			if (nr > 0) {
+				/*
+				 * A new leader was found before the previous
+				 * group's members were all consumed, so the
+				 * group description is inconsistent with the
+				 * event list.
+				 */
+				goto out_inconsistent;
+			}
+
 			evsel__set_leader(evsel, evsel);
 			/* {anon_group} is a dummy name */
 			if (strcmp(desc[i].name, "{anon_group}")) {
@@ -3381,11 +3394,6 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
 			}
 			evsel->core.nr_members = desc[i].nr_members;
 
-			if (i >= nr_groups || nr > 0) {
-				pr_debug("invalid group desc\n");
-				goto out_free;
-			}
-
 			leader = evsel;
 			nr = evsel->core.nr_members - 1;
 			i++;
@@ -3397,10 +3405,8 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
 		}
 	}
 
-	if (i != nr_groups || nr != 0) {
-		pr_debug("invalid group desc\n");
-		goto out_free;
-	}
+	if (i != nr_groups || nr != 0)
+		goto out_inconsistent;
 
 	ret = 0;
 out_free:
@@ -3409,6 +3415,24 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused)
 	free(desc);
 
 	return ret;
+
+out_inconsistent:
+	/*
+	 * Group information is optional metadata and is not required to decode
+	 * samples. Rather than rejecting the whole file, warn and fall back to
+	 * a consistent ungrouped event list. This can happen with otherwise
+	 * valid perf.data files, e.g. AUX area (Intel PT, Arm CoreSight ETM)
+	 * recordings using aux-action pause/resume.
+	 */
+	pr_warning("Inconsistent HEADER_GROUP_DESC, ignoring group information\n");
+	env->nr_groups = 0;
+	evlist__for_each_entry(session->evlist, evsel) {
+		evsel__set_leader(evsel, evsel);
+		evsel->core.nr_members = 1;
+		zfree(&evsel->group_name);
+	}
+	ret = 0;
+	goto out_free;
 }
 
 static int process_auxtrace(struct feat_fd *ff, void *data __maybe_unused)
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-08-03  9:27 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03  9:06 [PATCH 1/9] perf header: Tolerate inconsistent HEADER_GROUP_DESC Amir Ayupov
2026-08-03  9:06 ` [PATCH 2/9] perf thread-stack: Report branch stack hw_idx as not available Amir Ayupov
2026-08-03  9:19   ` sashiko-bot
2026-08-03  9:06 ` [PATCH 3/9] perf thread-stack: Bound wrapped branch stack copy Amir Ayupov
2026-08-03  9:26   ` sashiko-bot
2026-08-03  9:06 ` [PATCH 4/9] perf dlfilter: Add non-empty branch stack filter Amir Ayupov
2026-08-03  9:06 ` [PATCH 5/9] perf cs-etm: Split up cs_etm__process_timestamped_queues() Amir Ayupov
2026-08-03  9:06 ` [PATCH 6/9] perf cs-etm: Add branch history to existing samples Amir Ayupov
2026-08-03  9:23   ` sashiko-bot
2026-08-03  9:06 ` [PATCH 7/9] perf test cs-etm: Test branch history on " Amir Ayupov
2026-08-03  9:21   ` sashiko-bot
2026-08-03  9:06 ` [PATCH 8/9] perf cs-etm: Consume branch history when attaching it to a sample Amir Ayupov
2026-08-03  9:06 ` [PATCH 9/9] Documentation: coresight: Document context-sensitive PGO workflow Amir Ayupov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox