diff options
| author | Ian Rogers <irogers@google.com> | 2025-07-18 20:05:16 -0700 | 
|---|---|---|
| committer | Namhyung Kim <namhyung@kernel.org> | 2025-07-24 13:41:35 -0700 | 
| commit | 8dcd27b1b8661f64e220bc26a499865261d5d0f1 (patch) | |
| tree | 19fa320c5436dc4b23b54dab76ff910c2a4ecb20 /tools/perf/util/parse-events.c | |
| parent | 5b546de9cc177936a3ed07d7d46ef072db4fdbab (diff) | |
perf parse-events: Fix missing slots for Intel topdown metric events
Topdown metric events require grouping with a slots event. In perf
metrics this is currently achieved by metrics adding an unnecessary
"0 * tma_info_thread_slots". New TMA metrics trigger optimizations of
the metric expression that removes the event and breaks the metric due
to the missing but required event. Add a pass immediately before
sorting and fixing parsed events, that insert a slots event if one is
missing. Update test expectations to match this.
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250719030517.1990983-15-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/util/parse-events.c')
| -rw-r--r-- | tools/perf/util/parse-events.c | 10 | 
1 files changed, 10 insertions, 0 deletions
| diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index fe2073c6b549..01fa8c80998b 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -2190,6 +2190,11 @@ static int evlist__cmp(void *_fg_idx, const struct list_head *l, const struct li  	return arch_evlist__cmp(lhs, rhs);  } +int __weak arch_evlist__add_required_events(struct list_head *list __always_unused) +{ +	return 0; +} +  static int parse_events__sort_events_and_fix_groups(struct list_head *list)  {  	int idx = 0, force_grouped_idx = -1; @@ -2201,6 +2206,11 @@ static int parse_events__sort_events_and_fix_groups(struct list_head *list)  	struct evsel *force_grouped_leader = NULL;  	bool last_event_was_forced_leader = false; +	/* On x86 topdown metrics events require a slots event. */ +	ret = arch_evlist__add_required_events(list); +	if (ret) +		return ret; +  	/*  	 * Compute index to insert ungrouped events at. Place them where the  	 * first ungrouped event appears. | 
