diff options
author | Yabin Cui <yabinc@google.com> | 2016-08-24 19:32:55 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-08-25 15:42:25 -0700 |
commit | 778424b18ee1d9b9e789eb3de2dfc532fa499a55 (patch) | |
tree | 6fb1a1c77a55069a876dd4f0d11640c6a46b6b25 /simpleperf/event_selection_set.h | |
parent | a903cc9b9ce63b281e42a9c019f8d9873f00877f (diff) | |
download | extras-778424b18ee1d9b9e789eb3de2dfc532fa499a55.tar.gz |
simpleperf: support hotplug events in stat cmd.
1. When a cpu is down, read counters from event files on that cpu,
then close those events files.
2. When a cpu is up, open event files on that cpu.
3. Remove check of time_running != 0 in cmd_stat.cpp, because
1) We no longer need the check as we no longer open event file
for each cpu for non system wide profiling.
2) The kernel has a bug that can make time_running == 0 if
a cpu is down while profiling. But the counter value is
still valid, and shouldn't be ignored.
Bug: http://b/29245608
Test: run simpleperf and make cpu offline and online.
Change-Id: I3e7bec139c5f50bea1311c95bb154a5b290a72ea
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r-- | simpleperf/event_selection_set.h | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index 6fb02b81..12ed510a 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -32,24 +32,30 @@ constexpr double DEFAULT_PERIOD_TO_DETECT_CPU_HOTPLUG_EVENTS_IN_SEC = 0.5; +struct CounterInfo { + pid_t tid; + int cpu; + PerfCounter counter; +}; + +struct EventSelection; + +struct CountersInfo { + const EventSelection* selection; + std::vector<CounterInfo> counters; +}; + 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; + // counters for event files closed for cpu hotplug events + std::vector<CounterInfo> hotplugged_counters; }; -typedef std::vector<EventSelection> EventSelectionGroup; -struct CountersInfo { - const EventSelection* selection; - struct CounterInfo { - pid_t tid; - int cpu; - PerfCounter counter; - }; - std::vector<CounterInfo> counters; -}; +typedef std::vector<EventSelection> EventSelectionGroup; class IOEventLoop; @@ -115,10 +121,13 @@ class EventSelectionSet { bool ReadMmapEventDataForFd(std::unique_ptr<EventFd>& event_fd); bool DetectCpuHotplugEvents(); + bool HandleCpuOnlineEvent(int cpu); + bool HandleCpuOfflineEvent(int cpu); const bool for_stat_cmd_; std::vector<EventSelectionGroup> groups_; + std::vector<pid_t> threads_; std::function<bool(Record*)> record_callback_; |