Re: [PATCH 2/6] perf: Support branch events logging

From: Andi Kleen
Date: Fri Apr 14 2023 - 18:47:40 EST



Yeah, don't do this. There is no guarantee what so ever you'll get any
of those events in the 0-3 range.


The kernel can simply force to 0-3 if LBR is enabled and the feature too. It's in Kan's patch

and it isn't particularly complicated.


You really *must* make then a group such that perf knows what events to
associated with the LBR event and constain them to the 0-3 range of
PMCs.

If you want multiplexing, simply create multiple groups with an LBR
event in them.


Well if you force groups then you require user space or a user which understands all the constraints

to create groups. I thought one of the basic ideas of perf was to be able to abstract those things.

There are tools today (e.g. the perf builtin metrics[1] and I believe others) that don't have enough

knowledge to set up real groups and rely on the kernel.  While they could be fixed it's a lot of work

(I do it in pmu-tools, and it's quite hairy code)


-Andi


[1] Given they are are not supported by perf record yet, but since perf script already supports

evaluating them they could be at some point, and then it would make sense to use them

with this feature too.