Re: [PATCH v1] perf evlist: Force adding default events only to core PMUs

From: Linus Torvalds
Date: Tue May 28 2024 - 16:00:39 EST


On Tue, 28 May 2024 at 12:44, Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> wrote:
>
> For 'perf record' we're asking for sampling, if the event has the name
> specified and can't be sampled, skip it, warn the user and even so
> only if verbose mode is asked, something like:

Yes. I think that's the right rule in general.

However, the more I have looked at this case, the more I am also
convinced that "cycles" as a name is special.

It's literally documented to be an alias for cpu-cycles, both in
examples and in "perf list" output, and that's what the usage is.

So even if you were to have some other PMU in the system that had a
"cycles" thing, if it's not a core event but some other cycles
("uncore", bus cycles, bicycles, whatever), it shouldn't be used even
if it could be used for profiling.

You'd have to use the full PMU name and actually list it out if you
want to use a non-core counter named "cycles".

And yes, we even have some documentation that says exactly that:

"e.g usage::

perf stat -a -e arm_dsu_0/cycles/"

So this isn't even anything new or ambiguous. This is just how things
*ARE*, and absolutely have to be.

Linus