On Tue, Sep 02, 2014 at 11:29:29AM -0400, kan.li...@intel.com wrote:
> From: Kan Liang <kan.li...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to