Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Fix up some comments and code to properly use the event_source bus

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>

authored by

Greg Kroah-Hartman and committed by
Namhyung Kim
0cced76a 687b8c39

+12 -12
+6 -6
tools/perf/Documentation/intel-hybrid.txt
··· 8 8 on atom cpu and even part of events are available on both. 9 9 10 10 Kernel exports two new cpu pmus via sysfs: 11 - /sys/devices/cpu_core 12 - /sys/devices/cpu_atom 11 + /sys/bus/event_source/devices/cpu_core 12 + /sys/bus/event_source/devices/cpu_atom 13 13 14 14 The 'cpus' files are created under the directories. For example, 15 15 16 - cat /sys/devices/cpu_core/cpus 16 + cat /sys/bus/event_source/devices/cpu_core/cpus 17 17 0-15 18 18 19 - cat /sys/devices/cpu_atom/cpus 19 + cat /sys/bus/event_source/devices/cpu_atom/cpus 20 20 16-23 21 21 22 22 It indicates cpu0-cpu15 are core cpus and cpu16-cpu23 are atom cpus. ··· 60 60 type. The PMU type ID is stored at attr.config[63:32]. 61 61 62 62 PMU type ID is retrieved from sysfs. 63 - /sys/devices/cpu_atom/type 64 - /sys/devices/cpu_core/type 63 + /sys/bus/event_source/devices/cpu_atom/type 64 + /sys/bus/event_source/devices/cpu_core/type 65 65 66 66 The new attr.config layout for PERF_TYPE_HARDWARE: 67 67
+1 -1
tools/perf/Documentation/perf-list.txt
··· 188 188 189 189 The available PMUs and their raw parameters can be listed with 190 190 191 - ls /sys/devices/*/format 191 + ls /sys/bus/event_source/devices/*/format 192 192 193 193 For example the raw event "LSD.UOPS" core pmu event above could 194 194 be specified as
+1 -1
tools/perf/arch/x86/util/iostat.c
··· 32 32 #define MAX_PATH 1024 33 33 #endif 34 34 35 - #define UNCORE_IIO_PMU_PATH "devices/uncore_iio_%d" 35 + #define UNCORE_IIO_PMU_PATH "bus/event_source/devices/uncore_iio_%d" 36 36 #define SYSFS_UNCORE_PMU_PATH "%s/"UNCORE_IIO_PMU_PATH 37 37 #define PLATFORM_MAPPING_PATH UNCORE_IIO_PMU_PATH"/die%d" 38 38
+1 -1
tools/perf/builtin-stat.c
··· 97 97 #include <internal/threadmap.h> 98 98 99 99 #define DEFAULT_SEPARATOR " " 100 - #define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi" 100 + #define FREEZE_ON_SMI_PATH "bus/event_source/devices/cpu/freeze_on_smi" 101 101 102 102 static void print_counters(struct timespec *ts, int argc, const char **argv); 103 103
+1 -1
tools/perf/util/mem-events.c
··· 189 189 if (!e->event_name) 190 190 return true; 191 191 192 - scnprintf(path, PATH_MAX, "%s/devices/%s/events/%s", mnt, pmu->name, e->event_name); 192 + scnprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/%s", mnt, pmu->name, e->event_name); 193 193 194 194 return !stat(path, &st); 195 195 }
+2 -2
tools/perf/util/pmu.c
··· 36 36 #define UNIT_MAX_LEN 31 /* max length for event unit name */ 37 37 38 38 enum event_source { 39 - /* An event loaded from /sys/devices/<pmu>/events. */ 39 + /* An event loaded from /sys/bus/event_source/devices/<pmu>/events. */ 40 40 EVENT_SRC_SYSFS, 41 41 /* An event loaded from a CPUID matched json file. */ 42 42 EVENT_SRC_CPU_JSON, 43 43 /* 44 - * An event loaded from a /sys/devices/<pmu>/identifier matched json 44 + * An event loaded from a /sys/bus/event_source/devices/<pmu>/identifier matched json 45 45 * file. 46 46 */ 47 47 EVENT_SRC_SYS_JSON,