perf parse-events: Extra care around force grouped events
Perf metric (topdown) events on Intel Icelake+ machines require a
group, however, they may be next to events that don't require a group.
Consider:
cycles,slots,topdown-fe-bound
The cycles event needn't be grouped but slots and topdown-fe-bound need
grouping.
Prior to this change, as slots and topdown-fe-bound need a group forcing
and all events share the same PMU, slots and topdown-fe-bound would be
forced into a group with cycles.
This is a bug on two fronts, cycles wasn't supposed to be grouped and
cycles can't be a group leader with a perf metric event.
This change adds recognition that cycles isn't force grouped and so it
shouldn't be force grouped with slots and topdown-fe-bound.
Fixes: a90cc5a9ee
("perf evsel: Don't let evsel__group_pmu_name() traverse unsorted group")
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20230719001836.198363-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
341e0e9f59
commit
5c49b6c3f2
@ -2149,7 +2149,7 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
|
|||||||
int idx = 0, unsorted_idx = -1;
|
int idx = 0, unsorted_idx = -1;
|
||||||
struct evsel *pos, *cur_leader = NULL;
|
struct evsel *pos, *cur_leader = NULL;
|
||||||
struct perf_evsel *cur_leaders_grp = NULL;
|
struct perf_evsel *cur_leaders_grp = NULL;
|
||||||
bool idx_changed = false;
|
bool idx_changed = false, cur_leader_force_grouped = false;
|
||||||
int orig_num_leaders = 0, num_leaders = 0;
|
int orig_num_leaders = 0, num_leaders = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -2190,7 +2190,7 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
|
|||||||
const struct evsel *pos_leader = evsel__leader(pos);
|
const struct evsel *pos_leader = evsel__leader(pos);
|
||||||
const char *pos_pmu_name = pos->group_pmu_name;
|
const char *pos_pmu_name = pos->group_pmu_name;
|
||||||
const char *cur_leader_pmu_name, *pos_leader_pmu_name;
|
const char *cur_leader_pmu_name, *pos_leader_pmu_name;
|
||||||
bool force_grouped = arch_evsel__must_be_in_group(pos);
|
bool pos_force_grouped = arch_evsel__must_be_in_group(pos);
|
||||||
|
|
||||||
/* Reset index and nr_members. */
|
/* Reset index and nr_members. */
|
||||||
if (pos->core.idx != idx)
|
if (pos->core.idx != idx)
|
||||||
@ -2206,7 +2206,8 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
|
|||||||
cur_leader = pos;
|
cur_leader = pos;
|
||||||
|
|
||||||
cur_leader_pmu_name = cur_leader->group_pmu_name;
|
cur_leader_pmu_name = cur_leader->group_pmu_name;
|
||||||
if ((cur_leaders_grp != pos->core.leader && !force_grouped) ||
|
if ((cur_leaders_grp != pos->core.leader &&
|
||||||
|
(!pos_force_grouped || !cur_leader_force_grouped)) ||
|
||||||
strcmp(cur_leader_pmu_name, pos_pmu_name)) {
|
strcmp(cur_leader_pmu_name, pos_pmu_name)) {
|
||||||
/* Event is for a different group/PMU than last. */
|
/* Event is for a different group/PMU than last. */
|
||||||
cur_leader = pos;
|
cur_leader = pos;
|
||||||
@ -2216,9 +2217,14 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
|
|||||||
* group.
|
* group.
|
||||||
*/
|
*/
|
||||||
cur_leaders_grp = pos->core.leader;
|
cur_leaders_grp = pos->core.leader;
|
||||||
|
/*
|
||||||
|
* Avoid forcing events into groups with events that
|
||||||
|
* don't need to be in the group.
|
||||||
|
*/
|
||||||
|
cur_leader_force_grouped = pos_force_grouped;
|
||||||
}
|
}
|
||||||
pos_leader_pmu_name = pos_leader->group_pmu_name;
|
pos_leader_pmu_name = pos_leader->group_pmu_name;
|
||||||
if (strcmp(pos_leader_pmu_name, pos_pmu_name) || force_grouped) {
|
if (strcmp(pos_leader_pmu_name, pos_pmu_name) || pos_force_grouped) {
|
||||||
/*
|
/*
|
||||||
* Event's PMU differs from its leader's. Groups can't
|
* Event's PMU differs from its leader's. Groups can't
|
||||||
* span PMUs, so update leader from the group/PMU
|
* span PMUs, so update leader from the group/PMU
|
||||||
|
Loading…
Reference in New Issue
Block a user