perf test: Parse events workaround for dash/minus
Ian Rogers
reviewerPATCH 1/1 perf test: Parse events workaround for dash/minus
Skip an event configuration for event names with a dash/minus in them. Events with a dash/minus in their name cause parsing issues as legacy encoding of events would use a dash/minus as a separator. The parser separates events with dashes into prefixes and suffixes and then recombines them. Unfortunately if an event has part of its name that matches a legacy token then the recombining fails. This is seen for branch-brs where branch is a legacy token. branch-brs was introduced to sysfs in:
https://lore.kernel.org/all/[email protected]/
The failure is shown below as well as the workaround to use a config where the dash/minus isn't treated specially:
```
$ perf stat -e branch-brs true
event syntax error: 'branch-brs'
\___ parser error
$ perf stat -e cpu/branch-brs/ true
Performance counter stats for 'true':
46,179 cpu/branch-brs/
```--- tools/perf/tests/parse-events.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
tools/perf/tests/parse-events.c +13 -0
@@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtestpr_debug ("Test PMU event failed for '%s'" , name); ret =combine_test_results (ret, test_ret); } +/* +* Names containing '-' are recognized as prefixes and suffixes +* due to '-' being a legacy PMU separator. This fails when the +* prefix or suffix collides with an existing legacy token. For +* example, branch-brs has a prefix (branch) that collides with +* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix +* isn't expected after this. As event names in the config +* slashes are allowed a '-' in the name we check this works +* above. +*/ +if (strchr (ent->d_name,'-' )) +continue ; +snprintf (name,sizeof (name),"%s:u,cpu/event=%s/u" , ent->d_name, ent->d_name); e.name = name; e.check = test__checkevent_pmu_events_mix;
Signature · 1 line
2.38.0.rc1.362.ged0d419d3c-goog
Quoted 34 lines · Ian Rogers
Skip an event configuration for event names with a dash/minus in them. Events with a dash/minus in their name cause parsing issues as legacy encoding of events would use a dash/minus as a separator. The parser separates events with dashes into prefixes and suffixes and then recombines them. Unfortunately if an event has part of its name that matches a legacy token then the recombining fails. This is seen for branch-brs where branch is a legacy token. branch-brs was introduced to sysfs in:
https://lore.kernel.org/all/[email protected]/
The failure is shown below as well as the workaround to use a config where the dash/minus isn't treated specially:``` $ perf stat -e branch-brs true event syntax error: 'branch-brs' \___ parser error $ perf stat -e cpu/branch-brs/ true Performance counter stats for 'true': 46,179 cpu/branch-brs/ ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/parse-events.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)tools/perf/tests/parse-events.c +0
-0
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2239
Quoted 3 lines
tools/perf/tests/parse-events.c +0
-0@@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtestpr_debug ("Test PMU event failed for '%s'" , name); ret =combine_test_results (ret, test_ret);
Hi Ian,
}
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
Quoted 7 lines
tools/perf/tests/parse-events.c +7
-0+/* +* Names containing '-' are recognized as prefixes and suffixes +* due to '-' being a legacy PMU separator. This fails when the +* prefix or suffix collides with an existing legacy token. For +* example, branch-brs has a prefix (branch) that collides with +* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix +* isn't expected after this.
OK, so you want to skip anything with '-'. Will we now miss out on events which contain a '-' but don't clash with an existing legacy token?
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 3 lines
tools/perf/tests/parse-events.c +2
-0As event names in the config + * slashes are allowed a '-' in the name we check this works + * above.
Sorry, I can't follow what you mean here. Do you mean that "cpu/branch-brs/" works ok and we continue to test it?
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2251
Quoted 3 lines
tools/perf/tests/parse-events.c +3
-0+*/ +if (strchr (ent->d_name,'-' )) +continue ;
Thanks,
John
Quoted 4 lines
tools/perf/tests/parse-events.c +1
-0+snprintf (name,sizeof (name),"%s:u,cpu/event=%s/u" , ent->d_name, ent->d_name); e.name = name;e.check = test__checkevent_pmu_events_mix;
Ian Rogers
reviewerQuoted 51 lines · John Garry
Quoted 34 lines · Ian Rogers
Skip an event configuration for event names with a dash/minus in them. Events with a dash/minus in their name cause parsing issues as legacy encoding of events would use a dash/minus as a separator. The parser separates events with dashes into prefixes and suffixes and then recombines them. Unfortunately if an event has part of its name that matches a legacy token then the recombining fails. This is seen for branch-brs where branch is a legacy token. branch-brs was introduced to sysfs in:
https://lore.kernel.org/all/[email protected]/
The failure is shown below as well as the workaround to use a config where the dash/minus isn't treated specially:``` $ perf stat -e branch-brs true event syntax error: 'branch-brs' \___ parser error $ perf stat -e cpu/branch-brs/ true Performance counter stats for 'true': 46,179 cpu/branch-brs/ ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/parse-events.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)tools/perf/tests/parse-events.c +0
-0tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2239
Quoted 3 lines
tools/perf/tests/parse-events.c +0
-0@@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtestpr_debug ("Test PMU event failed for '%s'" , name); ret =combine_test_results (ret, test_ret);Hi Ian,
}
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
Quoted 7 lines
tools/perf/tests/parse-events.c +7
-0+/* +* Names containing '-' are recognized as prefixes and suffixes +* due to '-' being a legacy PMU separator. This fails when the +* prefix or suffix collides with an existing legacy token. For +* example, branch-brs has a prefix (branch) that collides with +* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix +* isn't expected after this.
Quoted 2 lines
OK, so you want to skip anything with '-'. Will we now miss out on events which contain a '-' but don't clash with an existing legacy token?
Yes. The long term solution here is to ditch the current parse event code and its legacy support. An idea is to create a simplified parser as part of libperf2 (libperf but with a libbpf style license), use the new parser for metrics and events. In the events case, if the new parser fails then use the legacy parser and its weird handling of dashes.
Quoted 6 lines
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 3 lines
tools/perf/tests/parse-events.c +2
-0As event names in the config + * slashes are allowed a '-' in the name we check this works + * above.Sorry, I can't follow what you mean here. Do you mean that "cpu/branch-brs/" works ok and we continue to test it?
Yep, as shown in the commit message. The comment isn't great, it should be worded something like:
If an event name is in the config slashes, such as cpu/branch-brs/, a '-' in the name works as the dash doesn't separate the parts of the name. This continues to be tested above.
Quoted 1 line
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 1 line
tools/perf/tests/parse-events.c +1
-0+* above.
Thanks,
Ian
Quoted 12 lines
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2251
Quoted 3 lines
tools/perf/tests/parse-events.c +3
-0+*/ +if (strchr (ent->d_name,'-' )) +continue ;Thanks,
JohnQuoted 4 lines
tools/perf/tests/parse-events.c +1
-0+snprintf (name,sizeof (name),"%s:u,cpu/event=%s/u" , ent->d_name, ent->d_name); e.name = name; e.check = test__checkevent_pmu_events_mix;
Ian Rogers
reviewerQuoted 70 lines · Ian Rogers
Quoted 51 lines · John Garry
Quoted 34 lines · Ian Rogers
Skip an event configuration for event names with a dash/minus in them. Events with a dash/minus in their name cause parsing issues as legacy encoding of events would use a dash/minus as a separator. The parser separates events with dashes into prefixes and suffixes and then recombines them. Unfortunately if an event has part of its name that matches a legacy token then the recombining fails. This is seen for branch-brs where branch is a legacy token. branch-brs was introduced to sysfs in:
https://lore.kernel.org/all/[email protected]/
The failure is shown below as well as the workaround to use a config where the dash/minus isn't treated specially:``` $ perf stat -e branch-brs true event syntax error: 'branch-brs' \___ parser error $ perf stat -e cpu/branch-brs/ true Performance counter stats for 'true': 46,179 cpu/branch-brs/ ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/parse-events.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)tools/perf/tests/parse-events.c +0
-0tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2239
Quoted 3 lines
tools/perf/tests/parse-events.c +0
-0@@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtestpr_debug ("Test PMU event failed for '%s'" , name); ret =combine_test_results (ret, test_ret);Hi Ian,
}
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
Quoted 7 lines
tools/perf/tests/parse-events.c +7
-0+/* +* Names containing '-' are recognized as prefixes and suffixes +* due to '-' being a legacy PMU separator. This fails when the +* prefix or suffix collides with an existing legacy token. For +* example, branch-brs has a prefix (branch) that collides with +* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix +* isn't expected after this. Quoted 2 lines
OK, so you want to skip anything with '-'. Will we now miss out on events which contain a '-' but don't clash with an existing legacy token?
Yes. The long term solution here is to ditch the current parse event code and its legacy support. An idea is to create a simplified parser as part of libperf2 (libperf but with a libbpf style license), use the new parser for metrics and events. In the events case, if the new parser fails then use the legacy parser and its weird handling of dashes.
Quoted 6 lines
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 3 lines
tools/perf/tests/parse-events.c +2
-0As event names in the config + * slashes are allowed a '-' in the name we check this works + * above.Sorry, I can't follow what you mean here. Do you mean that "cpu/branch-brs/" works ok and we continue to test it?
Quoted 6 lines
Yep, as shown in the commit message. The comment isn't great, it should be worded something like:
If an event name is in the config slashes, such as cpu/branch-brs/, a '-' in the name works as the dash doesn't separate the parts of the name. This continues to be tested above.
Ping. It'd be nice to merge this as otherwise we have a perf test failure on AMD.
Thanks,
Ian
Quoted 17 lines
Quoted 1 line
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 1 line
tools/perf/tests/parse-events.c +1
-0+* above. Thanks,
IanQuoted 12 lines
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2251
Quoted 3 lines
tools/perf/tests/parse-events.c +3
-0+*/ +if (strchr (ent->d_name,'-' )) +continue ;Thanks,
JohnQuoted 4 lines
tools/perf/tests/parse-events.c +1
-0+snprintf (name,sizeof (name),"%s:u,cpu/event=%s/u" , ent->d_name, ent->d_name); e.name = name; e.check = test__checkevent_pmu_events_mix;
Arnaldo Carvalho de Melo
maintainerEm Fri, Oct 28, 2022 at 10:55:14AM -0700, Ian Rogers escreveu:
Quoted 74 lines · Ian Rogers
Quoted 73 lines · John Garry
Quoted 51 lines · Ian Rogers
Quoted 34 lines
Skip an event configuration for event names with a dash/minus in them. Events with a dash/minus in their name cause parsing issues as legacy encoding of events would use a dash/minus as a separator. The parser separates events with dashes into prefixes and suffixes and then recombines them. Unfortunately if an event has part of its name that matches a legacy token then the recombining fails. This is seen for branch-brs where branch is a legacy token. branch-brs was introduced to sysfs in:
https://lore.kernel.org/all/[email protected]/
The failure is shown below as well as the workaround to use a config where the dash/minus isn't treated specially:``` $ perf stat -e branch-brs true event syntax error: 'branch-brs' \___ parser error $ perf stat -e cpu/branch-brs/ true Performance counter stats for 'true': 46,179 cpu/branch-brs/ ```Signed-off-by Ian Rogers <[email protected]>--- tools/perf/tests/parse-events.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)tools/perf/tests/parse-events.c +0
-0tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2239
Quoted 3 lines
tools/perf/tests/parse-events.c +0
-0@@ -2237,6 +2237,19 @@ static int test__pmu_events(struct test_suite *test __maybe_unused, int subtestpr_debug ("Test PMU event failed for '%s'" , name); ret =combine_test_results (ret, test_ret);Hi Ian,
}
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest
Quoted 7 lines
tools/perf/tests/parse-events.c +7
-0+/* +* Names containing '-' are recognized as prefixes and suffixes +* due to '-' being a legacy PMU separator. This fails when the +* prefix or suffix collides with an existing legacy token. For +* example, branch-brs has a prefix (branch) that collides with +* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix +* isn't expected after this. Quoted 2 lines
OK, so you want to skip anything with '-'. Will we now miss out on events which contain a '-' but don't clash with an existing legacy token?
Yes. The long term solution here is to ditch the current parse event code and its legacy support. An idea is to create a simplified parser as part of libperf2 (libperf but with a libbpf style license), use the new parser for metrics and events. In the events case, if the new parser fails then use the legacy parser and its weird handling of dashes.
Quoted 6 lines
tools/perf/tests/parse-events.c static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest · line 2248
Quoted 3 lines
tools/perf/tests/parse-events.c +2
-0As event names in the config + * slashes are allowed a '-' in the name we check this works + * above.Sorry, I can't follow what you mean here. Do you mean that "cpu/branch-brs/" works ok and we continue to test it?
Yep, as shown in the commit message. The comment isn't great, it should be worded something like:
Quoted 6 lines
Quoted 3 lines
If an event name is in the config slashes, such as cpu/branch-brs/, a '-' in the name works as the dash doesn't separate the parts of the name. This continues to be tested above.
Ping. It'd be nice to merge this as otherwise we have a perf test failure on AMD.
I added it for perf/core, i.e. 6.2.
Thanks,
- Arnaldo