Skip to content

Commit 5c49b6c

Browse files
captain5050acmel
authored andcommitted
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: a90cc5a ("perf evsel: Don't let evsel__group_pmu_name() traverse unsorted group") Signed-off-by: Ian Rogers <[email protected]> Tested-by: Andi Kleen <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Xing Zhengjun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 341e0e9 commit 5c49b6c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tools/perf/util/parse-events.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,7 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
21492149
int idx = 0, unsorted_idx = -1;
21502150
struct evsel *pos, *cur_leader = NULL;
21512151
struct perf_evsel *cur_leaders_grp = NULL;
2152-
bool idx_changed = false;
2152+
bool idx_changed = false, cur_leader_force_grouped = false;
21532153
int orig_num_leaders = 0, num_leaders = 0;
21542154
int ret;
21552155

@@ -2190,7 +2190,7 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
21902190
const struct evsel *pos_leader = evsel__leader(pos);
21912191
const char *pos_pmu_name = pos->group_pmu_name;
21922192
const char *cur_leader_pmu_name, *pos_leader_pmu_name;
2193-
bool force_grouped = arch_evsel__must_be_in_group(pos);
2193+
bool pos_force_grouped = arch_evsel__must_be_in_group(pos);
21942194

21952195
/* Reset index and nr_members. */
21962196
if (pos->core.idx != idx)
@@ -2206,7 +2206,8 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
22062206
cur_leader = pos;
22072207

22082208
cur_leader_pmu_name = cur_leader->group_pmu_name;
2209-
if ((cur_leaders_grp != pos->core.leader && !force_grouped) ||
2209+
if ((cur_leaders_grp != pos->core.leader &&
2210+
(!pos_force_grouped || !cur_leader_force_grouped)) ||
22102211
strcmp(cur_leader_pmu_name, pos_pmu_name)) {
22112212
/* Event is for a different group/PMU than last. */
22122213
cur_leader = pos;
@@ -2216,9 +2217,14 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)
22162217
* group.
22172218
*/
22182219
cur_leaders_grp = pos->core.leader;
2220+
/*
2221+
* Avoid forcing events into groups with events that
2222+
* don't need to be in the group.
2223+
*/
2224+
cur_leader_force_grouped = pos_force_grouped;
22192225
}
22202226
pos_leader_pmu_name = pos_leader->group_pmu_name;
2221-
if (strcmp(pos_leader_pmu_name, pos_pmu_name) || force_grouped) {
2227+
if (strcmp(pos_leader_pmu_name, pos_pmu_name) || pos_force_grouped) {
22222228
/*
22232229
* Event's PMU differs from its leader's. Groups can't
22242230
* span PMUs, so update leader from the group/PMU

0 commit comments

Comments
 (0)