From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759143AbbFBSLJ (ORCPT ); Tue, 2 Jun 2015 14:11:09 -0400 Received: from mail.kernel.org ([198.145.29.136]:48819 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754325AbbFBSLD (ORCPT ); Tue, 2 Jun 2015 14:11:03 -0400 Date: Tue, 2 Jun 2015 15:10:56 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: lkml , Peter Zijlstra , Paul Mackerras , David Ahern , Namhyung Kim , Ingo Molnar , Andi Kleen , Stephane Eranian Subject: Re: [PATCH 1/9] perf tools: Add nameid value into evsel object Message-ID: <20150602181056.GR624@kernel.org> References: <1433199603-20082-1-git-send-email-jolsa@kernel.org> <1433199603-20082-2-git-send-email-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433199603-20082-2-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 Tue, Jun 02, 2015 at 12:59:55AM +0200, Jiri Olsa escreveu: > Adding a way to tag an evsel object with ID value based > on its name. It will be used for transaction events, > but could be useful for others. For what? Can you ellaborate? Just by looking at this commit message I can't figure out the value of this patch :-\ - Arnaldo > This way we can identify transactions events and get rid > of the current position based way we use. > Link: http://lkml.kernel.org/n/tip-9lnvjksibrs0flhkpix2qkm9@git.kernel.org > Signed-off-by: Jiri Olsa > --- > tools/perf/util/evsel.c | 22 ++++++++++++++++++++++ > tools/perf/util/evsel.h | 11 +++++++++++ > tools/perf/util/parse-events.c | 2 +- > 3 files changed, 34 insertions(+), 1 deletion(-) > > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index a3e36fc634dc..9e057319933d 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -80,6 +80,28 @@ set_methods: > return 0; > } > > +#define ID(id, name) [PERF_EVSEL_NAMEID__##id] = #name > +static const char *nameid_str[PERF_EVSEL_NAMEID__MAX] = { > + ID(NONE, x), > +}; > +#undef ID > + > +void perf_evsel__name_init(struct perf_evsel *evsel, char *name) > +{ > + enum perf_evsel_nameid nameid = PERF_EVSEL_NAMEID__NONE; > + int i; > + > + for (i = 0; i < PERF_EVSEL_NAMEID__MAX; i++) { > + if (!strcmp(name, nameid_str[i])) { > + nameid = i; > + break; > + } > + } > + > + evsel->nameid = nameid; > + evsel->name = strdup(name); > +} > + > #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) > > int __perf_evsel__sample_size(u64 sample_type) > diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h > index 21ec08247d47..f89f34f1a7a1 100644 > --- a/tools/perf/util/evsel.h > +++ b/tools/perf/util/evsel.h > @@ -46,6 +46,13 @@ struct perf_sample_id { > > struct cgroup_sel; > > +enum perf_evsel_nameid { > + PERF_EVSEL_NAMEID__NONE = 0, > + PERF_EVSEL_NAMEID__MAX, > +}; > + > +#define perf_evsel__is(evsel, id) (evsel->nameid == PERF_EVSEL_NAMEID__ ## id) > + > /** struct perf_evsel - event selector > * > * @name - Can be set to retain the original event name passed by the user, > @@ -100,6 +107,8 @@ struct perf_evsel { > unsigned long *per_pkg_mask; > struct perf_evsel *leader; > char *group_name; > + > + enum perf_evsel_nameid nameid; > }; > > union u64_swap { > @@ -366,4 +375,6 @@ typedef int (*attr__fprintf_f)(FILE *, const char *, const char *, void *); > int perf_event_attr__fprintf(FILE *fp, struct perf_event_attr *attr, > attr__fprintf_f attr__fprintf, void *priv); > > +void perf_evsel__name_init(struct perf_evsel *evsel, char *name); > + > #endif /* __PERF_EVSEL_H */ > diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c > index 2a4d1ec02846..abf0ff07b9cf 100644 > --- a/tools/perf/util/parse-events.c > +++ b/tools/perf/util/parse-events.c > @@ -890,7 +890,7 @@ int parse_events_name(struct list_head *list, char *name) > > __evlist__for_each(list, evsel) { > if (!evsel->name) > - evsel->name = strdup(name); > + perf_evsel__name_init(evsel, name); > } > > return 0; > -- > 1.9.3