Skip to content

Commit 905365f

Browse files
Jin Yaoacmel
authored andcommitted
perf stat: Save aggr value to first member of prev_raw_counts
To collect the overall statistics for interval mode, we copy the counts from evsel->prev_raw_counts to evsel->counts. For AGGR_GLOBAL mode, because the perf_stat_process_counter creates aggr values from per cpu values, but the per cpu values are 0, so the calculated aggr values will be always 0. This patch uses a trick that saves the previous aggr value to the first member of perf_counts, then aggr calculation in process_counter_values can work correctly for AGGR_GLOBAL. v6: --- Add comments in perf_evlist__save_aggr_prev_raw_counts. Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Jin Yao <yao.jin@intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/20200520042737.24160-5-yao.jin@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 297767a commit 905365f

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎tools/perf/util/stat.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,26 @@ void perf_evlist__copy_prev_raw_counts(struct evlist *evlist)
249249
perf_evsel__copy_prev_raw_counts(evsel);
250250
}
251251

252+
void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist)
253+
{
254+
struct evsel *evsel;
255+
256+
/*
257+
* To collect the overall statistics for interval mode,
258+
* we copy the counts from evsel->prev_raw_counts to
259+
* evsel->counts. The perf_stat_process_counter creates
260+
* aggr values from per cpu values, but the per cpu values
261+
* are 0 for AGGR_GLOBAL. So we use a trick that saves the
262+
* previous aggr value to the first member of perf_counts,
263+
* then aggr calculation in process_counter_values can work
264+
* correctly.
265+
*/
266+
evlist__for_each_entry(evlist, evsel) {
267+
*perf_counts(evsel->prev_raw_counts, 0, 0) =
268+
evsel->prev_raw_counts->aggr;
269+
}
270+
}
271+
252272
static void zero_per_pkg(struct evsel *counter)
253273
{
254274
if (counter->per_pkg_mask)

‎tools/perf/util/stat.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void perf_evlist__free_stats(struct evlist *evlist);
199199
void perf_evlist__reset_stats(struct evlist *evlist);
200200
void perf_evlist__reset_prev_raw_counts(struct evlist *evlist);
201201
void perf_evlist__copy_prev_raw_counts(struct evlist *evlist);
202+
void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist);
202203

203204
int perf_stat_process_counter(struct perf_stat_config *config,
204205
struct evsel *counter);

0 commit comments

Comments
 (0)