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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70F3BC83F21 for ; Tue, 15 Jul 2025 13:24:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 125968D0010; Tue, 15 Jul 2025 09:24:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D7488D0001; Tue, 15 Jul 2025 09:24:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 013748D0010; Tue, 15 Jul 2025 09:24:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E637C8D0001 for ; Tue, 15 Jul 2025 09:24:49 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8E1A61A048B for ; Tue, 15 Jul 2025 13:24:49 +0000 (UTC) X-FDA: 83666569098.17.34D53EF Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf18.hostedemail.com (Postfix) with ESMTP id C2CDC1C0011 for ; Tue, 15 Jul 2025 13:24:47 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SPFgiCbm; spf=pass (imf18.hostedemail.com: domain of will@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752585888; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EMDbadNseXzpLJnPf5nVCnaV4nsb0WAVNLIP5V+z6VU=; b=o3vz6g6f+e/jyVCg4oslAyO4wNmjIb60vNgWtCbgeNg71DhhBcJmqDkLwWYVEB/VF0dhi0 Q/tuhzszEjZ9J4pOFAGFlG88mFfFGhlF2FZRQaySF9xpF+e/miLVwwqFuXQBWSDTxzKY5F YAzVIRm/0Me9eZicZVmBaj5fZX5gD+I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752585888; a=rsa-sha256; cv=none; b=HubOM9S8nzgNO51xr/C1xjvre95KdAyy5v6sYgqMf7QdpOf0qo44sTTSN/pGzH43WEVgbx G3jBbTcOjDcMEtjvNPk9KDcwUPaXcufemScgT7N7L+mbLNihOcTKsGKUVdZRBcRzXUNI7R fI4ZClUBW2fTGyWcmfZe0JRLItKiHBc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SPFgiCbm; spf=pass (imf18.hostedemail.com: domain of will@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 8A02F44C91; Tue, 15 Jul 2025 13:24:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78FF9C4CEE3; Tue, 15 Jul 2025 13:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752585886; bh=LACQRLoYbwjDJR7B8kKiL5kegf3U3j4BP+gzpY0KEsY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SPFgiCbmTjPFJKl5cs0OZMbXGYUAhCKvFG7enaVLf+cqb6iwHU56DujED+FM/4W/z x1RFbZALiY/TbT/W30fFBxkD8Jx9QNZX2NnEp4ykPrhBMKuw2rRwvdmcmNGluj1hOg 6tgI9ehvM68n26LyiCkDWSHUv6WuUZnpewUtqClNHOxa3hJ8NDtd/CdbNCsmqAn0uD uxUKdhsRJ0TyQKFVjUOEqMvirCzGFjGwTpkys/3DVBlMb7BMr8eOEPqJTWXx98VQWI N5zqWCYnndaF/OJVGgy7A0rFygzVh8S7ElMNVCp22I186H186bp8d1LBrKVm3ZjrfS x8/h4CKze7ZVw== Date: Tue, 15 Jul 2025 14:24:38 +0100 From: Will Deacon To: Leon Romanovsky Cc: Marek Szyprowski , Leon Romanovsky , Christoph Hellwig , Jonathan Corbet , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Robin Murphy , Joerg Roedel , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Alexander Potapenko , Marco Elver , Dmitry Vyukov , Masami Hiramatsu , Mathieu Desnoyers , =?iso-8859-1?B?Suly9G1l?= Glisse , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, iommu@lists.linux.dev, virtualization@lists.linux.dev, kasan-dev@googlegroups.com, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 8/8] mm/hmm: migrate to physical address-based DMA mapping API Message-ID: References: <8a85f4450905fcb6b17d146cc86c11410d522de4.1750854543.git.leon@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8a85f4450905fcb6b17d146cc86c11410d522de4.1750854543.git.leon@kernel.org> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C2CDC1C0011 X-Stat-Signature: tiy6kbshap66u5dqjo9a74a53zjhut1i X-Rspam-User: X-HE-Tag: 1752585887-876054 X-HE-Meta: U2FsdGVkX18Irskf3uGtQJ7BFgs9Tqr3FqWkwkcMHfN2iROHGXJG04sAReHe+as/6vTY1/3ANJ+UIgrIWsM5jQz1U38nxkctYB3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mdQC7jj+SikZboMA3x0isdiKeidivVyrbcWp/VVljk96lrLEMQ47erunqTJM3Kt5Z+xEatNQIgpccpk310xyTpCXmlXcfcMdYw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Leon, On Wed, Jun 25, 2025 at 04:19:05PM +0300, Leon Romanovsky wrote: > From: Leon Romanovsky > > Convert HMM DMA operations from the legacy page-based API to the new > physical address-based dma_map_phys() and dma_unmap_phys() functions. > This demonstrates the preferred approach for new code that should use > physical addresses directly rather than page+offset parameters. > > The change replaces dma_map_page() and dma_unmap_page() calls with > dma_map_phys() and dma_unmap_phys() respectively, using the physical > address that was already available in the code. This eliminates the > redundant page-to-physical address conversion and aligns with the > DMA subsystem's move toward physical address-centric interfaces. > > This serves as an example of how new code should be written to leverage > the more efficient physical address API, which provides cleaner interfaces > for drivers that already have access to physical addresses. I'm struggling a little to see how this is cleaner or more efficient than the old code. >From what I can tell, dma_map_page_attrs() takes a 'struct page *' and converts it to a physical address using page_to_phys() whilst your new dma_map_phys() interface takes a physical address and converts it to a 'struct page *' using phys_to_page(). In both cases, hmm_dma_map_pfn() still needs the page for other reasons. If anything, existing users of dma_map_page_attrs() now end up with a redundant page-to-phys-to-page conversion which hopefully the compiler folds away. I'm assuming there's future work which builds on top of the new API and removes the reliance on 'struct page' entirely, is that right? If so, it would've been nicer to be clearer about that as, on its own, I'm not really sure this patch series achieves an awful lot and the efficiency argument looks quite weak to me. Cheers, Will