summaryrefslogtreecommitdiff
path: root/simpleperf/event_selection_set.h
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-06-13 18:03:47 -0700
committerYabin Cui <yabinc@google.com>2016-06-17 17:57:36 -0700
commit877751bbae11e009070e036ee1cd16e88135fff5 (patch)
treee0c795052ab4055a2d9bb0d2d2282305ff3b649d /simpleperf/event_selection_set.h
parent90d56472a6981cbbeba5adfc293f920004cd9a22 (diff)
downloadextras-877751bbae11e009070e036ee1cd16e88135fff5.tar.gz
simpleperf: support event group.
Kernel supports monitoring several events as a group, so they are scheduled on and out at the same time. Add --group option to stat command and record command. Adjust the method to calculate miss rate in stat command: limit the matched events in the same group or with scale == 1.0. Bug: 29213742 Change-Id: I899aba207f1e3357307541e81f97526f5a2913c3
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r--simpleperf/event_selection_set.h41
1 files changed, 23 insertions, 18 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h
index 3cfdb46b..d393a3b8 100644
--- a/simpleperf/event_selection_set.h
+++ b/simpleperf/event_selection_set.h
@@ -29,8 +29,17 @@
#include "perf_event.h"
#include "record.h"
+struct EventSelection {
+ uint32_t group_id;
+ uint32_t selection_id;
+ EventTypeAndModifier event_type_modifier;
+ perf_event_attr event_attr;
+ std::vector<std::unique_ptr<EventFd>> event_fds;
+};
+typedef std::vector<EventSelection> EventSelectionGroup;
+
struct CountersInfo {
- const EventTypeAndModifier* event_type;
+ const EventSelection* selection;
struct CounterInfo {
pid_t tid;
int cpu;
@@ -55,17 +64,22 @@ class EventSelectionSet {
EventSelectionSet() {
}
- bool Empty() const {
- return selections_.empty();
+ bool empty() const {
+ return groups_.empty();
+ }
+
+ const std::vector<EventSelectionGroup>& groups() {
+ return groups_;
}
- bool AddEventType(const EventTypeAndModifier& event_type_modifier);
+ bool AddEventType(const std::string& event_name);
+ bool AddEventGroup(const std::vector<std::string>& event_names);
void SetEnableOnExec(bool enable);
bool GetEnableOnExec();
void SampleIdAll();
- void SetSampleFreq(const EventTypeAndModifier& event_type_modifier, uint64_t sample_freq);
- void SetSamplePeriod(const EventTypeAndModifier& event_type_modifier, uint64_t sample_period);
+ void SetSampleFreq(const EventSelection& selection, uint64_t sample_freq);
+ void SetSamplePeriod(const EventSelection& selection, uint64_t sample_period);
bool SetBranchSampling(uint64_t branch_sample_type);
void EnableFpCallChainSampling();
bool EnableDwarfCallChainSampling(uint32_t dump_stack_size);
@@ -80,24 +94,15 @@ class EventSelectionSet {
bool ReadMmapEventData();
bool FinishReadMmapEventData();
- const perf_event_attr* FindEventAttrByType(const EventTypeAndModifier& event_type_modifier);
- const std::vector<std::unique_ptr<EventFd>>* FindEventFdsByType(
- const EventTypeAndModifier& event_type_modifier);
-
private:
+ bool BuildAndCheckEventSelection(const std::string& event_name,
+ EventSelection* selection);
void UnionSampleType();
bool OpenEventFiles(const std::vector<pid_t>& threads, const std::vector<int>& cpus);
bool ReadMmapEventDataForFd(std::unique_ptr<EventFd>& event_fd, const perf_event_attr& attr,
bool* has_data);
- struct EventSelection {
- EventTypeAndModifier event_type_modifier;
- perf_event_attr event_attr;
- std::vector<std::unique_ptr<EventFd>> event_fds;
- };
- EventSelection* FindSelectionByType(const EventTypeAndModifier& event_type_modifier);
-
- std::vector<EventSelection> selections_;
+ std::vector<EventSelectionGroup> groups_;
std::function<bool (Record*)> record_callback_;
std::unique_ptr<RecordCache> record_cache_;