From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B834C48BD1 for ; Fri, 11 Jun 2021 03:15:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFA1561359 for ; Fri, 11 Jun 2021 03:15:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFA1561359 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Cc:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=K8abfabqqp1Go9kAatQmDrAbbP3i5FrAIaY5r50ypMM=; b=o6OXPelIw91m5aaaQyulWX1bQq kX1apj9j55ifFR+mx4KQgNBvYs/DobvkIWT2r15tWzhtM7/YK/yeGu19J12PAmONXtm2mIacWimIO IywhYYdt5PKCQ3tmfsM3rtT8Q+kftFGl9ozKIajL4OexjzxixNxSRQccwv6GyUrvDa8O3PjN7aN7e ibw+ZO18nS9/a5nUXpedfBZQ+JvX0g9nObYSPn1HheT4YDnxotYTGVCTxwULkcUSrz3KUMu11Y500 ejH73lLweRv88uFR/+V481wMA/lqo5USUpb+rH2gzQEhcmTd8r7rDtWUsjgGWwfdNd7tWDabeXL8Z qqEWo3wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrXaB-003L86-Fj; Fri, 11 Jun 2021 03:11:43 +0000 Received: from mga01.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lrXa7-003L7c-LJ for linux-arm-kernel@lists.infradead.org; Fri, 11 Jun 2021 03:11:41 +0000 IronPort-SDR: 1W9Oi5y5E8yIKiKAxGyue5WoCqk6hfeHaqZmb7zpq2S/F34jLVZgGbNwDgsnwY7jL5gIwZptvW YjGXPedc/x7Q== X-IronPort-AV: E=McAfee;i="6200,9189,10011"; a="226869679" X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="226869679" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2021 20:11:36 -0700 IronPort-SDR: NrlyWs9r8kQf8R98k7/rsDSXLJggMO9rtZcVpA5z+deX5aK3ORb8MLRNBpl1nVCSEeR1jSa4Y6 n5VKlMC1MxxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,265,1616482800"; d="scan'208";a="553280078" Received: from allen-box.sh.intel.com (HELO [10.239.159.105]) ([10.239.159.105]) by fmsmga001.fm.intel.com with ESMTP; 10 Jun 2021 20:11:34 -0700 Cc: baolu.lu@linux.intel.com, will@kernel.org, robin.murphy@arm.com, pratikp@codeaurora.org Subject: Re: [RFC PATCH v5 00/15] Optimizing iommu_[map/unmap] performance To: "Isaac J. Manjarres" , iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org References: <20210408171402.12607-1-isaacm@codeaurora.org> From: Lu Baolu Message-ID: <405c06b2-0f5e-0d9e-5a11-1523522f9d55@linux.intel.com> Date: Fri, 11 Jun 2021 11:10:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210408171402.12607-1-isaacm@codeaurora.org> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210610_201139_751612_74B2C49E X-CRM114-Status: GOOD ( 37.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Isaac, Any update for this series? The iommu core part looks good to me and I also have some patches for Intel IOMMU implementation of [un]map_pages. Just wonder when could iommu core have this optimization. Best regards, baolu On 4/9/21 1:13 AM, Isaac J. Manjarres wrote: > When unmapping a buffer from an IOMMU domain, the IOMMU framework unmaps > the buffer at a granule of the largest page size that is supported by > the IOMMU hardware and fits within the buffer. For every block that > is unmapped, the IOMMU framework will call into the IOMMU driver, and > then the io-pgtable framework to walk the page tables to find the entry > that corresponds to the IOVA, and then unmaps the entry. > > This can be suboptimal in scenarios where a buffer or a piece of a > buffer can be split into several contiguous page blocks of the same size. > For example, consider an IOMMU that supports 4 KB page blocks, 2 MB page > blocks, and 1 GB page blocks, and a buffer that is 4 MB in size is being > unmapped at IOVA 0. The current call-flow will result in 4 indirect calls, > and 2 page table walks, to unmap 2 entries that are next to each other in > the page-tables, when both entries could have been unmapped in one shot > by clearing both page table entries in the same call. > > The same optimization is applicable to mapping buffers as well, so > these patches implement a set of callbacks called unmap_pages and > map_pages to the io-pgtable code and IOMMU drivers which unmaps or maps > an IOVA range that consists of a number of pages of the same > page size that is supported by the IOMMU hardware, and allows for > manipulating multiple page table entries in the same set of indirect > calls. The reason for introducing these callbacks is to give other IOMMU > drivers/io-pgtable formats time to change to using the new callbacks, so > that the transition to using this approach can be done piecemeal. > > Changes since V4: > > * Fixed type for addr_merge from phys_addr_t to unsigned long so > that GENMASK() can be used. > * Hooked up arm_v7s_[unmap/map]_pages to the io-pgtable ops. > * Introduced a macro for calculating the number of page table entries > for the ARM LPAE io-pgtable format. > > Changes since V3: > > * Removed usage of ULL variants of bitops from Will's patches, as > they were not needed. > * Instead of unmapping/mapping pgcount pages, unmap_pages() and > map_pages() will at most unmap and map pgcount pages, allowing > for part of the pages in pgcount to be mapped and unmapped. This > was done to simplify the handling in the io-pgtable layer. > * Extended the existing PTE manipulation methods in io-pgtable-arm > to handle multiple entries, per Robin's suggestion, eliminating > the need to add functions to clear multiple PTEs. > * Implemented a naive form of [map/unmap]_pages() for ARM v7s io-pgtable > format. > * arm_[v7s/lpae]_[map/unmap] will call > arm_[v7s/lpae]_[map_pages/unmap_pages] with an argument of 1 page. > * The arm_smmu_[map/unmap] functions have been removed, since they > have been replaced by arm_smmu_[map/unmap]_pages. > > Changes since V2: > > * Added a check in __iommu_map() to check for the existence > of either the map or map_pages callback as per Lu's suggestion. > > Changes since V1: > > * Implemented the map_pages() callbacks > * Integrated Will's patches into this series which > address several concerns about how iommu_pgsize() partitioned a > buffer (I made a minor change to the patch which changes > iommu_pgsize() to use bitmaps by using the ULL variants of > the bitops) > > Isaac J. Manjarres (12): > iommu/io-pgtable: Introduce unmap_pages() as a page table op > iommu: Add an unmap_pages() op for IOMMU drivers > iommu/io-pgtable: Introduce map_pages() as a page table op > iommu: Add a map_pages() op for IOMMU drivers > iommu: Add support for the map_pages() callback > iommu/io-pgtable-arm: Prepare PTE methods for handling multiple > entries > iommu/io-pgtable-arm: Implement arm_lpae_unmap_pages() > iommu/io-pgtable-arm: Implement arm_lpae_map_pages() > iommu/io-pgtable-arm-v7s: Implement arm_v7s_unmap_pages() > iommu/io-pgtable-arm-v7s: Implement arm_v7s_map_pages() > iommu/arm-smmu: Implement the unmap_pages() IOMMU driver callback > iommu/arm-smmu: Implement the map_pages() IOMMU driver callback > > Will Deacon (3): > iommu: Use bitmap to calculate page size in iommu_pgsize() > iommu: Split 'addr_merge' argument to iommu_pgsize() into separate > parts > iommu: Hook up '->unmap_pages' driver callback > > drivers/iommu/arm/arm-smmu/arm-smmu.c | 18 +-- > drivers/iommu/io-pgtable-arm-v7s.c | 50 ++++++- > drivers/iommu/io-pgtable-arm.c | 189 +++++++++++++++++--------- > drivers/iommu/iommu.c | 130 +++++++++++++----- > include/linux/io-pgtable.h | 8 ++ > include/linux/iommu.h | 9 ++ > 6 files changed, 289 insertions(+), 115 deletions(-) > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel