perf tools: Fix up some comments and code to properly use the event_source bus
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Feb 2025 13:40:56 +0000 (14:40 +0100)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 19 Feb 2025 21:23:43 +0000 (13:23 -0800)
In sysfs, the perf events are all located in
/sys/bus/event_source/devices/ but some places ended up hard-coding the
location to be at the root of /sys/devices/ which could be very risky as
you do not exactly know what type of device you are accessing in sysfs
at that location.

So fix this all up by properly pointing everything at the bus device
list instead of the root of the sysfs devices/ tree.

Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/2025021955-implant-excavator-179d@gregkh
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/Documentation/intel-hybrid.txt
tools/perf/Documentation/perf-list.txt
tools/perf/arch/x86/util/iostat.c
tools/perf/builtin-stat.c
tools/perf/util/mem-events.c
tools/perf/util/pmu.c

index e7a776ad25d719fa6af1115f2e75f48e8ae63948..0379903673a4acbecd6cecbc5e5e01f7325c2a8e 100644 (file)
@@ -8,15 +8,15 @@ Part of events are available on core cpu, part of events are available
 on atom cpu and even part of events are available on both.
 
 Kernel exports two new cpu pmus via sysfs:
-/sys/devices/cpu_core
-/sys/devices/cpu_atom
+/sys/bus/event_source/devices/cpu_core
+/sys/bus/event_source/devices/cpu_atom
 
 The 'cpus' files are created under the directories. For example,
 
-cat /sys/devices/cpu_core/cpus
+cat /sys/bus/event_source/devices/cpu_core/cpus
 0-15
 
-cat /sys/devices/cpu_atom/cpus
+cat /sys/bus/event_source/devices/cpu_atom/cpus
 16-23
 
 It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus.
@@ -60,8 +60,8 @@ can't carry pmu information. So now this type is extended to be PMU aware
 type. The PMU type ID is stored at attr.config[63:32].
 
 PMU type ID is retrieved from sysfs.
-/sys/devices/cpu_atom/type
-/sys/devices/cpu_core/type
+/sys/bus/event_source/devices/cpu_atom/type
+/sys/bus/event_source/devices/cpu_core/type
 
 The new attr.config layout for PERF_TYPE_HARDWARE:
 
index d0c65fad419a073089886fd0186617f0f3e516f8..c3ffd93f94d73b14fdc8a6f0119446a2f0975f3c 100644 (file)
@@ -188,7 +188,7 @@ in the CPU vendor specific documentation.
 
 The available PMUs and their raw parameters can be listed with
 
-  ls /sys/devices/*/format
+  ls /sys/bus/event_source/devices/*/format
 
 For example the raw event "LSD.UOPS" core pmu event above could
 be specified as
index 00f645a0c18ac9ce65dcd157753774381d59128b..7442a2cd87eda78f1a9f3bb24955e6eb8d2cd1c2 100644 (file)
@@ -32,7 +32,7 @@
 #define MAX_PATH 1024
 #endif
 
-#define UNCORE_IIO_PMU_PATH    "devices/uncore_iio_%d"
+#define UNCORE_IIO_PMU_PATH    "bus/event_source/devices/uncore_iio_%d"
 #define SYSFS_UNCORE_PMU_PATH  "%s/"UNCORE_IIO_PMU_PATH
 #define PLATFORM_MAPPING_PATH  UNCORE_IIO_PMU_PATH"/die%d"
 
index 77e327d4a9a70c450c0284ddfcb9d581f9300a95..68ea7589c143bd54fa95d73e7f54ad19bcafd55d 100644 (file)
@@ -97,7 +97,7 @@
 #include <internal/threadmap.h>
 
 #define DEFAULT_SEPARATOR      " "
-#define FREEZE_ON_SMI_PATH     "devices/cpu/freeze_on_smi"
+#define FREEZE_ON_SMI_PATH     "bus/event_source/devices/cpu/freeze_on_smi"
 
 static void print_counters(struct timespec *ts, int argc, const char **argv);
 
index 3692e988c86e5d90306dd5bce58525c613abc093..0277d3e1505c527572884cfcd1433b42eb21cf2f 100644 (file)
@@ -189,7 +189,7 @@ static bool perf_pmu__mem_events_supported(const char *mnt, struct perf_pmu *pmu
        if (!e->event_name)
                return true;
 
-       scnprintf(path, PATH_MAX, "%s/devices/%s/events/%s", mnt, pmu->name, e->event_name);
+       scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/%s", mnt, pmu->name, e->event_name);
 
        return !stat(path, &st);
 }
index c2a15b0259cf9fae1bb90f45ef39d237859a85ff..ec3878c890a9dc1ace093fb25b42a60aa84c5a2f 100644 (file)
 #define UNIT_MAX_LEN   31 /* max length for event unit name */
 
 enum event_source {
-       /* An event loaded from /sys/devices/<pmu>/events. */
+       /* An event loaded from /sys/bus/event_source/devices/<pmu>/events. */
        EVENT_SRC_SYSFS,
        /* An event loaded from a CPUID matched json file. */
        EVENT_SRC_CPU_JSON,
        /*
-        * An event loaded from a /sys/devices/<pmu>/identifier matched json
+        * An event loaded from a /sys/bus/event_source/devices/<pmu>/identifier matched json
         * file.
         */
        EVENT_SRC_SYS_JSON,