aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/stat.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-06-26 11:29:17 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-06-26 11:46:00 -0300
commita7d0a102e4ae46b75b70a9500979e7ed3cdf183f (patch)
treee20b51a83e32859812870723c676af04a99003e8 /tools/perf/util/stat.c
parentperf stat: Move perf_evlist__(alloc|free|reset)_stats into stat object (diff)
downloadlinux-dev-a7d0a102e4ae46b75b70a9500979e7ed3cdf183f.tar.xz
linux-dev-a7d0a102e4ae46b75b70a9500979e7ed3cdf183f.zip
perf stat: Introduce perf_evsel__alloc_stats function
Move all stat allocation logic related to stat object under single function. This way we can use it separately for stat object out of evlist object. 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-13-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/stat.c')
-rw-r--r--tools/perf/util/stat.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c
index 818cb022fcb6..f2a0d1521e26 100644
--- a/tools/perf/util/stat.c
+++ b/tools/perf/util/stat.c
@@ -189,17 +189,25 @@ void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel)
evsel->prev_raw_counts = NULL;
}
+int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw)
+{
+ int ncpus = perf_evsel__nr_cpus(evsel);
+ int nthreads = thread_map__nr(evsel->threads);
+
+ if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
+ perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
+ (alloc_raw && perf_evsel__alloc_prev_raw_counts(evsel, ncpus, nthreads) < 0))
+ return -ENOMEM;
+
+ return 0;
+}
+
int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw)
{
struct perf_evsel *evsel;
- int nthreads = thread_map__nr(evlist->threads);
evlist__for_each(evlist, evsel) {
- int ncpus = perf_evsel__nr_cpus(evsel);
-
- if (perf_evsel__alloc_stat_priv(evsel) < 0 ||
- perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
- (alloc_raw && perf_evsel__alloc_prev_raw_counts(evsel, ncpus, nthreads) < 0))
+ if (perf_evsel__alloc_stats(evsel, alloc_raw))
goto out_free;
}