On Fri, May 17, 2013 at 02:43:32PM -0500, Suthikulpanit, Suravee wrote:I will take care of this.diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/MakefileThis should also depend on CONFIG_AMD_IOMMU. If no IOMMU driver is
index b0684e4..fcbd3b8 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -30,7 +30,7 @@ obj-$(CONFIG_CPU_SUP_UMC_32) += umc.o
obj-$(CONFIG_PERF_EVENTS) += perf_event.o
ifdef CONFIG_PERF_EVENTS
-obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o perf_event_amd_uncore.o
+obj-$(CONFIG_CPU_SUP_AMD) += perf_event_amd.o perf_event_amd_uncore.o perf_event_amd_iommu.o
compiled in it doesn't make sense to have that PMU.
+ } else {This patch is adding perf system-wide counting mode support which is used by "perf stat" tool. We are not implementing the sampling mode since MSI interrupt of the IOMMU cannot be used for current perf sampling tools (e.g. perf record or top) since the IOMMU counters are not core-specific. The current "perf record" and "perf top" needs to attribute each sample to a particular core/pid which would allow the tools to figure out the instruction pointer and map the sample to a paticular module.
+ return -EINVAL;
+ }
+
+ /* integrate with iommu base devid (0000), assume one iommu */
+ perf_iommu->max_banks =
+ amd_iommu_pc_get_max_banks(IOMMU_BASE_DEVID);
+ perf_iommu->max_counters =
+ amd_iommu_pc_get_max_counters(IOMMU_BASE_DEVID);
+
+ /* update the hw_perf_event struct with the iommu config data */
+ hwc->config = config;
+ hwc->extra_reg.config = config1;
+
+ return 0;
+}
That implementation is very basic. Any reason for not using the event
reporting mechanism of the IOMMU? You could implement a nice perf
iommutop or something to see which devices do the most transactions or
something like that.
Joerg