[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 23/23] IOMMU/x86: add perf counters for page table splitting / coalescing


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 10 Jan 2022 17:38:31 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=97KazUwFBsNkQrAya4NCXyO8j9M+QQa3dDJrEHqAexY=; b=cHfol603NA8IMzoZuUAp+nZ0I3NV50r5bZkxwBunL13ThGrCqN1dTODJ45cGvnoQngNMEddsxzQN+2Li1q0A8Plnl+NvJiIjensiN0XMw/3F64AQ5uvtKcLBCzxS5YOZ3d8sPhpVmwzICxoSt9FqUTaEww6QHZhfDkMJW0HVywqTIan9A4T04um9QRFtgoXP3NQz4V4LDC/iOtBrXqAWOXwXn4V7qLz8yu/i1IoK6R44qj04sGjAnYLxy8eMjkwOfklWos8YO9ebpU/oBAPsGalbZi5lio6hR8IIf41vQ1sg/BeiM0sWCdqDuno8SCnkExAbEAwce/SEg7wg7dEbIQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K267DTvJe8m8dWOmIX0c7eBXKE3CmyYZ545KLDeLXzsmnWF4sykc2dilqv3rP/pHIBz/VTLrvCFkSM0RZGq3OWmDH6rBcpZBdeLdTRc8J3FcAqQhu9oYPk05CZMt5zsC0sGg0KWwBy1bjIjTP+KTNx/wc4hTykp5qAkJmtHkJJPpmNZ7EkGpCpu0hdWWn2YH5UT5I30OhwDnqAeZYNK4XJNKUwHqwsxg7qdr6W9pObyLvW1f+ZljJa0LEMbmaa5ffItUvKFT+RxCdPhyad64UoO1vnA3PCEt+MTifocsBTCzg9D4ShSb76BxCf7tHDr8TDLdyaJILD7P+TqIQUho/A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Mon, 10 Jan 2022 16:38:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v3: New.

--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -283,6 +283,8 @@ static int iommu_pde_from_dfn(struct dom
                                      level, PTE_kind_table);
 
             *flush_flags |= IOMMU_FLUSHF_modified;
+
+            perfc_incr(iommu_pt_shatters);
         }
 
         /* Install lower level page table for non-present entries */
@@ -411,6 +413,7 @@ int amd_iommu_map_page(struct domain *d,
                               flags & IOMMUF_readable, &contig);
         *flush_flags |= IOMMU_FLUSHF_modified | IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(d, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);
@@ -471,6 +474,7 @@ int amd_iommu_unmap_page(struct domain *
             clear_iommu_pte_present(pt_mfn, dfn_x(dfn), level, &free);
             *flush_flags |= IOMMU_FLUSHF_all;
             iommu_queue_free_pgtable(d, pg);
+            perfc_incr(iommu_pt_coalesces);
         }
     }
 
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -451,6 +451,8 @@ static uint64_t addr_to_dma_page_maddr(s
 
                 if ( flush_flags )
                     *flush_flags |= IOMMU_FLUSHF_modified;
+
+                perfc_incr(iommu_pt_shatters);
             }
 
             write_atomic(&pte->val, new_pte.val);
@@ -907,6 +909,7 @@ static int dma_pte_clear_one(struct doma
 
         *flush_flags |= IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(domain, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);
@@ -2099,6 +2102,7 @@ static int __must_check intel_iommu_map_
 
         *flush_flags |= IOMMU_FLUSHF_modified | IOMMU_FLUSHF_all;
         iommu_queue_free_pgtable(d, pg);
+        perfc_incr(iommu_pt_coalesces);
     }
 
     spin_unlock(&hd->arch.mapping_lock);
--- a/xen/arch/x86/include/asm/perfc_defn.h
+++ b/xen/arch/x86/include/asm/perfc_defn.h
@@ -125,4 +125,7 @@ PERFCOUNTER(realmode_exits,      "vmexit
 
 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__ */




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.