diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-11-21 04:31:14 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-12-01 18:00:30 -0500 |
commit | 779d0b997e0787fc5f80110159b6c18ae0fae395 (patch) | |
tree | 5834910f5c9e0640ab0764351b718b79b530b522 /tools/perf | |
parent | a5a7fd76b55a6e6916ff22e5c8fdb39a8381be2c (diff) |
perf stat: Add support for per-pkg counters
The .per-pkg file indicates that all but one value per socket should be
discarded. Adding the logic of skipping the rest of the socket once
first value was read.
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-11-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-stat.c | 49 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 1 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b24a7a08bd1d..860e8ad06616 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -388,10 +388,56 @@ static void update_shadow_stats(struct perf_evsel *counter, u64 *count) | |||
388 | update_stats(&runtime_itlb_cache_stats[0], count[0]); | 388 | update_stats(&runtime_itlb_cache_stats[0], count[0]); |
389 | } | 389 | } |
390 | 390 | ||
391 | static void zero_per_pkg(struct perf_evsel *counter) | ||
392 | { | ||
393 | if (counter->per_pkg_mask) | ||
394 | memset(counter->per_pkg_mask, 0, MAX_NR_CPUS); | ||
395 | } | ||
396 | |||
397 | static int check_per_pkg(struct perf_evsel *counter, int cpu, bool *skip) | ||
398 | { | ||
399 | unsigned long *mask = counter->per_pkg_mask; | ||
400 | struct cpu_map *cpus = perf_evsel__cpus(counter); | ||
401 | int s; | ||
402 | |||
403 | *skip = false; | ||
404 | |||
405 | if (!counter->per_pkg) | ||
406 | return 0; | ||
407 | |||
408 | if (cpu_map__empty(cpus)) | ||
409 | return 0; | ||
410 | |||
411 | if (!mask) { | ||
412 | mask = zalloc(MAX_NR_CPUS); | ||
413 | if (!mask) | ||
414 | return -ENOMEM; | ||
415 | |||
416 | counter->per_pkg_mask = mask; | ||
417 | } | ||
418 | |||
419 | s = cpu_map__get_socket(cpus, cpu); | ||
420 | if (s < 0) | ||
421 | return -1; | ||
422 | |||
423 | *skip = test_and_set_bit(s, mask) == 1; | ||
424 | return 0; | ||
425 | } | ||
426 | |||
391 | static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, | 427 | static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, |
392 | struct perf_counts_values *count) | 428 | struct perf_counts_values *count) |
393 | { | 429 | { |
394 | struct perf_counts_values *aggr = &evsel->counts->aggr; | 430 | struct perf_counts_values *aggr = &evsel->counts->aggr; |
431 | static struct perf_counts_values zero; | ||
432 | bool skip = false; | ||
433 | |||
434 | if (check_per_pkg(evsel, cpu, &skip)) { | ||
435 | pr_err("failed to read per-pkg counter\n"); | ||
436 | return -1; | ||
437 | } | ||
438 | |||
439 | if (skip) | ||
440 | count = &zero; | ||
395 | 441 | ||
396 | switch (aggr_mode) { | 442 | switch (aggr_mode) { |
397 | case AGGR_CORE: | 443 | case AGGR_CORE: |
@@ -465,6 +511,9 @@ static int read_counter(struct perf_evsel *counter) | |||
465 | if (counter->system_wide) | 511 | if (counter->system_wide) |
466 | nthreads = 1; | 512 | nthreads = 1; |
467 | 513 | ||
514 | if (counter->per_pkg) | ||
515 | zero_per_pkg(counter); | ||
516 | |||
468 | for (thread = 0; thread < nthreads; thread++) { | 517 | for (thread = 0; thread < nthreads; thread++) { |
469 | for (cpu = 0; cpu < ncpus; cpu++) { | 518 | for (cpu = 0; cpu < ncpus; cpu++) { |
470 | if (perf_evsel__read_cb(counter, cpu, thread, read_cb)) | 519 | if (perf_evsel__read_cb(counter, cpu, thread, read_cb)) |
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 3207f4861038..38622747d130 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -93,6 +93,7 @@ struct perf_evsel { | |||
93 | bool system_wide; | 93 | bool system_wide; |
94 | bool tracking; | 94 | bool tracking; |
95 | bool per_pkg; | 95 | bool per_pkg; |
96 | unsigned long *per_pkg_mask; | ||
96 | /* parse modifier helper */ | 97 | /* parse modifier helper */ |
97 | int exclude_GH; | 98 | int exclude_GH; |
98 | int nr_members; | 99 | int nr_members; |