perf report: Skip unsupported new event types
PATCH v2 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.
--- tools/perf/util/session.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/perf/util/session.c +11 -2
@@ -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 ) { +if (!PERF_ALIGN (event->header.size,sizeof (u64))) +/* perf should not support unaligned event */ +ui__warning ("Skip unaligned event type %u.\n" , event->header.type); +else +/* 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.504.g3bcea36a83-goog
Namhyung Kim
maintainerQuoted 17 lines · Chun-Tse Shao
perf reportcurrently 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.Signed-off-by Chun-Tse Shao <[email protected]>Suggested-by Arnaldo Carvalho de Melo <[email protected]>Suggested-by Namhyung Kim <[email protected]>--- tools/perf/util/session.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)tools/perf/util/session.c +0
-0
tools/perf/util/session.c static s64 perf_session__process_event(struct perf_session *session, · line 1643
Quoted 7 lines
tools/perf/util/session.c +2
-2@@ -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 ) { +if (!PERF_ALIGN (event->header.size,sizeof (u64)))
I think you wanted:
if (event->header.size % sizeof(u64))
tools/perf/util/session.c static s64 perf_session__process_event(struct perf_session *session, · line 1645
Quoted 2 lines
tools/perf/util/session.c +2
-0+/* perf should not support unaligned event */ +ui__warning ("Skip unaligned event type %u.\n" , event->header.type);
And I think we should stop here. Going with unaligned data will cause more troubles I guess.
Thanks,
Namhyung
Quoted 13 lines
tools/perf/util/session.c +7
-0+else +/* 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.504.g3bcea36a83-goog