diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-06-26 05:29:09 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-26 10:11:26 -0400 |
commit | 1ac77e1ce8654ec94ada0c508d58ba80a4647fba (patch) | |
tree | af641ba0dc1fadca7bd3a729b17535aafe49e3de /tools | |
parent | 134aa44f6bff6b967efb85255ee9e8982cb8e486 (diff) |
perf stat: Introduce perf_counts function
Introducing perf_counts function, that returns
'struct perf_counts_values' pointer for given cpu.
Also moving perf_counts* structures into stat.h.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1435310967-14570-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 14 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall-all-cpus.c | 4 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall.c | 2 | ||||
-rw-r--r-- | tools/perf/util/evsel.c | 6 | ||||
-rw-r--r-- | tools/perf/util/evsel.h | 18 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 23 |
6 files changed, 37 insertions, 30 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 3e1636cae76b..49b90374232c 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -316,7 +316,7 @@ static int read_cb(struct perf_evsel *evsel, int cpu, int thread __maybe_unused, | |||
316 | if (!evsel->snapshot) | 316 | if (!evsel->snapshot) |
317 | perf_evsel__compute_deltas(evsel, cpu, count); | 317 | perf_evsel__compute_deltas(evsel, cpu, count); |
318 | perf_counts_values__scale(count, scale, NULL); | 318 | perf_counts_values__scale(count, scale, NULL); |
319 | evsel->counts->cpu[cpu] = *count; | 319 | *perf_counts(evsel->counts, cpu) = *count; |
320 | if (aggr_mode == AGGR_NONE) | 320 | if (aggr_mode == AGGR_NONE) |
321 | perf_stat__update_shadow_stats(evsel, count->values, cpu); | 321 | perf_stat__update_shadow_stats(evsel, count->values, cpu); |
322 | break; | 322 | break; |
@@ -805,9 +805,9 @@ static void print_aggr(char *prefix) | |||
805 | s2 = aggr_get_id(evsel_list->cpus, cpu2); | 805 | s2 = aggr_get_id(evsel_list->cpus, cpu2); |
806 | if (s2 != id) | 806 | if (s2 != id) |
807 | continue; | 807 | continue; |
808 | val += counter->counts->cpu[cpu].val; | 808 | val += perf_counts(counter->counts, cpu)->val; |
809 | ena += counter->counts->cpu[cpu].ena; | 809 | ena += perf_counts(counter->counts, cpu)->ena; |
810 | run += counter->counts->cpu[cpu].run; | 810 | run += perf_counts(counter->counts, cpu)->run; |
811 | nr++; | 811 | nr++; |
812 | } | 812 | } |
813 | if (prefix) | 813 | if (prefix) |
@@ -915,9 +915,9 @@ static void print_counter(struct perf_evsel *counter, char *prefix) | |||
915 | int cpu; | 915 | int cpu; |
916 | 916 | ||
917 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { | 917 | for (cpu = 0; cpu < perf_evsel__nr_cpus(counter); cpu++) { |
918 | val = counter->counts->cpu[cpu].val; | 918 | val = perf_counts(counter->counts, cpu)->val; |
919 | ena = counter->counts->cpu[cpu].ena; | 919 | ena = perf_counts(counter->counts, cpu)->ena; |
920 | run = counter->counts->cpu[cpu].run; | 920 | run = perf_counts(counter->counts, cpu)->run; |
921 | 921 | ||
922 | if (prefix) | 922 | if (prefix) |
923 | fprintf(output, "%s", prefix); | 923 | fprintf(output, "%s", prefix); |
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c index b8d552b13950..e8d944fe1bd0 100644 --- a/tools/perf/tests/openat-syscall-all-cpus.c +++ b/tools/perf/tests/openat-syscall-all-cpus.c | |||
@@ -98,9 +98,9 @@ int test__openat_syscall_event_on_all_cpus(void) | |||
98 | } | 98 | } |
99 | 99 | ||
100 | expected = nr_openat_calls + cpu; | 100 | expected = nr_openat_calls + cpu; |
101 | if (evsel->counts->cpu[cpu].val != expected) { | 101 | if (perf_counts(evsel->counts, cpu)->val != expected) { |
102 | pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", | 102 | pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got %" PRIu64 "\n", |
103 | expected, cpus->map[cpu], evsel->counts->cpu[cpu].val); | 103 | expected, cpus->map[cpu], perf_counts(evsel->counts, cpu)->val); |
104 | err = -1; | 104 | err = -1; |
105 | } | 105 | } |
106 | } | 106 | } |
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index bdfa1f446681..e86fc477a74f 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c | |||
@@ -44,7 +44,7 @@ int test__openat_syscall_event(void) | |||
44 | goto out_close_fd; | 44 | goto out_close_fd; |
45 | } | 45 | } |
46 | 46 | ||
47 | if (evsel->counts->cpu[0].val != nr_openat_calls) { | 47 | if (perf_counts(evsel->counts, 0)->val != nr_openat_calls) { |
48 | pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n", | 48 | pr_debug("perf_evsel__read_on_cpu: expected to intercept %d calls, got %" PRIu64 "\n", |
49 | nr_openat_calls, evsel->counts->cpu[0].val); | 49 | nr_openat_calls, evsel->counts->cpu[0].val); |
50 | goto out_close_fd; | 50 | goto out_close_fd; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1b2f480a3e82..8401b042b9d4 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -910,8 +910,8 @@ void perf_evsel__compute_deltas(struct perf_evsel *evsel, int cpu, | |||
910 | tmp = evsel->prev_raw_counts->aggr; | 910 | tmp = evsel->prev_raw_counts->aggr; |
911 | evsel->prev_raw_counts->aggr = *count; | 911 | evsel->prev_raw_counts->aggr = *count; |
912 | } else { | 912 | } else { |
913 | tmp = evsel->prev_raw_counts->cpu[cpu]; | 913 | tmp = *perf_counts(evsel->prev_raw_counts, cpu); |
914 | evsel->prev_raw_counts->cpu[cpu] = *count; | 914 | *perf_counts(evsel->prev_raw_counts, cpu) = *count; |
915 | } | 915 | } |
916 | 916 | ||
917 | count->val = count->val - tmp.val; | 917 | count->val = count->val - tmp.val; |
@@ -972,7 +972,7 @@ int __perf_evsel__read_on_cpu(struct perf_evsel *evsel, | |||
972 | 972 | ||
973 | perf_evsel__compute_deltas(evsel, cpu, &count); | 973 | perf_evsel__compute_deltas(evsel, cpu, &count); |
974 | perf_counts_values__scale(&count, scale, NULL); | 974 | perf_counts_values__scale(&count, scale, NULL); |
975 | evsel->counts->cpu[cpu] = count; | 975 | *perf_counts(evsel->counts, cpu) = count; |
976 | return 0; | 976 | return 0; |
977 | } | 977 | } |
978 | 978 | ||
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 4dbf32d94dfb..b420f8f5fc5d 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h | |||
@@ -9,23 +9,7 @@ | |||
9 | #include "xyarray.h" | 9 | #include "xyarray.h" |
10 | #include "symbol.h" | 10 | #include "symbol.h" |
11 | #include "cpumap.h" | 11 | #include "cpumap.h" |
12 | 12 | #include "stat.h" | |
13 | struct perf_counts_values { | ||
14 | union { | ||
15 | struct { | ||
16 | u64 val; | ||
17 | u64 ena; | ||
18 | u64 run; | ||
19 | }; | ||
20 | u64 values[3]; | ||
21 | }; | ||
22 | }; | ||
23 | |||
24 | struct perf_counts { | ||
25 | s8 scaled; | ||
26 | struct perf_counts_values aggr; | ||
27 | struct perf_counts_values cpu[]; | ||
28 | }; | ||
29 | 13 | ||
30 | struct perf_evsel; | 14 | struct perf_evsel; |
31 | 15 | ||
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 093dc3cb28dd..5e43348836a6 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -31,6 +31,29 @@ enum aggr_mode { | |||
31 | AGGR_CORE, | 31 | AGGR_CORE, |
32 | }; | 32 | }; |
33 | 33 | ||
34 | struct perf_counts_values { | ||
35 | union { | ||
36 | struct { | ||
37 | u64 val; | ||
38 | u64 ena; | ||
39 | u64 run; | ||
40 | }; | ||
41 | u64 values[3]; | ||
42 | }; | ||
43 | }; | ||
44 | |||
45 | struct perf_counts { | ||
46 | s8 scaled; | ||
47 | struct perf_counts_values aggr; | ||
48 | struct perf_counts_values cpu[]; | ||
49 | }; | ||
50 | |||
51 | static inline struct perf_counts_values* | ||
52 | perf_counts(struct perf_counts *counts, int cpu) | ||
53 | { | ||
54 | return &counts->cpu[cpu]; | ||
55 | } | ||
56 | |||
34 | void update_stats(struct stats *stats, u64 val); | 57 | void update_stats(struct stats *stats, u64 val); |
35 | double avg_stats(struct stats *stats); | 58 | double avg_stats(struct stats *stats); |
36 | double stddev_stats(struct stats *stats); | 59 | double stddev_stats(struct stats *stats); |