diff options
Diffstat (limited to 'daemon/PerfGroup.cpp')
-rw-r--r-- | daemon/PerfGroup.cpp | 28 |
1 files changed, 4 insertions, 24 deletions
diff --git a/daemon/PerfGroup.cpp b/daemon/PerfGroup.cpp index 2a0239f..faf5fca 100644 --- a/daemon/PerfGroup.cpp +++ b/daemon/PerfGroup.cpp | |||
@@ -23,9 +23,7 @@ | |||
23 | #define DEFAULT_PEA_ARGS(pea, additionalSampleType) \ | 23 | #define DEFAULT_PEA_ARGS(pea, additionalSampleType) \ |
24 | pea.size = sizeof(pea); \ | 24 | pea.size = sizeof(pea); \ |
25 | /* Emit time, read_format below, group leader id, and raw tracepoint info */ \ | 25 | /* Emit time, read_format below, group leader id, and raw tracepoint info */ \ |
26 | pea.sample_type = (gSessionData->perf.getLegacySupport() \ | 26 | pea.sample_type = PERF_SAMPLE_TIME | PERF_SAMPLE_READ | PERF_SAMPLE_IDENTIFIER | additionalSampleType; \ |
27 | ? PERF_SAMPLE_TID | PERF_SAMPLE_IP | PERF_SAMPLE_TIME | PERF_SAMPLE_READ | PERF_SAMPLE_ID \ | ||
28 | : PERF_SAMPLE_TIME | PERF_SAMPLE_READ | PERF_SAMPLE_IDENTIFIER ) | additionalSampleType; \ | ||
29 | /* Emit emit value in group format */ \ | 27 | /* Emit emit value in group format */ \ |
30 | pea.read_format = PERF_FORMAT_ID | PERF_FORMAT_GROUP; \ | 28 | pea.read_format = PERF_FORMAT_ID | PERF_FORMAT_GROUP; \ |
31 | /* start out disabled */ \ | 29 | /* start out disabled */ \ |
@@ -41,7 +39,6 @@ static int sys_perf_event_open(struct perf_event_attr *const attr, const pid_t p | |||
41 | 39 | ||
42 | PerfGroup::PerfGroup(PerfBuffer *const pb) : mPb(pb) { | 40 | PerfGroup::PerfGroup(PerfBuffer *const pb) : mPb(pb) { |
43 | memset(&mAttrs, 0, sizeof(mAttrs)); | 41 | memset(&mAttrs, 0, sizeof(mAttrs)); |
44 | memset(&mPerCpu, 0, sizeof(mPerCpu)); | ||
45 | memset(&mKeys, -1, sizeof(mKeys)); | 42 | memset(&mKeys, -1, sizeof(mKeys)); |
46 | memset(&mFds, -1, sizeof(mFds)); | 43 | memset(&mFds, -1, sizeof(mFds)); |
47 | } | 44 | } |
@@ -78,7 +75,6 @@ bool PerfGroup::add(Buffer *const buffer, const int key, const __u32 type, const | |||
78 | mAttrs[i].freq = (flags & PERF_GROUP_FREQ ? 1 : 0); | 75 | mAttrs[i].freq = (flags & PERF_GROUP_FREQ ? 1 : 0); |
79 | mAttrs[i].task = (flags & PERF_GROUP_TASK ? 1 : 0); | 76 | mAttrs[i].task = (flags & PERF_GROUP_TASK ? 1 : 0); |
80 | mAttrs[i].sample_id_all = (flags & PERF_GROUP_SAMPLE_ID_ALL ? 1 : 0); | 77 | mAttrs[i].sample_id_all = (flags & PERF_GROUP_SAMPLE_ID_ALL ? 1 : 0); |
81 | mPerCpu[i] = (flags & PERF_GROUP_PER_CPU); | ||
82 | 78 | ||
83 | mKeys[i] = key; | 79 | mKeys[i] = key; |
84 | 80 | ||
@@ -95,17 +91,13 @@ bool PerfGroup::prepareCPU(const int cpu) { | |||
95 | continue; | 91 | continue; |
96 | } | 92 | } |
97 | 93 | ||
98 | if ((cpu != 0) && !mPerCpu[i]) { | ||
99 | continue; | ||
100 | } | ||
101 | |||
102 | const int offset = i * gSessionData->mCores; | 94 | const int offset = i * gSessionData->mCores; |
103 | if (mFds[cpu + offset] >= 0) { | 95 | if (mFds[cpu + offset] >= 0) { |
104 | logg->logMessage("%s(%s:%i): cpu already online or not correctly cleaned up", __FUNCTION__, __FILE__, __LINE__); | 96 | logg->logMessage("%s(%s:%i): cpu already online or not correctly cleaned up", __FUNCTION__, __FILE__, __LINE__); |
105 | return false; | 97 | return false; |
106 | } | 98 | } |
107 | 99 | ||
108 | logg->logMessage("%s(%s:%i): perf_event_open cpu: %i type: %lli config: %lli sample: %lli sample_type: 0x%llx pinned: %i mmap: %i comm: %i freq: %i task: %i sample_id_all: %i", __FUNCTION__, __FILE__, __LINE__, cpu, (long long)mAttrs[i].type, (long long)mAttrs[i].config, (long long)mAttrs[i].sample_period, (long long)mAttrs[i].sample_type, mAttrs[i].pinned, mAttrs[i].mmap, mAttrs[i].comm, mAttrs[i].freq, mAttrs[i].task, mAttrs[i].sample_id_all); | 100 | logg->logMessage("%s(%s:%i): perf_event_open cpu: %i type: %lli config: %lli sample: %lli sample_type: %lli", __FUNCTION__, __FILE__, __LINE__, cpu, (long long)mAttrs[i].type, (long long)mAttrs[i].config, (long long)mAttrs[i].sample_period, (long long)mAttrs[i].sample_type); |
109 | mFds[cpu + offset] = sys_perf_event_open(&mAttrs[i], -1, cpu, i == 0 ? -1 : mFds[cpu], i == 0 ? 0 : PERF_FLAG_FD_OUTPUT); | 101 | mFds[cpu + offset] = sys_perf_event_open(&mAttrs[i], -1, cpu, i == 0 ? -1 : mFds[cpu], i == 0 ? 0 : PERF_FLAG_FD_OUTPUT); |
110 | if (mFds[cpu + offset] < 0) { | 102 | if (mFds[cpu + offset] < 0) { |
111 | logg->logMessage("%s(%s:%i): failed %s", __FUNCTION__, __FILE__, __LINE__, strerror(errno)); | 103 | logg->logMessage("%s(%s:%i): failed %s", __FUNCTION__, __FILE__, __LINE__, strerror(errno)); |
@@ -133,9 +125,7 @@ int PerfGroup::onlineCPU(const int cpu, const bool start, Buffer *const buffer, | |||
133 | } | 125 | } |
134 | 126 | ||
135 | coreKeys[idCount] = mKeys[i]; | 127 | coreKeys[idCount] = mKeys[i]; |
136 | if (!gSessionData->perf.getLegacySupport() && ioctl(fd, PERF_EVENT_IOC_ID, &ids[idCount]) != 0 && | 128 | if (ioctl(fd, PERF_EVENT_IOC_ID, &ids[idCount]) != 0) { |
137 | // Workaround for running 32-bit gatord on 64-bit systems, kernel patch in the works | ||
138 | ioctl(fd, (PERF_EVENT_IOC_ID & ~IOCSIZE_MASK) | (8 << _IOC_SIZESHIFT), &ids[idCount]) != 0) { | ||
139 | logg->logMessage("%s(%s:%i): ioctl failed", __FUNCTION__, __FILE__, __LINE__); | 129 | logg->logMessage("%s(%s:%i): ioctl failed", __FUNCTION__, __FILE__, __LINE__); |
140 | return false; | 130 | return false; |
141 | } | 131 | } |
@@ -147,17 +137,7 @@ int PerfGroup::onlineCPU(const int cpu, const bool start, Buffer *const buffer, | |||
147 | return false; | 137 | return false; |
148 | } | 138 | } |
149 | 139 | ||
150 | if (!gSessionData->perf.getLegacySupport()) { | 140 | buffer->keys(idCount, ids, coreKeys); |
151 | buffer->keys(idCount, ids, coreKeys); | ||
152 | } else { | ||
153 | char buf[1024]; | ||
154 | ssize_t bytes = read(mFds[cpu], buf, sizeof(buf)); | ||
155 | if (bytes < 0) { | ||
156 | logg->logMessage("read failed"); | ||
157 | return false; | ||
158 | } | ||
159 | buffer->keysOld(idCount, coreKeys, bytes, buf); | ||
160 | } | ||
161 | 141 | ||
162 | if (start) { | 142 | if (start) { |
163 | for (int i = 0; i < ARRAY_LENGTH(mKeys); ++i) { | 143 | for (int i = 0; i < ARRAY_LENGTH(mKeys); ++i) { |