Skip to contentSkip to conversation

perf report: Skip unsupported new event types

PATCH Superseded Chun-Tse Shao 2 participants 3 messages Apr 11, 2025 – Apr 14, 2025 perf events

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 perf report: Skip unsupported new event types

perf report currently halts with an error when encountering unsupported new event types (event.type >= PERF_RECORD_HEADER_MAX). This patch modifies the behavior to skip these samples and continue processing the remaining events. Additionally, stops reporting if the new event size is not 8-byte aligned.

---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -2
index 60fb9997ea0d..f55b2ac4e103 100644
@@ -1639,8 +1639,17 @@ static s64 perf_session__process_event(struct perf_session *session,
 	if (session->header.needs_swap)
 		event_swap(event, evlist__sample_id_all(evlist));
 
-	if (event->header.type >= PERF_RECORD_HEADER_MAX)
-		return -EINVAL;
+	if (event->header.type >= PERF_RECORD_HEADER_MAX) {
+		/* perf should not support unaligned event, stop here. */
+		if (event->header.size % sizeof(u64))
+			return -EINVAL;
+
+		/* This perf is outdated and does not support the latest event type. */
+		ui__warning("Unsupported type %u, please considering update perf.\n",
+			    event->header.type);
+		/* Skip unsupported/unaligned event by returning its size. */
+		return event->header.size;
+	}
 
 	events_stats__inc(&evlist->stats, event->header.type);
 
Signature · 1 line
2.49.0.604.gff1f9ca942-goog
maintainer
#1 lore raw
Quoted 22 lines · Chun-Tse Shao

perf report currently halts with an error when encountering unsupported new event types (event.type >= PERF_RECORD_HEADER_MAX). This patch modifies the behavior to skip these samples and continue processing the remaining events. Additionally, stops reporting if the new event size is not 8-byte aligned.

---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +0 -1
index 60fb9997ea0d..f55b2ac4e103 100644
@@ -1639,8 +1639,17 @@ static s64 perf_session__process_event(struct perf_session *session,
 	if (session->header.needs_swap)
 		event_swap(event, evlist__sample_id_all(evlist));
 
-	if (event->header.type >= PERF_RECORD_HEADER_MAX)

tools/perf/util/session.c static s64 perf_session__process_event(struct perf_session *session, · line 1650

Quoted 10 lines
tools/perf/util/session.c +9 -1
-		return -EINVAL;
+	if (event->header.type >= PERF_RECORD_HEADER_MAX) {
+		/* perf should not support unaligned event, stop here. */
+		if (event->header.size % sizeof(u64))
+			return -EINVAL;
+
+		/* This perf is outdated and does not support the latest event type. */
+		ui__warning("Unsupported type %u, please considering update perf.\n",
+			    event->header.type);
+		/* Skip unsupported/unaligned event by returning its size. */

This comment also needs update. Other than that looks good to me.

Thanks,
Namhyung

Quoted 8 lines
tools/perf/util/session.c +2 -0
+		return event->header.size;
+	}
 
 	events_stats__inc(&evlist->stats, event->header.type);
 
Signature · 1 line
2.49.0.604.gff1f9ca942-goog
#2 lore raw

Sorry for my oversight, just sent out v4.

Thanks,
CT

Quoted 48 lines · Namhyung Kim
Quoted 22 lines · Chun-Tse Shao

perf report currently halts with an error when encountering unsupported new event types (event.type >= PERF_RECORD_HEADER_MAX). This patch modifies the behavior to skip these samples and continue processing the remaining events. Additionally, stops reporting if the new event size is not 8-byte aligned.

---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +0 -1
index 60fb9997ea0d..f55b2ac4e103 100644
@@ -1639,8 +1639,17 @@ static s64 perf_session__process_event(struct perf_session *session,
      if (session->header.needs_swap)
              event_swap(event, evlist__sample_id_all(evlist));
 
-     if (event->header.type >= PERF_RECORD_HEADER_MAX)

tools/perf/util/session.c static s64 perf_session__process_event(struct perf_session *session, · line 1650

Quoted 10 lines
tools/perf/util/session.c +9 -1
-             return -EINVAL;
+     if (event->header.type >= PERF_RECORD_HEADER_MAX) {
+             /* perf should not support unaligned event, stop here. */
+             if (event->header.size % sizeof(u64))
+                     return -EINVAL;
+
+             /* This perf is outdated and does not support the latest event type. */
+             ui__warning("Unsupported type %u, please considering update perf.\n",
+                         event->header.type);
+             /* Skip unsupported/unaligned event by returning its size. */

This comment also needs update. Other than that looks good to me.

Thanks,
Namhyung

Quoted 8 lines
tools/perf/util/session.c +2 -1
+             return event->header.size;
+     }
 
      events_stats__inc(&evlist->stats, event->header.type);
 
--

2.49.0.604.gff1f9ca942-goog