summaryrefslogtreecommitdiff
path: root/simpleperf
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2024-05-08 10:34:49 -0700
committerYabin Cui <yabinc@google.com>2024-05-08 11:15:48 -0700
commit9e247e80ae9346fe827822293e025246ac62c497 (patch)
tree3716bbca2dc32951570d8de6f391b5674825fc0b /simpleperf
parentb89b1ef923929d2ada9770b4360e04c41c2670bd (diff)
downloadextras-9e247e80ae9346fe827822293e025246ac62c497.tar.gz
simpleperf: Rotate the last cpu disabling ETM events
When using ETR, ETM data is flushed to the aux buffer of the last cpu disabling ETM events. To avoid overflowing the aux buffer for one cpu, rotate the last cpu disabling ETM events. Bug: 336375740 Test: run simpleperf manually Change-Id: I1b5f2b85935513a3485d84fe0b850b8223ad03b4
Diffstat (limited to 'simpleperf')
-rw-r--r--simpleperf/event_selection_set.cpp29
-rw-r--r--simpleperf/event_selection_set.h3
2 files changed, 30 insertions, 2 deletions
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp
index 6a1e5a9e..1a7cdef8 100644
--- a/simpleperf/event_selection_set.cpp
+++ b/simpleperf/event_selection_set.cpp
@@ -974,9 +974,34 @@ bool EventSelectionSet::DisableETMEvents() {
if (!sel.event_type_modifier.event_type.IsEtmEvent()) {
continue;
}
+ // When using ETR, ETM data is flushed to the aux buffer of the last cpu disabling ETM events.
+ // To avoid overflowing the aux buffer for one cpu, rotate the last cpu disabling ETM events.
+ if (etm_event_cpus_.empty()) {
+ for (const auto& fd : sel.event_fds) {
+ etm_event_cpus_.insert(fd->Cpu());
+ }
+ if (etm_event_cpus_.empty()) {
+ continue;
+ }
+ etm_event_cpus_it_ = etm_event_cpus_.begin();
+ }
+ int last_disabled_cpu = *etm_event_cpus_it_;
+ if (++etm_event_cpus_it_ == etm_event_cpus_.end()) {
+ etm_event_cpus_it_ = etm_event_cpus_.begin();
+ }
+
for (auto& fd : sel.event_fds) {
- if (!fd->SetEnableEvent(false)) {
- return false;
+ if (fd->Cpu() != last_disabled_cpu) {
+ if (!fd->SetEnableEvent(false)) {
+ return false;
+ }
+ }
+ }
+ for (auto& fd : sel.event_fds) {
+ if (fd->Cpu() == last_disabled_cpu) {
+ if (!fd->SetEnableEvent(false)) {
+ return false;
+ }
}
}
}
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h
index 1b3d6b4e..a892d51e 100644
--- a/simpleperf/event_selection_set.h
+++ b/simpleperf/event_selection_set.h
@@ -235,6 +235,9 @@ class EventSelectionSet {
std::optional<SampleRate> sample_rate_;
std::optional<std::vector<int>> cpus_;
+ std::set<int> etm_event_cpus_;
+ std::set<int>::const_iterator etm_event_cpus_it_;
+
DISALLOW_COPY_AND_ASSIGN(EventSelectionSet);
};