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 v4 2/3] perf tools: parse the pmu event prefix and surfix
Date: Sat, 6 Sep 2014 21:38:49 +0200 [thread overview]
Message-ID: <20140906193848.GC6059@krava.brq.redhat.com> (raw)
In-Reply-To: <1409671770-17260-2-git-send-email-kan.liang@intel.com>
On Tue, Sep 02, 2014 at 11:29:29AM -0400, kan.liang@intel.com wrote:
> From: Kan Liang <kan.liang@intel.com>
SNIP
> + * Read the pmu events list from sysfs
> + * Save it into kernel_pmu_events_list
> + */
> +static void scan_kernel_pmu_events_list(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) {
Why do we need to call scan here? Looks like:
pmu = pmu_lookup("cpu")
should be enough.. and could be used below as well
> + if (!strcmp(pmu->name, "cpu")) {
> + if (strchr(alias->name, '-'))
> + len++;
> + len++;
> + }
> + }
> + if (len == 0)
> + return;
> + kernel_pmu_events_list =
> + malloc(sizeof(struct kernel_pmu_event_symbol) * len);
> + kernel_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 kernel_pmu_event_symbol *p =
> + kernel_pmu_events_list + len;
> + char *tmp = strchr(alias->name, '-');
> +
> + if (tmp != NULL) {
> + strlcpy(p->symbol, alias->name,
> + tmp - alias->name + 1);
> + p->type = KERNEL_PMU_EVENT_PREFIX;
> + tmp++;
> + p++;
> + strcpy(p->symbol, tmp);
> + p->type = KERNEL_PMU_EVENT_SUFFIX;
> + len += 2;
> + } else {
> + strcpy(p->symbol, alias->name);
> + p->type = KERNEL_PMU_EVENT;
> + len++;
> + }
> + }
> + }
> + qsort(kernel_pmu_events_list, len,
> + sizeof(struct kernel_pmu_event_symbol), comp_pmu);
> +
> +}
SNIP
thanks,
jirka
next prev parent reply other threads:[~2014-09-06 19:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-02 15:29 [PATCH v4 1/3] Revert "perf tools: Default to cpu// for events v5" kan.liang
2014-09-02 15:29 ` [PATCH v4 2/3] perf tools: parse the pmu event prefix and surfix kan.liang
2014-09-06 19:38 ` Jiri Olsa [this message]
2014-09-06 19:39 ` Jiri Olsa
2014-09-02 15:29 ` [PATCH v4 3/3] perf tools: Add support to new style format of kernel PMU event kan.liang
2014-09-06 19:39 ` Jiri Olsa
2014-09-06 19:39 ` Jiri Olsa
2014-09-08 15:09 ` Liang, Kan
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=20140906193848.GC6059@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
all inboxes | Powered by JetHome®