diff options
Diffstat (limited to 'daemon/PerfSource.cpp')
-rw-r--r-- | daemon/PerfSource.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/daemon/PerfSource.cpp b/daemon/PerfSource.cpp index 1f1cb19..ecfaa66 100644 --- a/daemon/PerfSource.cpp +++ b/daemon/PerfSource.cpp | |||
@@ -37,7 +37,7 @@ static bool sendTracepointFormat(Buffer *const buffer, const char *const name, D | |||
37 | return true; | 37 | return true; |
38 | } | 38 | } |
39 | 39 | ||
40 | PerfSource::PerfSource(sem_t *senderSem, sem_t *startProfile) : mSummary(0, FRAME_SUMMARY, 1024, senderSem), mBuffer(0, FRAME_PERF_ATTRS, 1024*1024, senderSem), mCountersBuf(), mCountersGroup(&mCountersBuf), mMonitor(), mUEvent(), mSenderSem(senderSem), mStartProfile(startProfile), mInterruptFd(-1), mIsDone(false) { | 40 | PerfSource::PerfSource(sem_t *senderSem, sem_t *startProfile) : mSummary(0, FRAME_SUMMARY, 1024, senderSem), mBuffer(0, FRAME_PERF_ATTRS, 4*1024*1024, senderSem), mCountersBuf(), mCountersGroup(&mCountersBuf), mMonitor(), mUEvent(), mSenderSem(senderSem), mStartProfile(startProfile), mInterruptFd(-1), mIsDone(false) { |
41 | long l = sysconf(_SC_PAGE_SIZE); | 41 | long l = sysconf(_SC_PAGE_SIZE); |
42 | if (l < 0) { | 42 | if (l < 0) { |
43 | logg->logError(__FILE__, __LINE__, "Unable to obtain the page size"); | 43 | logg->logError(__FILE__, __LINE__, "Unable to obtain the page size"); |
@@ -74,6 +74,9 @@ bool PerfSource::prepare() { | |||
74 | DynBuf b3; | 74 | DynBuf b3; |
75 | long long schedSwitchId; | 75 | long long schedSwitchId; |
76 | 76 | ||
77 | // Reread cpuinfo since cores may have changed since startup | ||
78 | gSessionData->readCpuInfo(); | ||
79 | |||
77 | if (0 | 80 | if (0 |
78 | || !mMonitor.init() | 81 | || !mMonitor.init() |
79 | || !mUEvent.init() | 82 | || !mUEvent.init() |
@@ -83,14 +86,14 @@ bool PerfSource::prepare() { | |||
83 | || !sendTracepointFormat(&mBuffer, SCHED_SWITCH, &printb, &b1) | 86 | || !sendTracepointFormat(&mBuffer, SCHED_SWITCH, &printb, &b1) |
84 | 87 | ||
85 | // Only want RAW but not IP on sched_switch and don't want TID on SAMPLE_ID | 88 | // Only want RAW but not IP on sched_switch and don't want TID on SAMPLE_ID |
86 | || !mCountersGroup.add(&mBuffer, 100/**/, PERF_TYPE_TRACEPOINT, schedSwitchId, 1, PERF_SAMPLE_RAW, PERF_GROUP_MMAP | PERF_GROUP_COMM | PERF_GROUP_TASK | PERF_GROUP_SAMPLE_ID_ALL) | 89 | || !mCountersGroup.add(&mBuffer, 100/**/, PERF_TYPE_TRACEPOINT, schedSwitchId, 1, PERF_SAMPLE_RAW, PERF_GROUP_MMAP | PERF_GROUP_COMM | PERF_GROUP_TASK | PERF_GROUP_SAMPLE_ID_ALL | PERF_GROUP_PER_CPU) |
87 | 90 | ||
88 | // Only want TID and IP but not RAW on timer | 91 | // Only want TID and IP but not RAW on timer |
89 | || (gSessionData->mSampleRate > 0 && !gSessionData->mIsEBS && !mCountersGroup.add(&mBuffer, 99/**/, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, 1000000000UL / gSessionData->mSampleRate, PERF_SAMPLE_TID | PERF_SAMPLE_IP, 0)) | 92 | || (gSessionData->mSampleRate > 0 && !gSessionData->mIsEBS && !mCountersGroup.add(&mBuffer, 99/**/, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_CLOCK, 1000000000UL / gSessionData->mSampleRate, PERF_SAMPLE_TID | PERF_SAMPLE_IP, PERF_GROUP_PER_CPU)) |
90 | 93 | ||
91 | || !gSessionData->perf.enable(&mCountersGroup, &mBuffer) | 94 | || !gSessionData->perf.enable(&mCountersGroup, &mBuffer) |
92 | || 0) { | 95 | || 0) { |
93 | logg->logMessage("%s(%s:%i): perf setup failed, are you running Linux 3.12 or later?", __FUNCTION__, __FILE__, __LINE__); | 96 | logg->logMessage("%s(%s:%i): perf setup failed, are you running Linux 3.4 or later?", __FUNCTION__, __FILE__, __LINE__); |
94 | return false; | 97 | return false; |
95 | } | 98 | } |
96 | 99 | ||
@@ -134,7 +137,7 @@ bool PerfSource::prepare() { | |||
134 | return false; | 137 | return false; |
135 | } | 138 | } |
136 | 139 | ||
137 | if (!readProc(&mBuffer, &printb, &b1, &b2, &b3)) { | 140 | if (!readProc(&mBuffer, true, &printb, &b1, &b2, &b3)) { |
138 | logg->logMessage("%s(%s:%i): readProc failed", __FUNCTION__, __FILE__, __LINE__); | 141 | logg->logMessage("%s(%s:%i): readProc failed", __FUNCTION__, __FILE__, __LINE__); |
139 | return false; | 142 | return false; |
140 | } | 143 | } |
@@ -260,6 +263,7 @@ bool PerfSource::isDone () { | |||
260 | void PerfSource::write (Sender *sender) { | 263 | void PerfSource::write (Sender *sender) { |
261 | if (!mSummary.isDone()) { | 264 | if (!mSummary.isDone()) { |
262 | mSummary.write(sender); | 265 | mSummary.write(sender); |
266 | gSessionData->mSentSummary = true; | ||
263 | } | 267 | } |
264 | if (!mBuffer.isDone()) { | 268 | if (!mBuffer.isDone()) { |
265 | mBuffer.write(sender); | 269 | mBuffer.write(sender); |