perf: check if perf is actually active when counting it
@@ -329,7 +329,8 @@ void arch_perfAnalyze(run_t* run) {
}
uint64_t instrCount = 0;
- if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
+ if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) &&
+ run->linux.cpuInstrFd != -1) {
ioctl(run->linux.cpuInstrFd, PERF_EVENT_IOC_DISABLE, 0);
if (files_readFromFd(run->linux.cpuInstrFd, (uint8_t*)&instrCount, sizeof(instrCount)) !=
sizeof(instrCount)) {
@@ -339,7 +340,8 @@ void arch_perfAnalyze(run_t* run) {
}
uint64_t branchCount = 0;
- if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
+ if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) &&
+ run->linux.cpuBranchFd != -1) {
ioctl(run->linux.cpuBranchFd, PERF_EVENT_IOC_DISABLE, 0);
if (files_readFromFd(run->linux.cpuBranchFd, (uint8_t*)&branchCount, sizeof(branchCount)) !=
sizeof(branchCount)) {
@@ -348,13 +350,15 @@ void arch_perfAnalyze(run_t* run) {
ioctl(run->linux.cpuBranchFd, PERF_EVENT_IOC_RESET, 0);
}
- if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
+ if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) &&
+ run->linux.cpuIptBtsFd != -1) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0);
arch_perfMmapParse(run);
arch_perfMmapReset(run);
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_RESET, 0);
}
- if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
+ if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) &&
+ run->linux.cpuIptBtsFd != -1) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0);
arch_perfMmapParse(run);
arch_perfMmapReset(run);
