diff options
author | Yabin Cui <yabinc@google.com> | 2021-05-03 14:06:03 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2021-05-03 14:32:51 -0700 |
commit | 6a273b37e2997d9365cbcd1c75d0d281a469fd12 (patch) | |
tree | 468f03ff48f879d98d49320a7deab341dc55088a /simpleperf | |
parent | ac2e71ce6971ad3b61bcafb8d0c598fc5f94d043 (diff) | |
download | extras-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')
-rw-r--r-- | simpleperf/ETMRecorder.cpp | 9 |
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() { |