summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_stat.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-08-24 19:32:55 -0700
committerYabin Cui <yabinc@google.com>2016-08-25 15:42:25 -0700
commit778424b18ee1d9b9e789eb3de2dfc532fa499a55 (patch)
tree6fb1a1c77a55069a876dd4f0d11640c6a46b6b25 /simpleperf/cmd_stat.cpp
parenta903cc9b9ce63b281e42a9c019f8d9873f00877f (diff)
downloadextras-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/cmd_stat.cpp')
-rw-r--r--simpleperf/cmd_stat.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/simpleperf/cmd_stat.cpp b/simpleperf/cmd_stat.cpp
index 76df147f..728deb2e 100644
--- a/simpleperf/cmd_stat.cpp
+++ b/simpleperf/cmd_stat.cpp
@@ -572,13 +572,9 @@ bool StatCommand::ShowCounters(const std::vector<CountersInfo>& counters,
uint64_t time_enabled_sum = 0;
uint64_t time_running_sum = 0;
for (auto& counter_info : counters_info.counters) {
- // If time_running is 0, the program has never run on this event and we
- // shouldn't summarize it.
- if (counter_info.counter.time_running != 0) {
- value_sum += counter_info.counter.value;
- time_enabled_sum += counter_info.counter.time_enabled;
- time_running_sum += counter_info.counter.time_running;
- }
+ value_sum += counter_info.counter.value;
+ time_enabled_sum += counter_info.counter.time_enabled;
+ time_running_sum += counter_info.counter.time_running;
}
double scale = 1.0;
if (time_running_sum < time_enabled_sum && time_running_sum != 0) {