From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964872AbbFJSOh (ORCPT ); Wed, 10 Jun 2015 14:14:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39899 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934079AbbFJSM5 (ORCPT ); Wed, 10 Jun 2015 14:12:57 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Adrian Hunter , Andi Kleen , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Stephane Eranian Subject: [PATCH 15/25] perf stat: Move perf_evlist__(alloc|free)_stats into evlist object Date: Wed, 10 Jun 2015 20:10:48 +0200 Message-Id: <1433959858-31858-16-git-send-email-jolsa@kernel.org> In-Reply-To: <1433959858-31858-1-git-send-email-jolsa@kernel.org> References: <1433959858-31858-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moving perf_evlist__(alloc|free)_stats into evsel object, so it could be used in following patches. Link: http://lkml.kernel.org/n/tip-8dwmf838kipxabe0vay8h0zn@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/builtin-stat.c | 32 -------------------------------- tools/perf/util/evlist.c | 32 ++++++++++++++++++++++++++++++++ tools/perf/util/evlist.h | 2 ++ 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b15fc47aa673..5072ca809c23 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -141,38 +141,6 @@ static inline void diff_timespec(struct timespec *r, struct timespec *a, } } -static void perf_evlist__free_stats(struct perf_evlist *evlist) -{ - struct perf_evsel *evsel; - - evlist__for_each(evlist, evsel) { - perf_evsel__free_stat_priv(evsel); - perf_evsel__free_counts(evsel); - perf_evsel__free_prev_raw_counts(evsel); - } -} - -static int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw) -{ - struct perf_evsel *evsel; - int nthreads = thread_map__nr(evsel_list->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)) - goto out_free; - } - - return 0; - -out_free: - perf_evlist__free_stats(evlist); - return -1; -} - static void perf_stat__reset_stats(struct perf_evlist *evlist) { struct perf_evsel *evsel; diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index f438881040f2..44d52a07223c 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -1651,3 +1651,35 @@ void perf_evlist__set_tracking_event(struct perf_evlist *evlist, tracking_evsel->tracking = true; } + +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)) + goto out_free; + } + + return 0; + +out_free: + perf_evlist__free_stats(evlist); + return -1; +} + +void perf_evlist__free_stats(struct perf_evlist *evlist) +{ + struct perf_evsel *evsel; + + evlist__for_each(evlist, evsel) { + perf_evsel__free_stat_priv(evsel); + perf_evsel__free_counts(evsel); + perf_evsel__free_prev_raw_counts(evsel); + } +} diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 955bf31b7dd3..557083673bab 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -288,4 +288,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist, void perf_evlist__set_tracking_event(struct perf_evlist *evlist, struct perf_evsel *tracking_evsel); +int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw); +void perf_evlist__free_stats(struct perf_evlist *evlist); #endif /* __PERF_EVLIST_H */ -- 1.9.3