Skip to contentSkip to conversation

perf inject: Fix --buildid-all not to eat up MMAP2

PATCH Applied Namhyung Kim 2 participants 2 messages Feb 23, 2023

Subsystems (2)
lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf inject: Fix --buildid-all not to eat up MMAP2

When MMAP2 has PERF_RECORD_MISC_MMAP_BUILD_ID flag, it means the record already has the build-id info. So it marks the DSO as hit, to skip if the same DSO is not processed if it happens to miss the build-id later.

But it missed to copy the MMAP2 record itself so it'd fail to symbolize samples for those regions.

For example, the following generates 249 MMAP2 events.

  $ perf record --buildid-mmap -o- true | perf report --stat -i- | grep MMAP2
           MMAP2 events:        249  (86.8%)

Adding perf inject should not change the number of events like this

  $ perf record --buildid-mmap -o- true | perf inject -b | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:        249  (86.5%)

But when --buildid-all is used, it eats most of the MMAP2 events.

  $ perf record --buildid-mmap -o- true | perf inject -b --buildid-all | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:          1  ( 2.5%)

With this patch, it shows the original number now.

  $ perf record --buildid-mmap -o- true | perf inject -b --buildid-all | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:        249  (86.5%)
Fixes f7fc0d1c915a ("perf inject: Do not inject BUILD_ID record if MMAP2 has it")
---
 tools/perf/builtin-inject.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-inject.c +1 -0
index f8182417b734..10bb1d494258 100644
@@ -538,6 +538,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool,
 			dso->hit = 1;
 		}
 		dso__put(dso);
+		perf_event__repipe(tool, event, sample, machine);
 		return 0;
 	}
 
Signature · 1 line
2.39.2.637.g21b0678d19-goog
maintainer Applied
#1 lore raw

Em Wed, Feb 22, 2023 at 11:01:55PM -0800, Namhyung Kim escreveu:

Quoted 6 lines

When MMAP2 has PERF_RECORD_MISC_MMAP_BUILD_ID flag, it means the record already has the build-id info. So it marks the DSO as hit, to skip if the same DSO is not processed if it happens to miss the build-id later.

But it missed to copy the MMAP2 record itself so it'd fail to symbolize samples for those regions.

Thanks, applied.

- Arnaldo

Quoted 45 lines

For example, the following generates 249 MMAP2 events.

  $ perf record --buildid-mmap -o- true | perf report --stat -i- | grep MMAP2
           MMAP2 events:        249  (86.8%)

Adding perf inject should not change the number of events like this

  $ perf record --buildid-mmap -o- true | perf inject -b | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:        249  (86.5%)

But when --buildid-all is used, it eats most of the MMAP2 events.

  $ perf record --buildid-mmap -o- true | perf inject -b --buildid-all | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:          1  ( 2.5%)

With this patch, it shows the original number now.

  $ perf record --buildid-mmap -o- true | perf inject -b --buildid-all | \
Quoted 1 line

perf report --stat -i- | grep MMAP2

           MMAP2 events:        249  (86.5%)
Fixes f7fc0d1c915a ("perf inject: Do not inject BUILD_ID record if MMAP2 has it")
---
 tools/perf/builtin-inject.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/builtin-inject.c +1 -0
index f8182417b734..10bb1d494258 100644
@@ -538,6 +538,7 @@ static int perf_event__repipe_buildid_mmap2(struct perf_tool *tool,
 			dso->hit = 1;
 		}
 		dso__put(dso);
+		perf_event__repipe(tool, event, sample, machine);
 		return 0;
 	}
 
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Signature · 1 line
- Arnaldo