diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-11-21 04:31:10 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-01 18:00:30 -0500 |
commit | 1971f59f1a1e0e7f3efc25ce0597505626d9f7ed (patch) | |
tree | 212242fa9a6302041962aa95a9b78b07aacf15fe | |
parent | 9bf1a52914c7e810091f7726790fc42242a2dafe (diff) |
perf stat: Use read_counter in read_counter_aggr
Use the read_counter function as the values retrieval function for aggr
counter values thus eliminating the use of __perf_evsel__read function.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Matt Fleming <matt.fleming@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1416562275-12404-7-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-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 | ||