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:46:59 +0200 [thread overview]
Message-ID: <20140911084659.GA7326@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:
> From: Kan Liang <kan.liang@intel.com>
>
SNIP
> return 0;
> }
>
> +static int
> +comp_pmu(const void *p1, const void *p2)
> +{
> + struct perf_pmu_event_symbol *pmu1 =
> + (struct perf_pmu_event_symbol *) p1;
> + 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;
> +
missing my previous comment being addressed:
---
Why do we need to call scan here? Looks like:
pmu = pmu_lookup("cpu")
should be enough.. and could be used below as well
---
or commented why not to do it..
jirka
> + 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;
> + perf_pmu_events_list =
> + malloc(sizeof(struct perf_pmu_event_symbol) * len);
> + perf_pmu_events_list_num = len;
> +
> + pmu = NULL;
> + len = 0;
> + while ((pmu = perf_pmu__scan(pmu)) != NULL)
> + list_for_each_entry(alias, &pmu->aliases, list) {
> + if (!strcmp(pmu->name, "cpu")) {
> + struct perf_pmu_event_symbol *p =
> + perf_pmu_events_list + len;
> + char *tmp = strchr(alias->name, '-');
> +
> + if (tmp != NULL) {
> + p->symbol =
> + malloc(tmp - alias->name + 1);
> + strlcpy(p->symbol, alias->name,
> + tmp - alias->name + 1);
> + p->type = KERNEL_PMU_EVENT_PREFIX;
> + tmp++;
> + p++;
> + p->symbol = malloc(strlen(tmp) + 1);
> + strcpy(p->symbol, tmp);
> + p->type = KERNEL_PMU_EVENT_SUFFIX;
> + len += 2;
> + } else {
> + p->symbol =
> + malloc(strlen(alias->name) + 1);
> + strcpy(p->symbol, alias->name);
> + p->type = KERNEL_PMU_EVENT;
> + len++;
> + }
> + }
> + }
> + qsort(perf_pmu_events_list, len,
> + sizeof(struct perf_pmu_event_symbol), comp_pmu);
> +
> +}
> +
SNIP
next prev parent reply other threads:[~2014-09-11 8:47 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 [this message]
2014-09-11 13:31 ` Liang, Kan
2014-09-11 13:37 ` Jiri Olsa
2014-09-11 8:51 ` Jiri Olsa
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=20140911084659.GA7326@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