[13/20] perf stat: Reset aggr counts for each interval
Commit Message
The evsel->stats->aggr->count should be reset for interval processing
since we want to use the values directly for display.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/builtin-stat.c | 3 +++
tools/perf/util/stat.c | 20 +++++++++++++++++---
tools/perf/util/stat.h | 1 +
3 files changed, 21 insertions(+), 3 deletions(-)
@@ -492,6 +492,8 @@ static void process_interval(void)
diff_timespec(&rs, &ts, &ref_time);
perf_stat__reset_shadow_per_stat(&rt_stat);
+ evlist__reset_aggr_stats(evsel_list);
+
read_counters(&rs);
if (STAT_RECORD) {
@@ -965,6 +967,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
evlist__copy_prev_raw_counts(evsel_list);
evlist__reset_prev_raw_counts(evsel_list);
+ evlist__reset_aggr_stats(evsel_list);
perf_stat__reset_shadow_per_stat(&rt_stat);
} else {
update_stats(&walltime_nsecs_stats, t1 - t0);
@@ -130,17 +130,23 @@ static void perf_stat_evsel_id_init(struct evsel *evsel)
}
}
-static void evsel__reset_stat_priv(struct evsel *evsel)
+static void evsel__reset_aggr_stats(struct evsel *evsel)
{
struct perf_stat_evsel *ps = evsel->stats;
struct perf_stat_aggr *aggr = ps->aggr;
- init_stats(&ps->res_stats);
-
if (aggr)
memset(aggr, 0, sizeof(*aggr) * ps->nr_aggr);
}
+static void evsel__reset_stat_priv(struct evsel *evsel)
+{
+ struct perf_stat_evsel *ps = evsel->stats;
+
+ init_stats(&ps->res_stats);
+ evsel__reset_aggr_stats(evsel);
+}
+
static int evsel__alloc_aggr_stats(struct evsel *evsel, int nr_aggr)
{
struct perf_stat_evsel *ps = evsel->stats;
@@ -276,6 +282,14 @@ void evlist__reset_stats(struct evlist *evlist)
}
}
+void evlist__reset_aggr_stats(struct evlist *evlist)
+{
+ struct evsel *evsel;
+
+ evlist__for_each_entry(evlist, evsel)
+ evsel__reset_aggr_stats(evsel);
+}
+
void evlist__reset_prev_raw_counts(struct evlist *evlist)
{
struct evsel *evsel;
@@ -276,6 +276,7 @@ void evlist__copy_prev_raw_counts(struct evlist *evlist);
void evlist__save_aggr_prev_raw_counts(struct evlist *evlist);
int evlist__alloc_aggr_stats(struct evlist *evlist, int nr_aggr);
+void evlist__reset_aggr_stats(struct evlist *evlist);
int perf_stat_process_counter(struct perf_stat_config *config,
struct evsel *counter);