The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: kan.liang@intel.com
Cc: acme@kernel.org, linux-kernel@vger.kernel.org, ak@linux.intel.com
Subject: Re: [PATCH V5 2/3] perf tools: parse the pmu event prefix and surfix
Date: Thu, 11 Sep 2014 10:51:43 +0200	[thread overview]
Message-ID: <20140911085143.GB7326@krava.brq.redhat.com> (raw)
In-Reply-To: <1410371732-1185-2-git-send-email-kan.liang@intel.com>

On Wed, Sep 10, 2014 at 01:55:31PM -0400, kan.liang@intel.com wrote:

SNIP

> +	struct perf_pmu_event_symbol *pmu2 =
> +			(struct perf_pmu_event_symbol *) p2;
> +
> +	return strcmp(pmu1->symbol, pmu2->symbol);
> +}
> +
> +/*
> + * Read the pmu events list from sysfs
> + * Save it into perf_pmu_events_list
> + */
> +static void perf_pmu__parse_init(void)
> +{
> +
> +	struct perf_pmu *pmu = NULL;
> +	struct perf_pmu_alias *alias;
> +	int len = 0;
> +
> +	while ((pmu = perf_pmu__scan(pmu)) != NULL)
> +		list_for_each_entry(alias, &pmu->aliases, list) {
> +			if (!strcmp(pmu->name, "cpu")) {
> +				if (strchr(alias->name, '-'))
> +					len++;
> +				len++;
> +			}
> +	}
> +	if (len == 0)
> +		return;

s oif 'len' is 0 we will scan all the time? maybe we want some
separate 'init' variable..


> +	perf_pmu_events_list =
> +		malloc(sizeof(struct perf_pmu_event_symbol) * len);
> +	perf_pmu_events_list_num = len;
> +
> +	pmu = NULL;
> +	len = 0;

SNIP

> +	qsort(perf_pmu_events_list, len,
> +		sizeof(struct perf_pmu_event_symbol), comp_pmu);
> +
> +}
> +
> +static void perf_pmu__parse_cleanup(void)
> +{
> +	if (!perf_pmu_events_list_num) {

should this be 'if (perf_pmu_events_list_num)' ?

could you also please write automated test for this feature?

thanks,
jirka

> +		struct perf_pmu_event_symbol *p;
> +		size_t i;
> +
> +		for (i = 0; i < perf_pmu_events_list_num; i++) {
> +			p = perf_pmu_events_list + i;
> +			free(p->symbol);
> +		}
> +		free(perf_pmu_events_list);
> +		perf_pmu_events_list = NULL;
> +		perf_pmu_events_list_num = 0;
> +	}
> +}
> +

SNIP

  parent reply	other threads:[~2014-09-11  8:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 17:55 [PATCH V5 1/3] Revert "perf tools: Default to cpu// for events v5" kan.liang
2014-09-10 17:55 ` [PATCH V5 2/3] perf tools: parse the pmu event prefix and surfix kan.liang
2014-09-11  8:46   ` Jiri Olsa
2014-09-11 13:31     ` Liang, Kan
2014-09-11 13:37       ` Jiri Olsa
2014-09-11  8:51   ` Jiri Olsa [this message]
2014-09-11 13:50     ` Liang, Kan
2014-09-11 14:53       ` Jiri Olsa
2014-09-10 17:55 ` [PATCH V5 3/3] perf tools: Add support to new style format of kernel PMU event kan.liang

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=20140911085143.GB7326@krava.brq.redhat.com \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.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