summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2020-09-24 13:28:03 +0200
committerMilian Wolff <milian.wolff@kdab.com>2020-09-25 12:24:32 +0000
commit41fa1524eaad365ed50e99724b1ac81400034bad (patch)
treeadaf284905558cb2cf86619de93c8910895518cd
parent37720832aa0212c51cbd60f43dda7dc9a4f2f425 (diff)
Parse PERF_RECORD_SWITCH_CPU_WIDE
For now this just allows off-CPU cost analysis for data recorded with `perf record -a --switch-events`. In the future, we could even send the nextPrev{P,T}id too, which would allow us to draw arrows beetween the context switch targets. Change-Id: Ie9b88bb9c54a3238ba8d6addd013b8419c03c42f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--app/perfdata.cpp18
-rw-r--r--app/perfdata.h17
2 files changed, 35 insertions, 0 deletions
diff --git a/app/perfdata.cpp b/app/perfdata.cpp
index 2dfbc6c..27a2095 100644
--- a/app/perfdata.cpp
+++ b/app/perfdata.cpp
@@ -253,6 +253,14 @@ PerfData::ReadStatus PerfData::processEvents(QDataStream &stream)
m_destination->contextSwitch(switchEvent);
break;
}
+ case PERF_RECORD_SWITCH_CPU_WIDE: {
+ PerfRecordContextSwitchCpuWide switchEvent(&m_eventHeader, sampleType, sampleIdAll);
+ stream >> switchEvent;
+ // TODO: also send prevNext{T,P}id, that would allow switch markers in the GUI to
+ // show where a switch comes from/goes to
+ m_destination->contextSwitch(switchEvent);
+ break;
+ }
#ifdef HAVE_ZSTD
case PERF_RECORD_COMPRESSED: {
@@ -801,3 +809,13 @@ QDataStream &operator>>(QDataStream &stream, PerfRecordContextSwitch &record)
{
return stream >> record.m_sampleId;
}
+
+PerfRecordContextSwitchCpuWide::PerfRecordContextSwitchCpuWide(PerfEventHeader *header, quint64 sampleType, bool sampleIdAll) :
+ PerfRecordContextSwitch(header, sampleType, sampleIdAll)
+{
+}
+
+QDataStream &operator>>(QDataStream &stream, PerfRecordContextSwitchCpuWide &record)
+{
+ return stream >> record.m_nextPrevPid >> record.m_nextPrevTid >> record.m_sampleId;
+}
diff --git a/app/perfdata.h b/app/perfdata.h
index 942de34..6b2d913 100644
--- a/app/perfdata.h
+++ b/app/perfdata.h
@@ -603,6 +603,23 @@ private:
QDataStream &operator>>(QDataStream &stream, PerfRecordContextSwitch &record);
+class PerfRecordContextSwitchCpuWide : public PerfRecordContextSwitch
+{
+public:
+ PerfRecordContextSwitchCpuWide(PerfEventHeader *header = 0, quint64 sampleType = 0,
+ bool sampleIdAll = false);
+
+ qint32 nextPrevPid() const { return m_nextPrevPid; }
+ qint32 nextPrevTid() const { return m_nextPrevTid; }
+
+private:
+ qint32 m_nextPrevPid;
+ qint32 m_nextPrevTid;
+ friend QDataStream &operator>>(QDataStream &stream, PerfRecordContextSwitchCpuWide &record);
+};
+
+QDataStream &operator>>(QDataStream &stream, PerfRecordContextSwitchCpuWide &record);
+
class PerfUnwind;
class PerfData : public QObject
{