diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-06-26 05:29:10 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-26 10:19:19 -0400 |
commit | a8e02324dfe6bcafc15d02b790f33321ec4facb0 (patch) | |
tree | 74fc921aab20fe15559b3a0bb82095cee80aa9b9 /tools | |
parent | 1ac77e1ce8654ec94ada0c508d58ba80a4647fba (diff) |
perf stat: Use xyarray for cpu evsel counts
Switching single dimensional array of 'struct perf_counts_values'
with xyarray object, so we could store thread dimension counts.
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-6-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 | 2 | ||||
-rw-r--r-- | tools/perf/tests/openat-syscall.c | 2 | ||||
-rw-r--r-- | tools/perf/util/stat.c | 31 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 7 |
4 files changed, 28 insertions, 14 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 49b90374232c..055ce83dd6f2 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -218,7 +218,7 @@ static void perf_stat__reset_stats(struct perf_evlist *evlist) | |||
218 | 218 | ||
219 | evlist__for_each(evlist, evsel) { | 219 | evlist__for_each(evlist, evsel) { |
220 | perf_evsel__reset_stat_priv(evsel); | 220 | perf_evsel__reset_stat_priv(evsel); |
221 | perf_evsel__reset_counts(evsel, perf_evsel__nr_cpus(evsel)); | 221 | perf_evsel__reset_counts(evsel); |
222 | } | 222 | } |
223 | 223 | ||
224 | perf_stat__reset_shadow_stats(); | 224 | perf_stat__reset_shadow_stats(); |
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c index e86fc477a74f..bd882f09ebbc 100644 --- a/tools/perf/tests/openat-syscall.c +++ b/tools/perf/tests/openat-syscall.c | |||
@@ -46,7 +46,7 @@ int test__openat_syscall_event(void) | |||
46 | 46 | ||
47 | if (perf_counts(evsel->counts, 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, perf_counts(evsel->counts, 0)->val); |
50 | goto out_close_fd; | 50 | goto out_close_fd; |
51 | } | 51 | } |
52 | 52 | ||
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 4014b709f956..453480aa7650 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -97,26 +97,39 @@ void perf_stat_evsel_id_init(struct perf_evsel *evsel) | |||
97 | 97 | ||
98 | struct perf_counts *perf_counts__new(int ncpus) | 98 | struct perf_counts *perf_counts__new(int ncpus) |
99 | { | 99 | { |
100 | int size = sizeof(struct perf_counts) + | 100 | struct perf_counts *counts = zalloc(sizeof(*counts)); |
101 | ncpus * sizeof(struct perf_counts_values); | ||
102 | 101 | ||
103 | return zalloc(size); | 102 | if (counts) { |
103 | struct xyarray *cpu; | ||
104 | |||
105 | cpu = xyarray__new(ncpus, 1, sizeof(struct perf_counts_values)); | ||
106 | if (!cpu) { | ||
107 | free(counts); | ||
108 | return NULL; | ||
109 | } | ||
110 | |||
111 | counts->cpu = cpu; | ||
112 | } | ||
113 | |||
114 | return counts; | ||
104 | } | 115 | } |
105 | 116 | ||
106 | void perf_counts__delete(struct perf_counts *counts) | 117 | void perf_counts__delete(struct perf_counts *counts) |
107 | { | 118 | { |
108 | free(counts); | 119 | if (counts) { |
120 | xyarray__delete(counts->cpu); | ||
121 | free(counts); | ||
122 | } | ||
109 | } | 123 | } |
110 | 124 | ||
111 | static void perf_counts__reset(struct perf_counts *counts, int ncpus) | 125 | static void perf_counts__reset(struct perf_counts *counts) |
112 | { | 126 | { |
113 | memset(counts, 0, (sizeof(*counts) + | 127 | xyarray__reset(counts->cpu); |
114 | (ncpus * sizeof(struct perf_counts_values)))); | ||
115 | } | 128 | } |
116 | 129 | ||
117 | void perf_evsel__reset_counts(struct perf_evsel *evsel, int ncpus) | 130 | void perf_evsel__reset_counts(struct perf_evsel *evsel) |
118 | { | 131 | { |
119 | perf_counts__reset(evsel->counts, ncpus); | 132 | perf_counts__reset(evsel->counts); |
120 | } | 133 | } |
121 | 134 | ||
122 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus) | 135 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus) |
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 5e43348836a6..6d07612545e0 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -3,6 +3,7 @@ | |||
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <stdio.h> | 5 | #include <stdio.h> |
6 | #include "xyarray.h" | ||
6 | 7 | ||
7 | struct stats | 8 | struct stats |
8 | { | 9 | { |
@@ -45,13 +46,13 @@ struct perf_counts_values { | |||
45 | struct perf_counts { | 46 | struct perf_counts { |
46 | s8 scaled; | 47 | s8 scaled; |
47 | struct perf_counts_values aggr; | 48 | struct perf_counts_values aggr; |
48 | struct perf_counts_values cpu[]; | 49 | struct xyarray *cpu; |
49 | }; | 50 | }; |
50 | 51 | ||
51 | static inline struct perf_counts_values* | 52 | static inline struct perf_counts_values* |
52 | perf_counts(struct perf_counts *counts, int cpu) | 53 | perf_counts(struct perf_counts *counts, int cpu) |
53 | { | 54 | { |
54 | return &counts->cpu[cpu]; | 55 | return xyarray__entry(counts->cpu, cpu, 0); |
55 | } | 56 | } |
56 | 57 | ||
57 | void update_stats(struct stats *stats, u64 val); | 58 | void update_stats(struct stats *stats, u64 val); |
@@ -88,7 +89,7 @@ void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel, | |||
88 | struct perf_counts *perf_counts__new(int ncpus); | 89 | struct perf_counts *perf_counts__new(int ncpus); |
89 | void perf_counts__delete(struct perf_counts *counts); | 90 | void perf_counts__delete(struct perf_counts *counts); |
90 | 91 | ||
91 | void perf_evsel__reset_counts(struct perf_evsel *evsel, int ncpus); | 92 | void perf_evsel__reset_counts(struct perf_evsel *evsel); |
92 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); | 93 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus); |
93 | void perf_evsel__free_counts(struct perf_evsel *evsel); | 94 | void perf_evsel__free_counts(struct perf_evsel *evsel); |
94 | #endif | 95 | #endif |