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

From: Liang, Kan
Date: Fri Jun 25 2021 - 11:03:25 EST




On 6/25/2021 10:49 AM, Andi Kleen wrote:

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.


We have an attribute "caps/pmu_name" for the core PMU. Maybe we should add it for uncore PMU as well. For example,

$ cat /sys/devices/uncore_type_0_0/caps/pmu_name
cha_0

Userspace tool can get clues about what type_0_0 is.

Thanks,
Kan