Commit 864bc8c9 authored by John Garry's avatar John Garry Committed by Arnaldo Carvalho de Melo

perf parse-events: Support event alias in form foo-bar-baz

Event aliasing for events whose name in the form foo-bar-baz is not
supported, while foo-bar, foo_bar_baz, and other combinations are, i.e.
two hyphens are not supported.

The HiSilicon D06 platform has events in such form:

  $ ./perf list sdir-home-migrate

  List of pre-defined events (to be used in -e):

  uncore hha:
    sdir-home-migrate
   [Unit: hisi_sccl,hha]

  $ sudo ./perf stat -e sdir-home-migrate
  event syntax error: 'sdir-home-migrate'
                          \___ parser error
  Run 'perf list' for a list of valid events

   Usage: perf stat [<options>] [<command>]

   -e, --event <event>event selector. use 'perf list' to list available events

To support, add an extra PMU event symbol type for "baz", and add a new
rule in the bison file.
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Qi Liu <liuqi115@huawei.com>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: linuxarm@huawei.com
Link: https://lore.kernel.org/r/1642432215-234089-2-git-send-email-john.garry@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3606c0e1
...@@ -2098,8 +2098,17 @@ static void perf_pmu__parse_init(void) ...@@ -2098,8 +2098,17 @@ static void perf_pmu__parse_init(void)
pmu = NULL; pmu = NULL;
while ((pmu = perf_pmu__scan(pmu)) != NULL) { while ((pmu = perf_pmu__scan(pmu)) != NULL) {
list_for_each_entry(alias, &pmu->aliases, list) { list_for_each_entry(alias, &pmu->aliases, list) {
if (strchr(alias->name, '-')) char *tmp = strchr(alias->name, '-');
if (tmp) {
char *tmp2 = NULL;
tmp2 = strchr(tmp + 1, '-');
len++; len++;
if (tmp2)
len++;
}
len++; len++;
} }
} }
...@@ -2119,8 +2128,20 @@ static void perf_pmu__parse_init(void) ...@@ -2119,8 +2128,20 @@ static void perf_pmu__parse_init(void)
list_for_each_entry(alias, &pmu->aliases, list) { list_for_each_entry(alias, &pmu->aliases, list) {
struct perf_pmu_event_symbol *p = perf_pmu_events_list + len; struct perf_pmu_event_symbol *p = perf_pmu_events_list + len;
char *tmp = strchr(alias->name, '-'); char *tmp = strchr(alias->name, '-');
char *tmp2 = NULL;
if (tmp != NULL) { if (tmp)
tmp2 = strchr(tmp + 1, '-');
if (tmp2) {
SET_SYMBOL(strndup(alias->name, tmp - alias->name),
PMU_EVENT_SYMBOL_PREFIX);
p++;
tmp++;
SET_SYMBOL(strndup(tmp, tmp2 - tmp), PMU_EVENT_SYMBOL_SUFFIX);
p++;
SET_SYMBOL(strdup(++tmp2), PMU_EVENT_SYMBOL_SUFFIX2);
len += 3;
} else if (tmp) {
SET_SYMBOL(strndup(alias->name, tmp - alias->name), SET_SYMBOL(strndup(alias->name, tmp - alias->name),
PMU_EVENT_SYMBOL_PREFIX); PMU_EVENT_SYMBOL_PREFIX);
p++; p++;
......
...@@ -53,6 +53,7 @@ enum perf_pmu_event_symbol_type { ...@@ -53,6 +53,7 @@ enum perf_pmu_event_symbol_type {
PMU_EVENT_SYMBOL, /* normal style PMU event */ PMU_EVENT_SYMBOL, /* normal style PMU event */
PMU_EVENT_SYMBOL_PREFIX, /* prefix of pre-suf style event */ PMU_EVENT_SYMBOL_PREFIX, /* prefix of pre-suf style event */
PMU_EVENT_SYMBOL_SUFFIX, /* suffix of pre-suf style event */ PMU_EVENT_SYMBOL_SUFFIX, /* suffix of pre-suf style event */
PMU_EVENT_SYMBOL_SUFFIX2, /* suffix of pre-suf2 style event */
}; };
struct perf_pmu_event_symbol { struct perf_pmu_event_symbol {
......
...@@ -149,6 +149,8 @@ static int pmu_str_check(yyscan_t scanner, struct parse_events_state *parse_stat ...@@ -149,6 +149,8 @@ static int pmu_str_check(yyscan_t scanner, struct parse_events_state *parse_stat
return PE_PMU_EVENT_PRE; return PE_PMU_EVENT_PRE;
case PMU_EVENT_SYMBOL_SUFFIX: case PMU_EVENT_SYMBOL_SUFFIX:
return PE_PMU_EVENT_SUF; return PE_PMU_EVENT_SUF;
case PMU_EVENT_SYMBOL_SUFFIX2:
return PE_PMU_EVENT_SUF2;
case PMU_EVENT_SYMBOL: case PMU_EVENT_SYMBOL:
return parse_state->fake_pmu return parse_state->fake_pmu
? PE_PMU_EVENT_FAKE : PE_KERNEL_PMU_EVENT; ? PE_PMU_EVENT_FAKE : PE_KERNEL_PMU_EVENT;
......
...@@ -69,7 +69,7 @@ static void inc_group_count(struct list_head *list, ...@@ -69,7 +69,7 @@ static void inc_group_count(struct list_head *list,
%token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT
%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP %token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP
%token PE_ERROR %token PE_ERROR
%token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE %token PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
%token PE_ARRAY_ALL PE_ARRAY_RANGE %token PE_ARRAY_ALL PE_ARRAY_RANGE
%token PE_DRV_CFG_TERM %token PE_DRV_CFG_TERM
%type <num> PE_VALUE %type <num> PE_VALUE
...@@ -87,7 +87,7 @@ static void inc_group_count(struct list_head *list, ...@@ -87,7 +87,7 @@ static void inc_group_count(struct list_head *list,
%type <str> PE_MODIFIER_EVENT %type <str> PE_MODIFIER_EVENT
%type <str> PE_MODIFIER_BP %type <str> PE_MODIFIER_BP
%type <str> PE_EVENT_NAME %type <str> PE_EVENT_NAME
%type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE %type <str> PE_PMU_EVENT_PRE PE_PMU_EVENT_SUF PE_PMU_EVENT_SUF2 PE_KERNEL_PMU_EVENT PE_PMU_EVENT_FAKE
%type <str> PE_DRV_CFG_TERM %type <str> PE_DRV_CFG_TERM
%type <str> event_pmu_name %type <str> event_pmu_name
%destructor { free ($$); } <str> %destructor { free ($$); } <str>
...@@ -372,6 +372,19 @@ PE_KERNEL_PMU_EVENT opt_pmu_config ...@@ -372,6 +372,19 @@ PE_KERNEL_PMU_EVENT opt_pmu_config
$$ = list; $$ = list;
} }
| |
PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF '-' PE_PMU_EVENT_SUF2 sep_dc
{
struct list_head *list;
char pmu_name[128];
snprintf(pmu_name, sizeof(pmu_name), "%s-%s-%s", $1, $3, $5);
free($1);
free($3);
free($5);
if (parse_events_multi_pmu_add(_parse_state, pmu_name, NULL, &list) < 0)
YYABORT;
$$ = list;
}
|
PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc PE_PMU_EVENT_PRE '-' PE_PMU_EVENT_SUF sep_dc
{ {
struct list_head *list; struct list_head *list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment