summaryrefslogtreecommitdiff
path: root/simpleperf/event_selection_set.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'simpleperf/event_selection_set.cpp')
-rw-r--r--simpleperf/event_selection_set.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp
index 6235e32b..d6961e5a 100644
--- a/simpleperf/event_selection_set.cpp
+++ b/simpleperf/event_selection_set.cpp
@@ -24,6 +24,7 @@
#include "event_type.h"
#include "IOEventLoop.h"
#include "perf_regs.h"
+#include "utils.h"
bool IsBranchSamplingSupported() {
const EventType* type = FindEventTypeByName("cpu-cycles");
@@ -56,6 +57,17 @@ bool EventSelectionSet::BuildAndCheckEventSelection(
if (event_type == nullptr) {
return false;
}
+ if (for_stat_cmd_) {
+ if (event_type->event_type.name == "cpu-clock" ||
+ event_type->event_type.name == "task-clock") {
+ if (event_type->exclude_user || event_type->exclude_kernel) {
+ LOG(ERROR) << "Modifier u and modifier k used in event type "
+ << event_type->event_type.name
+ << " are not supported by the kernel.";
+ return false;
+ }
+ }
+ }
selection->event_type_modifier = *event_type;
selection->event_attr = CreateDefaultPerfEventAttr(event_type->event_type);
selection->event_attr.exclude_user = event_type->exclude_user;
@@ -439,3 +451,38 @@ bool EventSelectionSet::FinishReadMmapEventData() {
}
return true;
}
+
+bool EventSelectionSet::HandleCpuHotplugEvents(
+ IOEventLoop& loop, const std::vector<int>& monitored_cpus,
+ double check_interval_in_sec) {
+ monitored_cpus_.insert(monitored_cpus.begin(), monitored_cpus.end());
+ online_cpus_ = GetOnlineCpus();
+ if (!loop.AddPeriodicEvent(SecondToTimeval(check_interval_in_sec),
+ [&]() { return DetectCpuHotplugEvents(); })) {
+ return false;
+ }
+ return true;
+}
+
+bool EventSelectionSet::DetectCpuHotplugEvents() {
+ std::vector<int> new_cpus = GetOnlineCpus();
+ for (const auto& cpu : online_cpus_) {
+ if (std::find(new_cpus.begin(), new_cpus.end(), cpu) == new_cpus.end()) {
+ if (monitored_cpus_.empty() ||
+ monitored_cpus_.find(cpu) != monitored_cpus_.end()) {
+ LOG(INFO) << "Cpu " << cpu << " is offlined";
+ }
+ }
+ }
+ for (const auto& cpu : new_cpus) {
+ if (std::find(online_cpus_.begin(), online_cpus_.end(), cpu) ==
+ online_cpus_.end()) {
+ if (monitored_cpus_.empty() ||
+ monitored_cpus_.find(cpu) != monitored_cpus_.end()) {
+ LOG(INFO) << "Cpu " << cpu << " is onlined";
+ }
+ }
+ }
+ online_cpus_ = new_cpus;
+ return true;
+}