All of lore.kernel.org
 help / color / mirror / Atom feed
From: jolsa@redhat.com (Jiri Olsa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 07/11] perf vendor events: add support for arch standard events
Date: Tue, 27 Feb 2018 10:48:48 +0100	[thread overview]
Message-ID: <20180227094848.GF21033@krava> (raw)
In-Reply-To: <1519401932-205051-8-git-send-email-john.garry@huawei.com>

On Sat, Feb 24, 2018 at 12:05:28AM +0800, John Garry wrote:

SNIP

> +static int save_arch_std_events(void *data, char *name, char *event,
> +				char *desc, char *long_desc, char *pmu,
> +				char *unit, char *perpkg, char *metric_expr,
> +				char *metric_name, char *metric_group)
> +{
> +	struct event_struct *es;
> +	struct stat *sb = data;
> +
> +	es = malloc(sizeof(*es));
> +	if (!es)
> +		return -ENOMEM;
> +	memset(es, 0, sizeof(*es));
> +	FOR_ALL_EVENT_STRUCT_FIELDS(ADD_EVENT_FIELD);
> +	list_add_tail(&es->list, &arch_std_events);
> +	return 0;
> +out_free:
> +	FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
> +	free(es);
> +	return -ENOMEM;
> +}
> +
>  static void print_events_table_suffix(FILE *outfp)
>  {
>  	fprintf(outfp, "{\n");
> @@ -391,6 +469,27 @@ static char *real_event(const char *name, char *event)
>  	return event;
>  }
>  
> +static int
> +try_fixup(const char *fn, char *arch_std, char **event, char **desc,
> +	  char **name, char **long_desc, char **pmu, char **filter,
> +	  char **perpkg, char **unit, char **metric_expr, char **metric_name,
> +	  char **metric_group)
> +{
> +	/* try to find matching event from arch standard values */
> +	struct event_struct *es;
> +
> +	list_for_each_entry(es, &arch_std_events, list) {
> +		if (!strcmp(arch_std, es->event+sizeof(EVENT_PREFIX))) {

I spent some time figuring out how this can work when there's on '=' in EVENT_PREFIX
is this because sizeof returns +1 size for NULL char also?

thanks,
jirka

WARNING: multiple messages have this Message-ID (diff)
From: Jiri Olsa <jolsa@redhat.com>
To: John Garry <john.garry@huawei.com>
Cc: ak@linux.intel.com, peterz@infradead.org, mingo@redhat.com,
	acme@kernel.org, alexander.shishkin@linux.intel.com,
	namhyung@kernel.org, wcohen@redhat.com, will.deacon@arm.com,
	ganapatrao.kulkarni@cavium.com, linuxarm@huawei.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, zhangshaokun@hisilicon.com
Subject: Re: [PATCH v2 07/11] perf vendor events: add support for arch standard events
Date: Tue, 27 Feb 2018 10:48:48 +0100	[thread overview]
Message-ID: <20180227094848.GF21033@krava> (raw)
In-Reply-To: <1519401932-205051-8-git-send-email-john.garry@huawei.com>

On Sat, Feb 24, 2018 at 12:05:28AM +0800, John Garry wrote:

SNIP

> +static int save_arch_std_events(void *data, char *name, char *event,
> +				char *desc, char *long_desc, char *pmu,
> +				char *unit, char *perpkg, char *metric_expr,
> +				char *metric_name, char *metric_group)
> +{
> +	struct event_struct *es;
> +	struct stat *sb = data;
> +
> +	es = malloc(sizeof(*es));
> +	if (!es)
> +		return -ENOMEM;
> +	memset(es, 0, sizeof(*es));
> +	FOR_ALL_EVENT_STRUCT_FIELDS(ADD_EVENT_FIELD);
> +	list_add_tail(&es->list, &arch_std_events);
> +	return 0;
> +out_free:
> +	FOR_ALL_EVENT_STRUCT_FIELDS(FREE_EVENT_FIELD);
> +	free(es);
> +	return -ENOMEM;
> +}
> +
>  static void print_events_table_suffix(FILE *outfp)
>  {
>  	fprintf(outfp, "{\n");
> @@ -391,6 +469,27 @@ static char *real_event(const char *name, char *event)
>  	return event;
>  }
>  
> +static int
> +try_fixup(const char *fn, char *arch_std, char **event, char **desc,
> +	  char **name, char **long_desc, char **pmu, char **filter,
> +	  char **perpkg, char **unit, char **metric_expr, char **metric_name,
> +	  char **metric_group)
> +{
> +	/* try to find matching event from arch standard values */
> +	struct event_struct *es;
> +
> +	list_for_each_entry(es, &arch_std_events, list) {
> +		if (!strcmp(arch_std, es->event+sizeof(EVENT_PREFIX))) {

I spent some time figuring out how this can work when there's on '=' in EVENT_PREFIX
is this because sizeof returns +1 size for NULL char also?

thanks,
jirka

  reply	other threads:[~2018-02-27  9:48 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 16:05 [PATCH v2 00/11] perf events patches for improved ARM64 support John Garry
2018-02-23 16:05 ` John Garry
2018-02-23 16:05 ` [PATCH v2 01/11] perf vendor events: drop incomplete multiple mapfile support John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 02/11] perf vendor events: fix error code in json_events() John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 03/11] perf vendor events: drop support for unused topic directories John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 04/11] perf vendor events: add support for pmu events vendor subdirectory John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 05/11] perf vendor events arm64: Relocate ThunderX2 JSON to cavium subdirectory John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 06/11] perf vendor events arm64: Relocate Cortex A53 JSONs to arm subdirectory John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 07/11] perf vendor events: add support for arch standard events John Garry
2018-02-23 16:05   ` John Garry
2018-02-27  9:48   ` Jiri Olsa [this message]
2018-02-27  9:48     ` Jiri Olsa
2018-02-27  9:58     ` John Garry
2018-02-27  9:58       ` John Garry
2018-02-23 16:05 ` [PATCH v2 08/11] perf vendor events arm64: add armv8-recommended.json John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 09/11] perf vendor events arm64: fixup ThunderX2 to use recommended events John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 10/11] perf vendor events arm64: fixup A53 " John Garry
2018-02-23 16:05   ` John Garry
2018-02-23 16:05 ` [PATCH v2 11/11] perf vendor events arm64: add HiSilicon hip08 JSON file John Garry
2018-02-23 16:05   ` John Garry
2018-02-27  9:50 ` [PATCH v2 00/11] perf events patches for improved ARM64 support Jiri Olsa
2018-02-27  9:50   ` Jiri Olsa
2018-02-27 10:03   ` John Garry
2018-02-27 10:03     ` John Garry
2018-03-02  8:24   ` John Garry
2018-03-02  8:24     ` John Garry
2018-03-02  8:45     ` Ganapatrao Kulkarni
2018-03-02  8:45       ` Ganapatrao Kulkarni
2018-03-02 16:05     ` William Cohen
2018-03-02 16:05       ` William Cohen
2018-03-02 16:35       ` Ganapatrao Kulkarni
2018-03-02 16:35         ` Ganapatrao Kulkarni
2018-03-02 16:40         ` John Garry
2018-03-02 16:40           ` John Garry
2018-03-02 23:38         ` William Cohen
2018-03-02 23:38           ` William Cohen
2018-03-05 11:24           ` John Garry
2018-03-05 11:24             ` John Garry
2018-03-05 15:39             ` William Cohen
2018-03-05 15:39               ` William Cohen
2018-03-05 16:28               ` John Garry
2018-03-05 16:28                 ` John Garry

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=20180227094848.GF21033@krava \
    --to=jolsa@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.