Re: [PATCH v2] perf: Add support for exclusive groups/events
On Wed, Oct 14, 2020 at 12:22:12PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Oct 14, 2020 at 07:42:55AM -0700, Andi Kleen escreveu: > > Peter suggested that using the exclusive mode in perf could > > avoid some problems with bad scheduling of groups. Exclusive > > is implemented in the kernel, but wasn't exposed by the perf tool, > > so hard to use without custom low level API users. > > > > Add support for marking groups or events with :e for exclusive > > in the perf tool. The implementation is basically the same as the > > existing pinned attribute. > > > > Cc: pet...@infradead.org > > Signed-off-by: Andi Kleen > > Jiri, I'm taking you "I'm ok" with this as an Acked-by, thanks yes Acked-by: Jiri Olsa thanks, jirka > > - Arnaldo > > > > -- > > > > v2: Update check_modifier too (Jiri) > > --- > > tools/perf/Documentation/perf-list.txt | 1 + > > tools/perf/tests/parse-events.c| 58 +- > > tools/perf/util/parse-events.c | 11 - > > tools/perf/util/parse-events.l | 2 +- > > 4 files changed, 68 insertions(+), 4 deletions(-) > > > > diff --git a/tools/perf/Documentation/perf-list.txt > > b/tools/perf/Documentation/perf-list.txt > > index 10ed539a8859..4c7db1da8fcc 100644 > > --- a/tools/perf/Documentation/perf-list.txt > > +++ b/tools/perf/Documentation/perf-list.txt > > @@ -58,6 +58,7 @@ counted. The following modifiers exist: > > S - read sample value (PERF_SAMPLE_READ) > > D - pin the event to the PMU > > W - group is weak and will fallback to non-group if not schedulable, > > + e - group or event are exclusive and do not share the PMU > > > > The 'p' modifier can be used for specifying how precise the instruction > > address should be. The 'p' modifier can be specified multiple times: > > diff --git a/tools/perf/tests/parse-events.c > > b/tools/perf/tests/parse-events.c > > index 7f9f87a470c3..7411dd4d76cf 100644 > > --- a/tools/perf/tests/parse-events.c > > +++ b/tools/perf/tests/parse-events.c > > @@ -557,6 +557,7 @@ static int test__checkevent_pmu_events(struct evlist > > *evlist) > > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); > > > > return 0; > > } > > @@ -575,6 +576,7 @@ static int test__checkevent_pmu_events_mix(struct > > evlist *evlist) > > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); > > > > /* cpu/pmu-event/u*/ > > evsel = evsel__next(evsel); > > @@ -587,6 +589,7 @@ static int test__checkevent_pmu_events_mix(struct > > evlist *evlist) > > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned); > > > > return 0; > > } > > @@ -1277,6 +1280,49 @@ static int test__pinned_group(struct evlist *evlist) > > return 0; > > } > > > > +static int test__checkevent_exclusive_modifier(struct evlist *evlist) > > +{ > > + struct evsel *evsel = evlist__first(evlist); > > + > > + TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); > > + TEST_ASSERT_VAL("wrong exclude_kernel", > > evsel->core.attr.exclude_kernel); > > + TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > > + TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); > > + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); > > + > > + return test__checkevent_symbolic_name(evlist); > > +} > > + > > +static int test__exclusive_group(struct evlist *evlist) > > +{ > > + struct evsel *evsel, *leader; > > + > > + TEST_ASSERT_VAL("wrong number of entries", 3 == > > evlist->core.nr_entries); > > + > > + /* cycles - group leader */ > > + evsel = leader = evlist__first(evlist); > > + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == > > evsel->core.attr.type); > > + TEST_ASSERT_VAL("wrong config", > > + PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config); > > + TEST_ASSERT_VAL("wrong group name", !evsel->group_name); > > + TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); > > + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); > > + > > + /* cache-misses - can not be pinned, but will go on with the leader */ > > + evsel = evsel__next(evsel); > > + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == > > evsel->core.attr.type); > > + TEST_ASSERT_VAL("wrong config", > > +
Re: [PATCH v2] perf: Add support for exclusive groups/events
Em Wed, Oct 14, 2020 at 07:42:55AM -0700, Andi Kleen escreveu: > Peter suggested that using the exclusive mode in perf could > avoid some problems with bad scheduling of groups. Exclusive > is implemented in the kernel, but wasn't exposed by the perf tool, > so hard to use without custom low level API users. > > Add support for marking groups or events with :e for exclusive > in the perf tool. The implementation is basically the same as the > existing pinned attribute. > > Cc: pet...@infradead.org > Signed-off-by: Andi Kleen Jiri, I'm taking you "I'm ok" with this as an Acked-by, thanks - Arnaldo > -- > > v2: Update check_modifier too (Jiri) > --- > tools/perf/Documentation/perf-list.txt | 1 + > tools/perf/tests/parse-events.c| 58 +- > tools/perf/util/parse-events.c | 11 - > tools/perf/util/parse-events.l | 2 +- > 4 files changed, 68 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/Documentation/perf-list.txt > b/tools/perf/Documentation/perf-list.txt > index 10ed539a8859..4c7db1da8fcc 100644 > --- a/tools/perf/Documentation/perf-list.txt > +++ b/tools/perf/Documentation/perf-list.txt > @@ -58,6 +58,7 @@ counted. The following modifiers exist: > S - read sample value (PERF_SAMPLE_READ) > D - pin the event to the PMU > W - group is weak and will fallback to non-group if not schedulable, > + e - group or event are exclusive and do not share the PMU > > The 'p' modifier can be used for specifying how precise the instruction > address should be. The 'p' modifier can be specified multiple times: > diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c > index 7f9f87a470c3..7411dd4d76cf 100644 > --- a/tools/perf/tests/parse-events.c > +++ b/tools/perf/tests/parse-events.c > @@ -557,6 +557,7 @@ static int test__checkevent_pmu_events(struct evlist > *evlist) > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); > > return 0; > } > @@ -575,6 +576,7 @@ static int test__checkevent_pmu_events_mix(struct evlist > *evlist) > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); > > /* cpu/pmu-event/u*/ > evsel = evsel__next(evsel); > @@ -587,6 +589,7 @@ static int test__checkevent_pmu_events_mix(struct evlist > *evlist) > TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); > TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned); > > return 0; > } > @@ -1277,6 +1280,49 @@ static int test__pinned_group(struct evlist *evlist) > return 0; > } > > +static int test__checkevent_exclusive_modifier(struct evlist *evlist) > +{ > + struct evsel *evsel = evlist__first(evlist); > + > + TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); > + TEST_ASSERT_VAL("wrong exclude_kernel", > evsel->core.attr.exclude_kernel); > + TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); > + TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); > + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); > + > + return test__checkevent_symbolic_name(evlist); > +} > + > +static int test__exclusive_group(struct evlist *evlist) > +{ > + struct evsel *evsel, *leader; > + > + TEST_ASSERT_VAL("wrong number of entries", 3 == > evlist->core.nr_entries); > + > + /* cycles - group leader */ > + evsel = leader = evlist__first(evlist); > + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == > evsel->core.attr.type); > + TEST_ASSERT_VAL("wrong config", > + PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config); > + TEST_ASSERT_VAL("wrong group name", !evsel->group_name); > + TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); > + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); > + > + /* cache-misses - can not be pinned, but will go on with the leader */ > + evsel = evsel__next(evsel); > + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == > evsel->core.attr.type); > + TEST_ASSERT_VAL("wrong config", > + PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config); > + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); > + > + /* branch-misses - ditto */ > + evsel = evsel__next(evsel); > + TEST_ASSERT_VAL("wrong config", > +
[PATCH v2] perf: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some problems with bad scheduling of groups. Exclusive is implemented in the kernel, but wasn't exposed by the perf tool, so hard to use without custom low level API users. Add support for marking groups or events with :e for exclusive in the perf tool. The implementation is basically the same as the existing pinned attribute. Cc: pet...@infradead.org Signed-off-by: Andi Kleen -- v2: Update check_modifier too (Jiri) --- tools/perf/Documentation/perf-list.txt | 1 + tools/perf/tests/parse-events.c| 58 +- tools/perf/util/parse-events.c | 11 - tools/perf/util/parse-events.l | 2 +- 4 files changed, 68 insertions(+), 4 deletions(-) diff --git a/tools/perf/Documentation/perf-list.txt b/tools/perf/Documentation/perf-list.txt index 10ed539a8859..4c7db1da8fcc 100644 --- a/tools/perf/Documentation/perf-list.txt +++ b/tools/perf/Documentation/perf-list.txt @@ -58,6 +58,7 @@ counted. The following modifiers exist: S - read sample value (PERF_SAMPLE_READ) D - pin the event to the PMU W - group is weak and will fallback to non-group if not schedulable, + e - group or event are exclusive and do not share the PMU The 'p' modifier can be used for specifying how precise the instruction address should be. The 'p' modifier can be specified multiple times: diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index 7f9f87a470c3..7411dd4d76cf 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -557,6 +557,7 @@ static int test__checkevent_pmu_events(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); return 0; } @@ -575,6 +576,7 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); /* cpu/pmu-event/u*/ evsel = evsel__next(evsel); @@ -587,6 +589,7 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned); + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned); return 0; } @@ -1277,6 +1280,49 @@ static int test__pinned_group(struct evlist *evlist) return 0; } +static int test__checkevent_exclusive_modifier(struct evlist *evlist) +{ + struct evsel *evsel = evlist__first(evlist); + + TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); + TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); + TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); + TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip); + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); + + return test__checkevent_symbolic_name(evlist); +} + +static int test__exclusive_group(struct evlist *evlist) +{ + struct evsel *evsel, *leader; + + TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->core.nr_entries); + + /* cycles - group leader */ + evsel = leader = evlist__first(evlist); + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); + TEST_ASSERT_VAL("wrong config", + PERF_COUNT_HW_CPU_CYCLES == evsel->core.attr.config); + TEST_ASSERT_VAL("wrong group name", !evsel->group_name); + TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); + TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive); + + /* cache-misses - can not be pinned, but will go on with the leader */ + evsel = evsel__next(evsel); + TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type); + TEST_ASSERT_VAL("wrong config", + PERF_COUNT_HW_CACHE_MISSES == evsel->core.attr.config); + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); + + /* branch-misses - ditto */ + evsel = evsel__next(evsel); + TEST_ASSERT_VAL("wrong config", + PERF_COUNT_HW_BRANCH_MISSES == evsel->core.attr.config); + TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive); + + return 0; +} static int test__checkevent_breakpoint_len(struct evlist *evlist) { struct evsel *evsel = evlist__first(evlist); @@ -1765,7