diff options
author | Yabin Cui <yabinc@google.com> | 2016-08-19 17:24:37 -0700 |
---|---|---|
committer | Yabin Cui <yabinc@google.com> | 2016-08-19 17:32:10 -0700 |
commit | 994cb626a9b0ad6cb723a9dfa7c5e05849647c87 (patch) | |
tree | 29d9f84cc135da3194ec3d244b64d1803c51ca83 /simpleperf/event_selection_set.h | |
parent | cb0112fe640d7b8a9668f91d2cad7234bd63f880 (diff) | |
download | extras-994cb626a9b0ad6cb723a9dfa7c5e05849647c87.tar.gz |
simpleperf: monitor cpu hotplug in stat cmd.
Move code used to monitor cpu hotplug events
from cmd_record.cpp to event_selection_set.cpp,
so it can also be used by stat cmd.
Bug: http://b/29245608
Change-Id: I1f5f3268192aa5c98c0be9fc1de763352c08eab6
Test: run simpleperf stat, and online/offline a cpu.
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r-- | simpleperf/event_selection_set.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h index a947320f..c24dad4c 100644 --- a/simpleperf/event_selection_set.h +++ b/simpleperf/event_selection_set.h @@ -19,6 +19,7 @@ #include <functional> #include <map> +#include <set> #include <unordered_map> #include <vector> @@ -29,6 +30,8 @@ #include "perf_event.h" #include "record.h" +constexpr double DEFAULT_PERIOD_TO_DETECT_CPU_HOTPLUG_EVENTS_IN_SEC = 0.5; + struct EventSelection { uint32_t group_id; uint32_t selection_id; @@ -96,6 +99,12 @@ class EventSelectionSet { const std::function<bool(Record*)>& callback); bool FinishReadMmapEventData(); + // If monitored_cpus is empty, monitor all cpus. + bool HandleCpuHotplugEvents( + IOEventLoop& loop, const std::vector<int>& monitored_cpus, + double check_interval_in_sec = + DEFAULT_PERIOD_TO_DETECT_CPU_HOTPLUG_EVENTS_IN_SEC); + private: bool BuildAndCheckEventSelection(const std::string& event_name, EventSelection* selection); @@ -105,10 +114,15 @@ class EventSelectionSet { bool MmapEventFiles(size_t mmap_pages, bool report_error); bool ReadMmapEventDataForFd(std::unique_ptr<EventFd>& event_fd); + bool DetectCpuHotplugEvents(); + std::vector<EventSelectionGroup> groups_; std::function<bool(Record*)> record_callback_; + std::set<int> monitored_cpus_; + std::vector<int> online_cpus_; + DISALLOW_COPY_AND_ASSIGN(EventSelectionSet); }; |