From patchwork Thu Jun 9 10:21:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12875179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 77CE8C433EF for ; Thu, 9 Jun 2022 10:25:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.344956.570602 (Exim 4.92) (envelope-from ) id 1nzFM8-0008Cz-1r; Thu, 09 Jun 2022 10:25:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 344956.570602; Thu, 09 Jun 2022 10:25:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nzFM7-0008CX-Uu; Thu, 09 Jun 2022 10:25:35 +0000 Received: by outflank-mailman (input) for mailman id 344956; Thu, 09 Jun 2022 10:25:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nzFI5-0003pZ-H5 for xen-devel@lists.xenproject.org; Thu, 09 Jun 2022 10:21:25 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0605.outbound.protection.outlook.com [2a01:111:f400:fe06::605]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ea18e1e8-e7dd-11ec-b605-df0040e90b76; Thu, 09 Jun 2022 12:21:24 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.13; Thu, 9 Jun 2022 10:21:23 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::dfa:a64a:432f:e26b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::dfa:a64a:432f:e26b%7]) with mapi id 15.20.5332.013; Thu, 9 Jun 2022 10:21:23 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ea18e1e8-e7dd-11ec-b605-df0040e90b76 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Odal0snAZ8F9yN2IlfiSiVIK9OwJDNdkM+AZyUBxTsCvEj1sc3v5AuyoKtnunKVw7dMHpgEos5Z69dYG6yR/wtci/DEnkzgfYZlCfEA0l4vtvv/Bmrp2RUBvfkCBCDi24M1sjkcyJtkw5kyYoKmtOYDpugONdTA3bCyl1wQq8GKOwJ11jpehA6rkgwCIYIvLexDfeVbGi3G/1ZMJ5Ha2wVZxhIhec7VnoCmNcqBwxD74BOV9FYu84T38HO6e3WSVABMlQwuSKAo1Ux7ieDhSqv5Kih7yDzMHbUUlJMK+4MVtddo2+Le839AY8KsHZXcDNypJ33BkPFJe8Jd7SfgeHw== 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=iNSivqMUGJNXw6YV9IuRH2YBw0MQFLGrycARpWhZOTo=; b=MFtefsviZuhrRF3fj+CZ28MqyK1OaOe6LT1BXQCHRaAEl/qImrkuOIdCDLCjV3MgkJoOBMsd3xbSBu1EvGbZAM3I64YTFjwLJdksGCSrkqGS390rh40ZRF1BIpMASKB0Td87LXYJws2sP4mBzqd6uOcRnAl3nDjGKNTXW7PqlTpKlr3t2/jdOETfY/c0+IZPNlBT9iMVDokHcCtPBFi/jnDQ4SIkPWrbQg+Hk1NboK0qY+n2hQ44SpnxjN7ywi6WpDK+J5pIFpJXTQId3ojg7TqnWFSY+mDvqVWmpFZDYaPCV4wdfVvVlAQoQQb4jvYhmzK4MBYOAYAtlV2CtzpMiw== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iNSivqMUGJNXw6YV9IuRH2YBw0MQFLGrycARpWhZOTo=; b=KNUbVApEC4UPIpV7LsnKtKBhpDqY3q9tOy7QJhEpI2HN3OX87pcA8L83dBBEgjj5OGa9qubomQDAof+suyPrYiEIJAPQmuNxVtrBWKy4gW0Uak6GqRnmygZiztkIvz10c0vRoPliC4XkU+QUdnWBQLAGLf+drDwl+S1GVQgxmy2KeFZsod7lQ6EObgIDaADLbyjsCjHdvq4g1LCqmefSRhoiNcLGKiA1v++O6X+liO3MX4/ofmfwS9eDdU2J/u+yLDF3v7YFMwMUUl0Ju+mrbBZb3UB6jx4sefoujEeira2KLkHhgWxJM5KAtypymyvKKOjQTQvkKFI2fnFJegaqsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <5569f3d3-7315-3fd1-3e73-0cb610eb3f43@suse.com> Date: Thu, 9 Jun 2022 12:21:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: [PATCH v6 11/12] IOMMU/x86: add perf counters for page table splitting / coalescing Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= References: In-Reply-To: X-ClientProxiedBy: AS8PR04CA0146.eurprd04.prod.outlook.com (2603:10a6:20b:127::31) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9a45ac9-ad1e-4875-4c29-08da4a01cdd1 X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CQaUxOHFIyLGzQDuN3kk7V7d1Sx4Qvv5WE8f41ZFqzwbSqHFBX8k+I7n/e1fJGGXI2cJOmOO6xGc++jyt2SYj5I3f2CyDKV7+db5zqscHqEgcyl6Ql8hQi147Jo2sa+/wb40FbxjhV2678mxJLzYdGZibA+BaxLf2e0jk1dLIEun1t1enSifdDPfP1Vt7NUJX4WNAN9K2G0+7Tg6hCSPOVDMPPFdgkUBcl67K0GWhoPzlMse3jv5l+gSa9TavaHRhPdbMaXG+5S5rRRuz4+0al0OHztIyqtPbTwcptmOX7QSGoUDFElj+L8fqoMWx7z+pI0UXhsxB8FpRm6EiiyRq3JfAtzmfij/YXc0S0MQX0lzKlDEQzrVlsbWSqupszkMtBBywY/rtfXARddFQ8+BPivL6jvoH9b85w9k4K75NqG5+jPZHg+VN7SWofbfv10n3TIJir7ZFnNwNzhCrcIla9MgOLITaL+60YJ8gwVLI7/WtcjJaFOE+rfew1pcKAmA6Zy2Zxu4Em7q0/ececBWPvczs7OGNkgwmcHSzQ2aX6TPNybNrV84L5Nh5/YLSt7rhmRGCv4LRTlYzIKehmEX7mmUhU4TlDRonKZDOg5bCaPprS/jce3p2CvnIb5uwSxvuEqD705TRtWpN5rOe112NUOizrQGeRuuEgWNI6383rwB4Un2t6j0K0OdTcQWHF/yLq2Zc5wBvGPVbaSXnp1qjRqEoN+cUmsuEo3oxW0BK8wiI1kHUXCcGEN8sM1NMZ88 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(26005)(6512007)(31696002)(6486002)(6506007)(5660300002)(186003)(66946007)(83380400001)(2906002)(86362001)(508600001)(8936002)(36756003)(2616005)(38100700002)(66476007)(66556008)(8676002)(4326008)(6916009)(316002)(54906003)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?EbvgDUc8ZcdyTyksQUJF+vgxd4l3?= =?utf-8?q?2vFBaqMMCSG87+N4a8EVGoCPoVsz5bNYmfYhLiWUDUCguc0k2DDD1jyeFEYdLbPlh?= =?utf-8?q?pYRTVnfJGi4SMAoYb+sFaKgfySuyYhMutaSljI0W+U6ZcsmdhEfZpf0XJ6PHQ/Z3I?= =?utf-8?q?Jl/Z6vFSk9OS02as+xbPw/g65JcYnX1KbcE7oWwBHq+FElauXMJEVEhTW+V6heFqK?= =?utf-8?q?M2bRyXw9er2RS76lwp1l+LnEqPtkG7J9B02QezFfH3O/bC9REQRFpaijFei2fAUpa?= =?utf-8?q?eN36fFSbA5kVr1gKDNbBVIJEYy5YsLknuW8X+ETt+ZQK2SHtRgBK19MMXptKIgkgb?= =?utf-8?q?YpVJukjjsCuLtrw8BI3ScrI4k2b1XURcEznH83Skj1uo9+7IyTdcqv+bUjcPlDAHu?= =?utf-8?q?0jmwkfKzRHke0f0k2iSaXpgPKmZUnZc8kiekbKzIWOV2ETtfQ+8K9aINuN3yfdXBb?= =?utf-8?q?u+lZC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bsfCnCxsuKLeANPiERtny0IbM0zc61WyL6x6y77XdgaBZw7xSglC+BD0?= =?utf-8?q?zow3SdFW5HcsMgPEMi343wgP2hXKlodGE/FSkly+eQANj9AB3Kl3gB1xQD11s2Ojf?= =?utf-8?q?SZM2nr2RQvvOWkPj6czdm97AiYBrFWOd94t/9LrquGVU58SRxyAKPQlxZRu4AHFLC?= =?utf-8?q?jQNv3bwfs8CDYGIjoPqyo5TcB6zbRtF9EM24TpeJfUH+50Qot3dn/djiEyHFgIfAs?= =?utf-8?q?J6uAl2Y9sJeVDgwFYwQiM2Ow7lePfDzXGqHM4vlKqTgRzDHrkoISMHOjEHY0cNsJf?= =?utf-8?q?z4sNghp/8zJWRPrIQyhVt/s5yvjacKZg=3D=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9a45ac9-ad1e-4875-4c29-08da4a01cdd1 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2022 10:21:23.5908 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JHrOC8FivjUt+RQ/6nvDeVYA9jL5WMxe1ZLdaHzKmDKr8aWEm3ZpPgkgg805HuYYuBIxypm5el4/N/SmyT7DSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8790 Signed-off-by: Jan Beulich Reviewed-by: Kevin tian Reviewed-by: Roger Pau Monné --- v3: New. --- 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__ */ --- a/xen/drivers/passthrough/amd/iommu_map.c +++ b/xen/drivers/passthrough/amd/iommu_map.c @@ -345,6 +345,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 */ @@ -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); } } --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -404,6 +404,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); @@ -857,6 +859,7 @@ static int dma_pte_clear_one(struct doma *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_i *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);