Re: [PATCH 08/10] perf, tools: Expand PMU events by prefix match

From: Jiri Olsa
Date: Mon Oct 17 2016 - 07:40:45 EST


On Thu, Oct 13, 2016 at 02:15:30PM -0700, Andi Kleen wrote:

SNIP

> diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
> index 3a5196380609..790f0dd598b9 100644
> --- a/tools/perf/util/parse-events.y
> +++ b/tools/perf/util/parse-events.y
> @@ -224,11 +224,34 @@ event_pmu:
> PE_NAME opt_event_config
> {
> struct parse_events_evlist *data = _data;
> - struct list_head *list;
> + struct list_head *list, *orig_terms, *terms;
> +
> + if (parse_events_copy_term_list($2, &orig_terms))
> + YYABORT;
>
> ALLOC_LIST(list);
> - ABORT_ON(parse_events_add_pmu(data, list, $1, $2));
> + if (parse_events_add_pmu(data, list, $1, $2)) {
> + struct perf_pmu *pmu = NULL;
> + int ok = 0;
> +
> + while ((pmu = perf_pmu__scan(pmu)) != NULL) {
> + char *name = pmu->name;
> +
> + if (!strncmp(name, "uncore_", 7))
> + name += 7;

so there's a special treatment for uncore events,
what if user says 'uncore_box/..' then?


> + if (!strncmp($1, name, strlen($1))) {
> + if (parse_events_copy_term_list(orig_terms, &terms))
> + YYABORT;
> + if (!parse_events_add_pmu(data, list, pmu->name, terms))
> + ok++;

so we're ok if some of the events is not added?
do we warn at least?

thanks,
jirka