iommu/vt-d: Support cpumask for IOMMU perfmon
authorKan Liang <kan.liang@linux.intel.com>
Tue, 31 Jan 2023 07:37:38 +0000 (15:37 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 3 Feb 2023 10:06:08 +0000 (11:06 +0100)
commit46284c6ceb5e4dfddcb00dafb7c2f3c1437fdca4
tree16a01376418a6683fc5e7f53813c52e77ab184aa
parent7232ab8b89e9ea32f07370643635a13641ce9c3c
iommu/vt-d: Support cpumask for IOMMU perfmon

The perf subsystem assumes that all counters are by default per-CPU. So
the user space tool reads a counter from each CPU. However, the IOMMU
counters are system-wide and can be read from any CPU. Here we use a CPU
mask to restrict counting to one CPU to handle the issue. (with CPU
hotplug notifier to choose a different CPU if the chosen one is taken
off-line).

The CPU is exposed to /sys/bus/event_source/devices/dmar*/cpumask for
the user space perf tool.

Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/r/20230128200428.1459118-6-kan.liang@linux.intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Documentation/ABI/testing/sysfs-bus-event_source-devices-iommu
drivers/iommu/intel/perfmon.c
include/linux/cpuhotplug.h