Commit 17c0009f authored by Michael Ott's avatar Michael Ott
Browse files

Re-adding the check for errors when opening file descriptors for additional...

Re-adding the check for errors when opening file descriptors for additional sensors in a group and obtaining IDs. This time properly.
parent 66663604
......@@ -97,9 +97,18 @@ void PerfSensorGroup::start() {
fd = syscall(__NR_perf_event_open, &pe, -1, _cpuId, _fd, 0);
//store id, so that we can match counters with values later (see read())
ioctl(fd, PERF_EVENT_IOC_ID, &id);
_ids.push_back(id);
LOG(debug) << " " << _groupName << "::" << pc->getName() << " opened with ID " << std::to_string(id);
if (fd != -1) {
int rc;
if ((rc = ioctl(fd, PERF_EVENT_IOC_ID, &id)) == 0) {
_ids.push_back(id);
_fds.push_back(fd);
LOG(debug) << " " << _groupName << "::" << pc->getName() << " opened with ID " << std::to_string(id);
} else {
LOG(debug) << " " << _groupName << "::" << pc->getName() << " errro obtaining ID: " << strerror(rc);
}
} else {
LOG(debug) << " " << _groupName << "::" << pc->getName() << " errro opening perf file descriptor: " << strerror(errno);
}
}
ioctl(_fd, PERF_EVENT_IOC_RESET, 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment