Skip to content

Commit 29245ae

Browse files
olsajiriacmel
authored andcommitted
perf tools: Do not swap mmap2 fields in case it contains build id
If the PERF_RECORD_MISC_MMAP_BUILD_ID misc bit is set, mmap2 events carries a build id, placed in the following union: union { struct { u32 maj; u32 min; u64 ino; u64 ino_generation; }; struct { u8 build_id_size; u8 __reserved_1; u16 __reserved_2; u8 build_id[20]; }; }; In this case we can't swap above fields. Signed-off-by: Jiri Olsa <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexei Budankov <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Michael Petlan <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent dde587a commit 29245ae

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/perf/util/session.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,13 @@ static void perf_event__mmap2_swap(union perf_event *event,
593593
event->mmap2.start = bswap_64(event->mmap2.start);
594594
event->mmap2.len = bswap_64(event->mmap2.len);
595595
event->mmap2.pgoff = bswap_64(event->mmap2.pgoff);
596-
event->mmap2.maj = bswap_32(event->mmap2.maj);
597-
event->mmap2.min = bswap_32(event->mmap2.min);
598-
event->mmap2.ino = bswap_64(event->mmap2.ino);
599-
event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation);
596+
597+
if (!(event->header.misc & PERF_RECORD_MISC_MMAP_BUILD_ID)) {
598+
event->mmap2.maj = bswap_32(event->mmap2.maj);
599+
event->mmap2.min = bswap_32(event->mmap2.min);
600+
event->mmap2.ino = bswap_64(event->mmap2.ino);
601+
event->mmap2.ino_generation = bswap_64(event->mmap2.ino_generation);
602+
}
600603

601604
if (sample_id_all) {
602605
void *data = &event->mmap2.filename;

0 commit comments

Comments
 (0)