diff options
author | Jiri Olsa <jolsa@kernel.org> | 2015-06-26 05:29:14 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-26 10:26:44 -0400 |
commit | 9689edfabc1547155a7cdd1304fd294107054291 (patch) | |
tree | f20457901f70fe97eeef0550c790be67818955dd | |
parent | 254ecbc7474dfa08155c5595e90cd4a0fa9d14ce (diff) |
perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into stat object
Moving perf_evsel__(alloc|free|reset)_stat_priv into stat object, so it
could be used outside stat command in following patches.
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-10-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-stat.c | 25 | ||||
-rw-r--r-- | tools/perf/util/stat.c | 25 | ||||
-rw-r--r-- | tools/perf/util/stat.h | 4 |
3 files changed, 29 insertions, 25 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 188cd98a4ab3..8a7fd0c60ab1 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -141,31 +141,6 @@ static inline void diff_timespec(struct timespec *r, struct timespec *a, | |||
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | static void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) | ||
145 | { | ||
146 | int i; | ||
147 | struct perf_stat *ps = evsel->priv; | ||
148 | |||
149 | for (i = 0; i < 3; i++) | ||
150 | init_stats(&ps->res_stats[i]); | ||
151 | |||
152 | perf_stat_evsel_id_init(evsel); | ||
153 | } | ||
154 | |||
155 | static int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) | ||
156 | { | ||
157 | evsel->priv = zalloc(sizeof(struct perf_stat)); | ||
158 | if (evsel->priv == NULL) | ||
159 | return -ENOMEM; | ||
160 | perf_evsel__reset_stat_priv(evsel); | ||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | static void perf_evsel__free_stat_priv(struct perf_evsel *evsel) | ||
165 | { | ||
166 | zfree(&evsel->priv); | ||
167 | } | ||
168 | |||
169 | static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, | 144 | static int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, |
170 | int ncpus, int nthreads) | 145 | int ncpus, int nthreads) |
171 | { | 146 | { |
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 197a2db5f2c4..b8c329f41f13 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c | |||
@@ -143,3 +143,28 @@ void perf_evsel__free_counts(struct perf_evsel *evsel) | |||
143 | perf_counts__delete(evsel->counts); | 143 | perf_counts__delete(evsel->counts); |
144 | evsel->counts = NULL; | 144 | evsel->counts = NULL; |
145 | } | 145 | } |
146 | |||
147 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel) | ||
148 | { | ||
149 | int i; | ||
150 | struct perf_stat *ps = evsel->priv; | ||
151 | |||
152 | for (i = 0; i < 3; i++) | ||
153 | init_stats(&ps->res_stats[i]); | ||
154 | |||
155 | perf_stat_evsel_id_init(evsel); | ||
156 | } | ||
157 | |||
158 | int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel) | ||
159 | { | ||
160 | evsel->priv = zalloc(sizeof(struct perf_stat)); | ||
161 | if (evsel->priv == NULL) | ||
162 | return -ENOMEM; | ||
163 | perf_evsel__reset_stat_priv(evsel); | ||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | void perf_evsel__free_stat_priv(struct perf_evsel *evsel) | ||
168 | { | ||
169 | zfree(&evsel->priv); | ||
170 | } | ||
diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 295d1e29d3d6..c441cb312565 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h | |||
@@ -92,4 +92,8 @@ void perf_counts__delete(struct perf_counts *counts); | |||
92 | void perf_evsel__reset_counts(struct perf_evsel *evsel); | 92 | void perf_evsel__reset_counts(struct perf_evsel *evsel); |
93 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads); | 93 | int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus, int nthreads); |
94 | void perf_evsel__free_counts(struct perf_evsel *evsel); | 94 | void perf_evsel__free_counts(struct perf_evsel *evsel); |
95 | |||
96 | void perf_evsel__reset_stat_priv(struct perf_evsel *evsel); | ||
97 | int perf_evsel__alloc_stat_priv(struct perf_evsel *evsel); | ||
98 | void perf_evsel__free_stat_priv(struct perf_evsel *evsel); | ||
95 | #endif | 99 | #endif |