linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Perf avoid opening events on offline CPUs
@ 2024-06-03  9:28 Yicong Yang
  2024-06-03  9:28 ` [PATCH 1/3] perf pmu: Limit PMU cpumask to online CPUs Yicong Yang
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Yicong Yang @ 2024-06-03  9:28 UTC (permalink / raw)
  To: will, mark.rutland, acme, namhyung, linux-arm-kernel,
	linux-perf-users, linux-kernel
  Cc: peterz, mingo, alexander.shishkin, jolsa, irogers, james.clark,
	dongli.zhang, jonathan.cameron, prime.zeng, linuxarm, yangyicong

From: Yicong Yang <yangyicong@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@localhost yang]# echo 0 > /sys/devices/system/cpu/cpu0/online
[root@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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-07-03  4:55 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03  9:28 [PATCH 0/3] Perf avoid opening events on offline CPUs Yicong Yang
2024-06-03  9:28 ` [PATCH 1/3] perf pmu: Limit PMU cpumask to online CPUs Yicong Yang
2024-06-03 16:52   ` Ian Rogers
2024-06-04 11:12     ` Yicong Yang
2024-06-04 14:12       ` Ian Rogers
2024-06-07  0:09     ` Namhyung Kim
2024-06-07  0:36       ` Ian Rogers
2024-06-07  7:04         ` Ian Rogers
2024-06-03  9:28 ` [PATCH 2/3] perf: arm_pmu: Only show online CPUs in device's "cpus" attribute Yicong Yang
2024-06-03 16:20   ` Ian Rogers
2024-06-04  7:43     ` Yicong Yang
2024-06-07  0:17       ` Namhyung Kim
2024-06-04 12:22     ` Yicong Yang
2024-06-03  9:28 ` [PATCH 3/3] perf: arm_spe: Only show online CPUs in device's "cpumask" attribute Yicong Yang
2024-06-03 16:42 ` [PATCH 0/3] Perf avoid opening events on offline CPUs Ian Rogers
2024-06-04  8:03   ` Yicong Yang
2024-06-06  7:04     ` Ian Rogers
2024-07-01 14:22 ` Will Deacon
2024-07-03  4:55   ` Ian Rogers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).