From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934811AbbLRJFS (ORCPT ); Fri, 18 Dec 2015 04:05:18 -0500 Received: from terminus.zytor.com ([198.137.202.10]:52253 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932099AbbLRJFA (ORCPT ); Fri, 18 Dec 2015 04:05:00 -0500 Date: Fri, 18 Dec 2015 01:04:43 -0800 From: tip-bot for Jiri Olsa Message-ID: Cc: mingo@kernel.org, jolsa@kernel.org, kan.liang@intel.com, hpa@zytor.com, acme@redhat.com, tglx@linutronix.de, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, namhyung@kernel.org, dsahern@gmail.com Reply-To: dsahern@gmail.com, namhyung@kernel.org, a.p.zijlstra@chello.nl, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, kan.liang@intel.com, jolsa@kernel.org In-Reply-To: <1445784728-21732-17-git-send-email-jolsa@kernel.org> References: <1445784728-21732-17-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add stat event read function Git-Commit-ID: 0ea0e3558607626196eb09ace796aac585e61f5c 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: 0ea0e3558607626196eb09ace796aac585e61f5c Gitweb: http://git.kernel.org/tip/0ea0e3558607626196eb09ace796aac585e61f5c Author: Jiri Olsa AuthorDate: Sun, 25 Oct 2015 15:51:32 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 Dec 2015 14:55:43 -0300 perf tools: Add stat event read function Introducing the perf_event__process_stat_event function to process a 'struct perf_stat' data from a stat event. Signed-off-by: Jiri Olsa Tested-by: Kan Liang Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1445784728-21732-17-git-send-email-jolsa@kernel.org [ Renamed 'stat' parameter to 'st' to fix 'already defined' build error with older distros (e.g. RHEL6.7) ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/stat.c | 23 +++++++++++++++++++++++ tools/perf/util/stat.h | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/tools/perf/util/stat.c b/tools/perf/util/stat.c index 2d9d830..0ad59ce 100644 --- a/tools/perf/util/stat.c +++ b/tools/perf/util/stat.c @@ -341,3 +341,26 @@ int perf_stat_process_counter(struct perf_stat_config *config, return 0; } + +int perf_event__process_stat_event(struct perf_tool *tool __maybe_unused, + union perf_event *event, + struct perf_session *session) +{ + struct perf_counts_values count; + struct stat_event *st = &event->stat; + struct perf_evsel *counter; + + count.val = st->val; + count.ena = st->ena; + count.run = st->run; + + counter = perf_evlist__id2evsel(session->evlist, st->id); + if (!counter) { + pr_err("Failed to resolve counter for stat event.\n"); + return -EINVAL; + } + + *perf_counts(counter->counts, st->cpu, st->thread) = count; + counter->supported = true; + return 0; +} diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index da1d11c..afe6844 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -90,4 +90,10 @@ void perf_evlist__reset_stats(struct perf_evlist *evlist); int perf_stat_process_counter(struct perf_stat_config *config, struct perf_evsel *counter); +struct perf_tool; +union perf_event; +struct perf_session; +int perf_event__process_stat_event(struct perf_tool *tool, + union perf_event *event, + struct perf_session *session); #endif