]> xenbits.xensource.com Git - xen.git/commitdiff
IOMMU/x86: add perf counters for page table splitting / coalescing
authorJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:42:33 +0000 (15:42 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 25 Jul 2022 13:42:33 +0000 (15:42 +0200)
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin tian <kevin.tian@intel.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/arch/x86/include/asm/perfc_defn.h
xen/drivers/passthrough/amd/iommu_map.c
xen/drivers/passthrough/vtd/iommu.c

index b07063b7d837e3a534fdeb5d792e2b9f9a44ae74..509afc516b3f219f9dc08c6519e2ad315a4f7ba8 100644 (file)
@@ -125,4 +125,7 @@ PERFCOUNTER(realmode_exits,      "vmexits from realmode")
 
 PERFCOUNTER(pauseloop_exits, "vmexits from Pause-Loop Detection")
 
+PERFCOUNTER(iommu_pt_shatters,    "IOMMU page table shatters")
+PERFCOUNTER(iommu_pt_coalesces,   "IOMMU page table coalesces")
+
 /*#endif*/ /* __XEN_PERFC_DEFN_H__ */
index 85d3a85fbb22e58eb7917d4cd514a3544b18385f..f2157e004369f231fc77b6512dfeef6c6a93a6f8 100644 (file)
@@ -345,6 +345,8 @@ static int iommu_pde_from_dfn(struct domain *d, unsigned long dfn,
                                      level, PTE_kind_table);
 
             *flush_flags |= IOMMU_FLUSHF_modified;
+
+            perfc_incr(iommu_pt_shatters);
         }
 
         /* Install lower level page table for non-present entries */
@@ -477,6 +479,7 @@ int cf_check amd_iommu_map_page(
                               flags & IOMMUF_readable, &contig);
         *flush_flags |= IOMMU_FLUSHF_modified | IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(hd, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);
@@ -543,6 +546,7 @@ int cf_check amd_iommu_unmap_page(
             clear_iommu_pte_present(pt_mfn, dfn_x(dfn), level, &free);
             *flush_flags |= IOMMU_FLUSHF_all;
             iommu_queue_free_pgtable(hd, pg);
+            perfc_incr(iommu_pt_coalesces);
         }
     }
 
index 35545bfaef9bae509292d42c02f871cefb06fdd8..496d2d50eebfe2b242c143c0e76994e5024e939c 100644 (file)
@@ -404,6 +404,8 @@ static uint64_t addr_to_dma_page_maddr(struct domain *domain, daddr_t addr,
 
                 if ( flush_flags )
                     *flush_flags |= IOMMU_FLUSHF_modified;
+
+                perfc_incr(iommu_pt_shatters);
             }
 
             write_atomic(&pte->val, new_pte.val);
@@ -857,6 +859,7 @@ static int dma_pte_clear_one(struct domain *domain, daddr_t addr,
 
         *flush_flags |= IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(hd, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);
@@ -2239,6 +2242,7 @@ static int __must_check cf_check intel_iommu_map_page(
 
         *flush_flags |= IOMMU_FLUSHF_modified | IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(hd, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);