[PATCH 0/3] Perf avoid opening events on offline CPUs
Yicong Yang
yangyicong at huawei.com
Mon Jun 3 02:28:09 PDT 2024
From: Yicong Yang <yangyicong at hisilicon.com>
If user doesn't specify the CPUs, perf will try to open events on CPUs
of the PMU which is initialized from the PMU's "cpumask" or "cpus" sysfs
attributes if provided. But we doesn't check whether the CPUs provided
by the PMU are all online. So we may open events on offline CPUs if PMU
driver provide offline CPUs and then we'll be rejected by the kernel:
[root at localhost yang]# echo 0 > /sys/devices/system/cpu/cpu0/online
[root at localhost yang]# ./perf_static stat -e armv8_pmuv3_0/cycles/ --timeout 100
Error:
The sys_perf_event_open() syscall returned with 19 (No such device) for event (cpu-clock).
/bin/dmesg | grep -i perf may provide additional information.
This patchset tries to avoid this case by:
- Double check the PMU's cpumask in the perf tool and only include online CPUs
- Trying to make the PMU drivers only export online CPUs in its "cpus" or "cpumask"
attributes
Previously discussion can be found at [1]. Will suggested to do it in userspace.
I think it makes sense to do a double check in the perf tool in case the driver
doesn't do this. So PATCH 1/3 is added in this version.
[1] https://lore.kernel.org/linux-arm-kernel/20240410095833.63934-1-yangyicong@huawei.com/
Yicong Yang (3):
perf pmu: Limit PMU cpumask to online CPUs
perf: arm_pmu: Only show online CPUs in device's "cpus" attribute
perf: arm_spe: Only show online CPUs in device's "cpumask" attribute
drivers/perf/arm_pmu.c | 24 +++++++++++++++++++++++-
drivers/perf/arm_spe_pmu.c | 22 +++++++++++++++++++++-
tools/perf/util/pmu.c | 13 +++++++++++--
3 files changed, 55 insertions(+), 4 deletions(-)
--
2.24.0
More information about the linux-arm-kernel
mailing list