From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754160AbbF3E4X (ORCPT ); Tue, 30 Jun 2015 00:56:23 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38551 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753931AbbF3E4H (ORCPT ); Tue, 30 Jun 2015 00:56:07 -0400 Date: Mon, 29 Jun 2015 21:55:50 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: hpa@zytor.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, dsahern@gmail.com, a.p.zijlstra@chello.nl, eranian@google.com, ak@linux.intel.com, tglx@linutronix.de, jolsa@kernel.org, adrian.hunter@intel.com, mingo@kernel.org, acme@redhat.com Reply-To: a.p.zijlstra@chello.nl, dsahern@gmail.com, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, acme@redhat.com, adrian.hunter@intel.com, mingo@kernel.org, tglx@linutronix.de, jolsa@kernel.org, ak@linux.intel.com, eranian@google.com In-Reply-To: <1435310967-14570-13-git-send-email-jolsa@kernel.org> References: <1435310967-14570-13-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf stat: Introduce perf_evsel__alloc_stats function Git-Commit-ID: a7d0a102e4ae46b75b70a9500979e7ed3cdf183f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a7d0a102e4ae46b75b70a9500979e7ed3cdf183f Gitweb: http://git.kernel.org/tip/a7d0a102e4ae46b75b70a9500979e7ed3cdf183f Author: Jiri Olsa AuthorDate: Fri, 26 Jun 2015 11:29:17 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 26 Jun 2015 11:46:00 -0300 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 Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/1435310967-14570-13-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.c | 20 ++++++++++++++------ tools/perf/util/stat.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 818cb02..f2a0d15 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; } diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 5f62db2..9f05c57 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -103,6 +103,8 @@ int perf_evsel__alloc_prev_raw_counts(struct perf_evsel *evsel, int ncpus, int nthreads); void perf_evsel__free_prev_raw_counts(struct perf_evsel *evsel); +int perf_evsel__alloc_stats(struct perf_evsel *evsel, bool alloc_raw); + int perf_evlist__alloc_stats(struct perf_evlist *evlist, bool alloc_raw); void perf_evlist__free_stats(struct perf_evlist *evlist); void perf_evlist__reset_stats(struct perf_evlist *evlist);