]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
perf parse-events: Make X modifier more respectful of groups
authorIan Rogers <irogers@google.com>
Fri, 17 Oct 2025 23:03:57 +0000 (16:03 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 20 Oct 2025 04:05:37 +0000 (13:05 +0900)
commit800201997a509c298e74696da3586d82b1a2b6f4
treeac3e54fad773586d8e673ab989dc2e5d5b59a1aa
parentad83f3b7155db28e82de24dbaa1af2b8f5d972a3
perf parse-events: Make X modifier more respectful of groups

Events with an X modifier were reordered within a group, for example
slots was made the leader in:
```
$ perf record -e '{cpu/mem-stores/ppu,cpu/slots/uX}' -- sleep 1
```

Fix by making `dont_regroup` evsels always use their index for
sorting. Make the cur_leader, when fixing the groups, be that of
`dont_regroup` evsel so that the `dont_regroup` evsel doesn't become a
leader.

On a tigerlake this patch corrects this and meets expectations in:
```
$ perf stat -e '{cpu/mem-stores/,cpu/slots/uX}' -a -- sleep 0.1

 Performance counter stats for 'system wide':

        83,458,652      cpu/mem-stores/
     2,720,854,880      cpu/slots/uX

       0.103780587 seconds time elapsed

$ perf stat -e 'slots,slots:X' -a -- sleep 0.1

 Performance counter stats for 'system wide':

       732,042,247      slots                (48.96%)
       643,288,155      slots:X              (51.04%)

       0.102731018 seconds time elapsed
```

Closes: https://lore.kernel.org/lkml/18f20d38-070c-4e17-bc90-cf7102e1e53d@linux.intel.com/
Fixes: 035c17893082 ("perf parse-events: Add 'X' modifier to exclude an event from being regrouped")
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/parse-events.c