Re: [RESEND PATCH v2] perf tools: Ensure event leader stays at head of evlist after sorting
From: Arnaldo Carvalho de Melo
Date: Thu Jun 04 2026 - 10:20:04 EST
On Sat, May 09, 2026 at 11:52:44PM -0700, Namhyung Kim wrote:
> Hello,
>
> On Tue, May 05, 2026 at 02:19:00PM -0700, Chun-Tse Shao wrote:
> > From: Ian Rogers <irogers@xxxxxxxxxx>
> >
> > For evlist of a certain event/metric, the HEAD should be the event
> > leader. In some scenarios where uncore_xxx_0 does not exist, the event
> > leader is not the first element after sorting. For example, on my test
> > machine uncore_iio_0 does not exist, the event leader is uncore_iio_2.
> >
> > However, in `evlist__cmp`, it was reordered based on the PMU name, which
> > makes uncore_iio_1 the HEAD of evlist, breaking the following merge
> > logic in `evsel__merge_aliases`.
> >
> > The patch adds a loop at the end of
> > `parse_events__sort_events_and_fix_groups` to make sure the first
> > wildcard match is the earliest entry in the list, updating pointers
> > accordingly without breaking reordering detection.
> >
> > Tested on device lacks uncore_iio_0, and `perf test` looks good.
> >
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> > Signed-off-by: Chun-Tse Shao <ctshao@xxxxxxxxxx>
>
> Acked-by: Namhyung Kim <namhyung@xxxxxxxxxx>
Thanks, applied to perf-tools-next, for v7.2.
- Arnaldo