summaryrefslogtreecommitdiff
path: root/simpleperf/event_selection_set.h
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-08-26 18:25:21 -0700
committerYabin Cui <yabinc@google.com>2016-08-26 18:44:31 -0700
commit825e56be3a1c5310969aaa3e10a7cd1f63455189 (patch)
tree7181f34ddeba5fa307af8335e6067adb65c9ae70 /simpleperf/event_selection_set.h
parentb5a1a4a7728250a6f77ec00d00df29c68985fbdd (diff)
downloadextras-825e56be3a1c5310969aaa3e10a7cd1f63455189.tar.gz
simpleperf: support hotplug events in record cmd.
1. When a cpu is down, read records from event files on that cpu, then close those event files. 2. When a cpu is up, open event files on that cpu, and create mapped buffer for those event files to dump records. 3. Instead of creating a mapped buffer for each event type on each cpu, we can just create a mapped buffer for all event types on each cpu. 4. When new event files are created, store a EventIdRecord record in perf.data to notify record_file_reader.cpp. Bug: http://b/29245608 Test: run simpleperf record cmd and make cpu offline and online. Test: run simpleperf_unit_test. Change-Id: Ib97a24b6292fa143e9b35cb105bdddf1e826d60a
Diffstat (limited to 'simpleperf/event_selection_set.h')
-rw-r--r--simpleperf/event_selection_set.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/simpleperf/event_selection_set.h b/simpleperf/event_selection_set.h
index 12ed510a..5a2dea4e 100644
--- a/simpleperf/event_selection_set.h
+++ b/simpleperf/event_selection_set.h
@@ -76,7 +76,8 @@ class IOEventLoop;
class EventSelectionSet {
public:
- EventSelectionSet(bool for_stat_cmd) : for_stat_cmd_(for_stat_cmd) {}
+ EventSelectionSet(bool for_stat_cmd)
+ : for_stat_cmd_(for_stat_cmd), mmap_pages_(0), loop_(nullptr) {}
bool empty() const { return groups_.empty(); }
@@ -118,17 +119,20 @@ class EventSelectionSet {
bool OpenEventFiles(const std::vector<pid_t>& threads,
const std::vector<int>& cpus);
bool MmapEventFiles(size_t mmap_pages, bool report_error);
- bool ReadMmapEventDataForFd(std::unique_ptr<EventFd>& event_fd);
+ bool ReadMmapEventDataForFd(EventFd* event_fd);
bool DetectCpuHotplugEvents();
bool HandleCpuOnlineEvent(int cpu);
bool HandleCpuOfflineEvent(int cpu);
+ bool CreateMappedBufferForCpu(int cpu);
const bool for_stat_cmd_;
std::vector<EventSelectionGroup> groups_;
std::vector<pid_t> threads_;
+ size_t mmap_pages_;
+ IOEventLoop* loop_;
std::function<bool(Record*)> record_callback_;
std::set<int> monitored_cpus_;