[PATCH 0/3] Perf avoid opening events on offline CPUs
Will Deacon
will at kernel.org
Mon Jul 1 07:22:23 PDT 2024
On Mon, Jun 03, 2024 at 05:28:09PM +0800, Yicong Yang wrote:
> 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.
I still don't see the value in this. CPUs can come and go asynchronously,
so this is all horribly racy. Furthermore, there are other (racy) ways
to find out which CPUs are online and whatever we do in the kernel now
isn't going to help userspace running on older kernels.
Will
More information about the linux-arm-kernel
mailing list