summaryrefslogtreecommitdiff
path: root/simpleperf/ETMRecorder.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2021-05-03 14:06:03 -0700
committerYabin Cui <yabinc@google.com>2021-05-03 14:32:51 -0700
commit6a273b37e2997d9365cbcd1c75d0d281a469fd12 (patch)
tree468f03ff48f879d98d49320a7deab341dc55088a /simpleperf/ETMRecorder.cpp
parentac2e71ce6971ad3b61bcafb8d0c598fc5f94d043 (diff)
downloadextras-6a273b37e2997d9365cbcd1c75d0d281a469fd12.tar.gz
simpleperf: read etm info only for online cpus.
Bug: none Test: run simpleperf_unit_test. Test: run simpleperf manually. Change-Id: Ibbd5048b0b703be950ebc27864460f096fc64f07
Diffstat (limited to 'simpleperf/ETMRecorder.cpp')
-rw-r--r--simpleperf/ETMRecorder.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/simpleperf/ETMRecorder.cpp b/simpleperf/ETMRecorder.cpp
index 7c8654e3..c9119d0e 100644
--- a/simpleperf/ETMRecorder.cpp
+++ b/simpleperf/ETMRecorder.cpp
@@ -28,6 +28,7 @@
#include <android-base/parseint.h>
#include <android-base/strings.h>
+#include "environment.h"
#include "utils.h"
namespace simpleperf {
@@ -139,10 +140,14 @@ bool ETMRecorder::CheckEtmSupport() {
}
bool ETMRecorder::ReadEtmInfo() {
- int cpu_count = get_nprocs_conf();
+ std::vector<int> online_cpus = GetOnlineCpus();
for (const auto& name : GetEntriesInDir(ETM_DIR)) {
int cpu;
if (sscanf(name.c_str(), "cpu%d", &cpu) == 1) {
+ // We can't read ETM registers for offline cpus. So skip them.
+ if (std::find(online_cpus.begin(), online_cpus.end(), cpu) == online_cpus.end()) {
+ continue;
+ }
ETMPerCpu& cpu_info = etm_info_[cpu];
bool success = ReadValueInEtmDir(name + "/trcidr/trcidr0", &cpu_info.trcidr0) &&
ReadValueInEtmDir(name + "/trcidr/trcidr1", &cpu_info.trcidr1) &&
@@ -155,7 +160,7 @@ bool ETMRecorder::ReadEtmInfo() {
}
}
}
- return (etm_info_.size() == cpu_count);
+ return (etm_info_.size() == online_cpus.size());
}
bool ETMRecorder::FindSinkConfig() {