From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755272AbbHGB77 (ORCPT ); Thu, 6 Aug 2015 21:59:59 -0400 Received: from mail.kernel.org ([198.145.29.136]:48525 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753772AbbHGB75 (ORCPT ); Thu, 6 Aug 2015 21:59:57 -0400 Date: Thu, 6 Aug 2015 16:50:32 -0300 From: Arnaldo Carvalho de Melo To: Adrian Hunter Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Jiri Olsa Subject: Re: [PATCH V8 14/25] perf tools: Add perf_pmu__format_bits() Message-ID: <20150806195032.GF10826@kernel.org> References: <1437150840-31811-1-git-send-email-adrian.hunter@intel.com> <1437150840-31811-15-git-send-email-adrian.hunter@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1437150840-31811-15-git-send-email-adrian.hunter@intel.com> 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 Fri, Jul 17, 2015 at 07:33:49PM +0300, Adrian Hunter escreveu: > Add perf_pmu__format_bits() to get the format bits > for a PMU config term. Intel PT will use this to > validate terms and to record format bits to enable > later interpreting the config from the attribute > stored in the perf.data file. Applied > Signed-off-by: Adrian Hunter > --- > tools/perf/util/pmu.c | 17 ++++++++++++++++- > tools/perf/util/pmu.h | 1 + > 2 files changed, 17 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c > index 52d569cda606..d26ff0ab8410 100644 > --- a/tools/perf/util/pmu.c > +++ b/tools/perf/util/pmu.c > @@ -538,7 +538,7 @@ struct perf_pmu *perf_pmu__find(const char *name) > } > > static struct perf_pmu_format * > -pmu_find_format(struct list_head *formats, char *name) > +pmu_find_format(struct list_head *formats, const char *name) > { > struct perf_pmu_format *format; > > @@ -549,6 +549,21 @@ pmu_find_format(struct list_head *formats, char *name) > return NULL; > } > > +__u64 perf_pmu__format_bits(struct list_head *formats, const char *name) > +{ > + struct perf_pmu_format *format = pmu_find_format(formats, name); > + __u64 bits = 0; > + int fbit; > + > + if (!format) > + return 0; > + > + for_each_set_bit(fbit, format->bits, PERF_PMU_FORMAT_BITS) > + bits |= 1ULL << fbit; > + > + return bits; > +} > + > /* > * Sets value based on the format definition (format parameter) > * and unformated value (value parameter). > diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h > index 7b9c8cf8ae3e..5d7e84466bee 100644 > --- a/tools/perf/util/pmu.h > +++ b/tools/perf/util/pmu.h > @@ -54,6 +54,7 @@ int perf_pmu__config_terms(struct list_head *formats, > struct perf_event_attr *attr, > struct list_head *head_terms, > bool zero, struct parse_events_error *error); > +__u64 perf_pmu__format_bits(struct list_head *formats, const char *name); > int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms, > struct perf_pmu_info *info); > struct list_head *perf_pmu__alias(struct perf_pmu *pmu, > -- > 1.9.1