diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 2511d3aae708..b24a7a08bd1d 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -391,6 +391,8 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count) | |||
391 | static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, | 391 | static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, |
392 | struct perf_counts_values *count) | 392 | struct perf_counts_values *count) |
393 | { | 393 | { |
394 | struct perf_counts_values *aggr = &evsel->counts->aggr; | ||
395 | |||
394 | switch (aggr_mode) { | 396 | switch (aggr_mode) { |
395 | case AGGR_CORE: | 397 | case AGGR_CORE: |
396 | case AGGR_SOCKET: | 398 | case AGGR_SOCKET: |
@@ -401,6 +403,11 @@ static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, | |||
401 | update_shadow_stats(evsel, count->values); | 403 | update_shadow_stats(evsel, count->values); |
402 | break; | 404 | break; |
403 | case AGGR_GLOBAL: | 405 | case AGGR_GLOBAL: |
406 | aggr->val += count->val; | ||
407 | if (scale) { | ||
408 | aggr->ena += count->ena; | ||
409 | aggr->run += count->run; | ||
410 | } | ||
404 | default: | 411 | default: |
405 | break; | 412 | break; |
406 | } | 413 | } |
@@ -408,20 +415,27 @@ static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, | |||
408 | return 0; | 415 | return 0; |
409 | } | 416 | } |
410 | 417 | ||
418 | static int read_counter(struct perf_evsel *counter); | ||
419 | |||
411 | /* | 420 | /* |
412 | * Read out the results of a single counter: | 421 | * Read out the results of a single counter: |
413 | * aggregate counts across CPUs in system-wide mode | 422 | * aggregate counts across CPUs in system-wide mode |
414 | */ | 423 | */ |
415 | static int read_counter_aggr(struct perf_evsel *counter) | 424 | static int read_counter_aggr(struct perf_evsel *counter) |
416 | { | 425 | { |
426 | struct perf_counts_values *aggr = &counter->counts->aggr; | ||
417 | struct perf_stat *ps = counter->priv; | 427 | struct perf_stat *ps = counter->priv; |
418 | u64 *count = counter->counts->aggr.values; | 428 | u64 *count = counter->counts->aggr.values; |
419 | int i; | 429 | int i; |
420 | 430 | ||
421 | if (__perf_evsel__read(counter, perf_evsel__nr_cpus(counter), | 431 | aggr->val = aggr->ena = aggr->run = 0; |
422 | thread_map__nr(evsel_list->threads), scale) < 0) | 432 | |
433 | if (read_counter(counter)) | ||
423 | return -1; | 434 | return -1; |
424 | 435 | ||
436 | perf_evsel__compute_deltas(counter, -1, aggr); | ||
437 | perf_counts_values__scale(aggr, scale, &counter->counts->scaled); | ||
438 | |||
425 | for (i = 0; i < 3; i++) | 439 | for (i = 0; i < 3; i++) |
426 | update_stats(&ps->res_stats[i], count[i]); | 440 | update_stats(&ps->res_stats[i], count[i]); |
427 | 441 | ||