diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2018-01-16 16:54:48 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-03 12:34:29 +0000 |
commit | 05692e6459903acbf20c693d7af2c7a5b48c62a2 (patch) | |
tree | a825f4405614895ab0e71e88cb2f64fcffa9ccd3 | |
parent | fcbbc909654fe2da4cec5e9b3e527c05bff5c4c0 (diff) |
Forward the CPU on which an event occurred
This data is only meaningful (i.e. non-zero) when perf record
was run with --sample-cpu.
Change-Id: I36a7c7d9cba6a7e334ff89aacc62b05392e51b26
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r-- | app/perfdata.h | 2 | ||||
-rw-r--r-- | app/perfunwind.cpp | 19 | ||||
-rw-r--r-- | app/perfunwind.h | 1 |
3 files changed, 15 insertions, 7 deletions
diff --git a/app/perfdata.h b/app/perfdata.h index faecf00..3a7b421 100644 --- a/app/perfdata.h +++ b/app/perfdata.h @@ -257,6 +257,7 @@ struct PerfSampleId { quint64 id() const { return m_id; } quint16 fixedLength() const; quint64 sampleType() const { return m_sampleType; } + quint32 cpu() const { return m_cpu; } private: qint32 m_pid; @@ -284,6 +285,7 @@ public: qint32 tid() const { return m_sampleId.tid(); } quint64 time() const { return m_sampleId.time(); } quint64 id() const { return m_sampleId.id(); } + quint32 cpu() const { return m_sampleId.cpu(); } quint16 size() const { return m_header.size; } quint16 misc() const { return m_header.misc; } diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 5499312..c04c6e0 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -222,7 +222,8 @@ void PerfUnwind::comm(const PerfRecordComm &comm) { const qint32 commId = resolveString(comm.comm()); - bufferEvent(TaskEvent{comm.pid(), comm.tid(), comm.time(), commId, Command}, + bufferEvent(TaskEvent{comm.pid(), comm.tid(), comm.time(), comm.cpu(), + commId, Command}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -299,7 +300,8 @@ void PerfUnwind::sendEventFormat(qint32 id, const EventFormat &format) void PerfUnwind::lost(const PerfRecordLost &lost) { - bufferEvent(TaskEvent{lost.pid(), lost.tid(), lost.time(), 0, LostDefinition}, + bufferEvent(TaskEvent{lost.pid(), lost.tid(), lost.time(), lost.cpu(), + 0, LostDefinition}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -643,7 +645,7 @@ void PerfUnwind::analyze(const PerfRecordSample &sample) QByteArray buffer; QDataStream stream(&buffer, QIODevice::WriteOnly); stream << static_cast<quint8>(type) << sample.pid() - << sample.tid() << sample.time() << m_currentUnwind.frames + << sample.tid() << sample.time() << sample.cpu() << m_currentUnwind.frames << numGuessedFrames << values; if (type == TracePointSample) { @@ -662,13 +664,15 @@ void PerfUnwind::analyze(const PerfRecordSample &sample) void PerfUnwind::fork(const PerfRecordFork &sample) { - bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), 0, ThreadStart}, + bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(), + 0, ThreadStart}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } void PerfUnwind::exit(const PerfRecordExit &sample) { - bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), 0, ThreadEnd}, + bufferEvent(TaskEvent{sample.childPid(), sample.childTid(), sample.time(), sample.cpu(), + 0, ThreadEnd}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -989,7 +993,8 @@ void PerfUnwind::flushEventBuffer(uint desiredBufferSize) void PerfUnwind::contextSwitch(const PerfRecordContextSwitch& contextSwitch) { - bufferEvent(TaskEvent{contextSwitch.pid(), contextSwitch.tid(), contextSwitch.time(), + bufferEvent(TaskEvent{contextSwitch.pid(), contextSwitch.tid(), + contextSwitch.time(), contextSwitch.cpu(), contextSwitch.misc() & PERF_RECORD_MISC_SWITCH_OUT, ContextSwitchDefinition}, &m_taskEventsBuffer, &m_stats.numTaskEventsInRound); } @@ -1000,7 +1005,7 @@ void PerfUnwind::sendTaskEvent(const TaskEvent& taskEvent) QDataStream stream(&buffer, QIODevice::WriteOnly); stream << static_cast<quint8>(taskEvent.m_type) << taskEvent.m_pid << taskEvent.m_tid - << taskEvent.m_time; + << taskEvent.m_time << taskEvent.m_cpu; if (taskEvent.m_type == ContextSwitchDefinition) stream << static_cast<bool>(taskEvent.m_payload); diff --git a/app/perfunwind.h b/app/perfunwind.h index 4096d77..00571f6 100644 --- a/app/perfunwind.h +++ b/app/perfunwind.h @@ -281,6 +281,7 @@ private: qint32 m_pid; qint32 m_tid; quint64 m_time; + quint32 m_cpu; qint32 m_payload; EventType m_type; |