From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964978AbbFJTOJ (ORCPT ); Wed, 10 Jun 2015 15:14:09 -0400 Received: from mail.kernel.org ([198.145.29.136]:45717 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964932AbbFJTN5 (ORCPT ); Wed, 10 Jun 2015 15:13:57 -0400 Date: Wed, 10 Jun 2015 16:13:52 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Adrian Hunter , Andi Kleen , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Stephane Eranian Subject: Re: [PATCH 15/25] perf stat: Move perf_evlist__(alloc|free)_stats into evlist object Message-ID: <20150610191352.GI3332@kernel.org> References: <1433959858-31858-1-git-send-email-jolsa@kernel.org> <1433959858-31858-16-git-send-email-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433959858-31858-16-git-send-email-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, Jun 10, 2015 at 08:10:48PM +0200, Jiri Olsa escreveu: > Moving perf_evlist__(alloc|free)_stats into evsel object, > so it could be used in following patches. Can this go into the new counts.[ch] file too? As it is specific to counting tools? - Arnaldo > 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