Skip to content

Commit

Permalink
Add basic support for PERF_FORMAT_LOST in PerfRecordSample parsing
Browse files Browse the repository at this point in the history
Without this, we incorrectly interpreted the binary data stream
leading to totally bogus failures. Most notably, we ended up using
the id of the PERF_FORMAT_LOST as the number of callchain samples
which was really bad as that number is often very large, leading to
excessive memory consumption.

We do not actually read the lost values anywhere, this can come
in a follow-up patch next.

Fixes: KDAB/hotspot#578
Change-Id: I3f73a5f02507fd31e21577585dd89679312782d9
  • Loading branch information
milianw committed Jan 1, 2024
1 parent 9b3ff41 commit ab14b69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/perfattributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ class PerfEventAttributes {
FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
FORMAT_ID = 1U << 2,
FORMAT_GROUP = 1U << 3,
FORMAT_LOST = 1U << 4,

FORMAT_MAX = 1U << 4
FORMAT_MAX = 1U << 5
};

/*
Expand Down
5 changes: 5 additions & 0 deletions app/perfdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ QDataStream &operator>>(QDataStream &stream, PerfRecordSample &record)
quint32 waste32;

const quint64 sampleType = record.m_sampleId.sampleType();
const auto withLostFormat = record.m_readFormat & PerfEventAttributes::FORMAT_LOST;

if (sampleType & PerfEventAttributes::SAMPLE_IDENTIFIER)
stream >> record.m_sampleId.m_id;
Expand Down Expand Up @@ -682,10 +683,14 @@ QDataStream &operator>>(QDataStream &stream, PerfRecordSample &record)
if (record.m_readFormat & PerfEventAttributes::FORMAT_GROUP) {
while (numFormats-- > 0) {
stream >> format.value >> format.id;
if (withLostFormat)
stream >> format.lost;
record.m_readFormats << format;
}
} else {
stream >> format.id;
if (withLostFormat)
stream >> format.lost;
record.m_readFormats << format;
}
}
Expand Down
1 change: 1 addition & 0 deletions app/perfdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ class PerfRecordSample : public PerfRecord {
struct ReadFormat {
quint64 value;
quint64 id;
quint64 lost;
};

QList<ReadFormat> readFormats() const { return m_readFormats; }
Expand Down

0 comments on commit ab14b69

Please sign in to comment.