OSDN Git Service

simpleperf: don't adjust frequency for etm recording.
authorYabin Cui <yabinc@google.com>
Mon, 21 Oct 2019 18:26:06 +0000 (11:26 -0700)
committerYabin Cui <yabinc@google.com>
Mon, 21 Oct 2019 21:56:47 +0000 (14:56 -0700)
Bug: none
Test: run simpleperf_unit_test.

Change-Id: I401bcc72492b8a751c4a06f37026ef93d0af74c0

simpleperf/cmd_record_test.cpp
simpleperf/event_selection_set.cpp

index 82f494f..701c9cc 100644 (file)
@@ -894,6 +894,13 @@ TEST(record_cmd, cs_etm_event) {
   ASSERT_TRUE(RunRecordCmd({"-e", "cs-etm"}, tmpfile.path));
   std::unique_ptr<RecordFileReader> reader = RecordFileReader::CreateInstance(tmpfile.path);
   ASSERT_TRUE(reader);
+
+  // cs-etm uses sample period instead of sample freq.
+  ASSERT_EQ(reader->AttrSection().size(), 1u);
+  const perf_event_attr* attr = reader->AttrSection()[0].attr;
+  ASSERT_EQ(attr->freq, 0);
+  ASSERT_EQ(attr->sample_period, 1);
+
   bool has_auxtrace_info = false;
   bool has_auxtrace = false;
   bool has_aux = false;
index e1cba8c..c7c7a38 100644 (file)
@@ -174,6 +174,11 @@ bool EventSelectionSet::BuildAndCheckEventSelection(const std::string& event_nam
     if (event_type->event_type.type == PERF_TYPE_TRACEPOINT) {
       selection->event_attr.freq = 0;
       selection->event_attr.sample_period = DEFAULT_SAMPLE_PERIOD_FOR_TRACEPOINT_EVENT;
+    } else if (IsEtmEventType(event_type->event_type.type)) {
+      // ETM recording has no sample frequency to adjust. Using sample frequency only wastes time
+      // enabling/disabling etm devices. So don't adjust frequency by default.
+      selection->event_attr.freq = 0;
+      selection->event_attr.sample_period = 1;
     } else {
       selection->event_attr.freq = 1;
       // Set default sample freq here may print msg "Adjust sample freq to max allowed sample