[PATCH] D111384: [llvm-profgen] Deduplicate PID when processing perf input
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 7 21:42:55 PDT 2021
wenlei created this revision.
wenlei added reviewers: hoy, wlei.
Herald added subscribers: modimo, lxfind.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When parsing mmap to retrieve PID, deduplicate them before passing PID list to perf script. Perf script would error out when there's duplicated PID in the input, however raw perf data may main duplicated PID for large binary where more than one mmap is needed to load executable segment.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111384
Files:
llvm/tools/llvm-profgen/PerfReader.cpp
Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ llvm/tools/llvm-profgen/PerfReader.cpp
@@ -322,18 +322,26 @@
// Collect the PIDs
TraceStream TraceIt(PerfTraceFile);
std::string PIDs;
+ std::unordered_set<uint32_t> PIDSet;
while (!TraceIt.isAtEoF()) {
MMapEvent MMap;
if (isMMap2Event(TraceIt.getCurrentLine()) &&
extractMMap2EventForBinary(Binary, TraceIt.getCurrentLine(), MMap)) {
- if (!PIDs.empty()) {
- PIDs.append(",");
+ auto It = PIDSet.emplace(MMap.PID);
+ if (It.second) {
+ if (!PIDs.empty()) {
+ PIDs.append(",");
+ }
+ PIDs.append(utostr(MMap.PID));
}
- PIDs.append(utostr(MMap.PID));
}
TraceIt.advance();
}
+ if (PIDs.empty()) {
+ exitWithError("No relevant mmap event is found in perf data.");
+ }
+
// Run perf script again to retrieve events for PIDs collected above
StringRef ScriptSampleArgs[] = {PerfPath, "script", "--show-mmap-events",
"-F", "ip,brstack", "--pid",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111384.378088.patch
Type: text/x-patch
Size: 1165 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/5fb7f28f/attachment.bin>
More information about the llvm-commits
mailing list