public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Ingo Molnar <mingo@kernel.org>, Andi Kleen <ak@linux.intel.com>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 1/9] perf tools: Add nameid value into evsel object
Date: Tue, 2 Jun 2015 15:10:56 -0300	[thread overview]
Message-ID: <20150602181056.GR624@kernel.org> (raw)
In-Reply-To: <1433199603-20082-2-git-send-email-jolsa@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 <jolsa@kernel.org>
> ---
>  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

  reply	other threads:[~2015-06-02 18:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-01 22:59 [PATCH 0/9] perf stat: Separate shadow counters code Jiri Olsa
2015-06-01 22:59 ` [PATCH 1/9] perf tools: Add nameid value into evsel object Jiri Olsa
2015-06-02 18:10   ` Arnaldo Carvalho de Melo [this message]
2015-06-02 18:46     ` Jiri Olsa
2015-06-02 19:59       ` Arnaldo Carvalho de Melo
2015-06-01 22:59 ` [PATCH 2/9] perf stat: Replace transaction event check with nameid Jiri Olsa
2015-06-01 22:59 ` [PATCH 3/9] perf stat: Remove setup_events function Jiri Olsa
2015-06-01 22:59 ` [PATCH 4/9] perf stat: Remove transaction_run from shadow update/print code Jiri Olsa
2015-06-01 22:59 ` [PATCH 5/9] perf stat: Introduce reset_shadow_stats function Jiri Olsa
2015-06-01 23:00 ` [PATCH 6/9] perf stat: Introduce print_shadow_stats function Jiri Olsa
2015-06-01 23:00 ` [PATCH 7/9] perf stat: Add output file argument to " Jiri Olsa
2015-06-01 23:00 ` [PATCH 8/9] perf stat: Add aggr_mode " Jiri Olsa
2015-06-01 23:00 ` [PATCH 9/9] perf stat: Move shadow stat counters into separate object Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150602181056.GR624@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=ak@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox