Re: [PATCH 2/7] perf: Create a symlink for a PMU

Andi Kleen
2021-06-25T14:49:40Z

> Device names will change, that's always a given, as the kernel can never
> always make them the same. That's why userspace needs to scan the bus
> for all devices and then pick out the one that it wants to look at.

In perf the tool doesn't normally know what devices (= pmu) the users
want to look at. It's all specified on the command line depending on
what events you want to measure. There's no way for the tool to figure
that out on its own.

> Don't hard-encode device names into userspace tools, that way lies
> madness.

There's no hard coding in the tools (or at least not for the non json
event list case). It all comes from the command line. But that is where
the problem comes from.

>
>> Anyways thinking about it if Greg doesn't want symlinks (even though sysfs
>> already has symlinks elsewhere), maybe we could just create two devices
>> without symlinks. Kan, do you think that would work?
> Do not have 2 different structures represent the same hardware device,
> that too is a shortcut to madness.
>
> What prevents userspace from handling device names changing today? Why
> are you forcing userspace to pick a specific device name at all?

The way the perf tool works is that you have to specify the names on the
command line:

perf stat -a -e uncore_cha/event=1/ ...

With the numeric identifiers it would be

perf stat -a -e uncore_type_X_Y/event=1/

The tool handles it all abstractly.

So yes the user tools itself can handle it. But the problem is that it
is directly exposed to the users, so the users would need to change all
their scripts when switching between the two cases. That is what we're
trying to avoid -- provide them a way that works on both.

-Andi