Skip to contentSkip to conversation

perf report: Skip unsupported new event types

PATCH In review Chun-Tse Shao 3 participants 5 messages Apr 14, 2025 – Apr 24, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v4 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..ba32f8461a4b 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 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
reviewer Reviewed-by on v4 1/1
#1 lore raw
Quoted 10 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.

Thanks,
Ian

Quoted 31 lines
---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -3
index 60fb9997ea0d..ba32f8461a4b 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 event by returning its size. */
+               return event->header.size;
+       }
 
        events_stats__inc(&evlist->stats, event->header.type);
 
--

2.49.0.604.gff1f9ca942-goog

#2 lore raw

Ping.

Thanks,
CT

Quoted 49 lines · Ian Rogers
Quoted 10 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.

Thanks,
Ian

Quoted 31 lines
---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -3
index 60fb9997ea0d..ba32f8461a4b 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 event by returning its size. */
+               return event->header.size;
+       }
 
        events_stats__inc(&evlist->stats, event->header.type);
 
--

2.49.0.604.gff1f9ca942-goog

#3 lore raw
Quoted 1 line · Chun-Tse Shao

Ping.

Thanks for the ping, I just applied it with these changes, please check,

Thanks,

- Arnaldo

⬢ [acme@toolbox perf-tools-next]$ git diff

tools/perf/util/session.c +1 -1
index ba32f8461a4b6438..81cc56503a2d0f51 100644
@@ -1645,7 +1645,7 @@ static s64 perf_session__process_event(struct perf_session *session,
                        return -EINVAL;
 
                /* This perf is outdated and does not support the latest event type. */
-               ui__warning("Unsupported type %u, please considering update perf.\n",
+               ui__warning("Unsupported header type %u, please consider updating perf.\n",
                            event->header.type);
                /* Skip unsupported event by returning its size. */
                return event->header.size;

⬢ [acme@toolbox perf-tools-next]$

Quoted 54 lines

Thanks,
CT

Quoted 49 lines · Ian Rogers
Quoted 10 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.

Thanks,
Ian

Quoted 31 lines
---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -3
index 60fb9997ea0d..ba32f8461a4b 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 event by returning its size. */
+               return event->header.size;
+       }
 
        events_stats__inc(&evlist->stats, event->header.type);
 
--

2.49.0.604.gff1f9ca942-goog

#4 lore raw

Thank you Arnaldo!

-CT

Quoted 80 lines · Arnaldo Carvalho de Melo
Quoted 1 line · Chun-Tse Shao

Ping.

Thanks for the ping, I just applied it with these changes, please check,

Thanks,

- Arnaldo

⬢ [acme@toolbox perf-tools-next]$ git diff

tools/perf/util/session.c +1 -1
index ba32f8461a4b6438..81cc56503a2d0f51 100644
@@ -1645,7 +1645,7 @@ static s64 perf_session__process_event(struct perf_session *session,
                        return -EINVAL;
 
                /* This perf is outdated and does not support the latest event type. */
-               ui__warning("Unsupported type %u, please considering update perf.\n",
+               ui__warning("Unsupported header type %u, please consider updating perf.\n",
                            event->header.type);
                /* Skip unsupported event by returning its size. */
                return event->header.size;

⬢ [acme@toolbox perf-tools-next]$

Quoted 54 lines

Thanks,
CT

Quoted 49 lines · Ian Rogers
Quoted 10 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.

Thanks,
Ian

Quoted 31 lines
---
 tools/perf/util/session.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -3
index 60fb9997ea0d..ba32f8461a4b 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 event by returning its size. */
+               return event->header.size;
+       }
 
        events_stats__inc(&evlist->stats, event->header.type);
 
--

2.49.0.604.gff1f9ca942-goog