From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2047.outbound.protection.outlook.com [40.107.94.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69A03A2D for ; Thu, 9 Jan 2025 08:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.47 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736410200; cv=fail; b=tEoqUNnI8RNQLsmA2DZNtEOJ0GE8kMdTa2nOYdq1NlrU0AU8I0Z4WlIOqvlB4XokqNqJDgSBhoBns+AqUicgXDw7vlsoZt9NivvTSUY3KwUcEBUozfzt8jVGXunVBXJQDtJ0XDOEsUH86uqcIWW49V2IQILGpEun7z9qzcea108= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736410200; c=relaxed/simple; bh=LtSCF7VAYVmUxWre1a2bt/3xkO4iBlf33+fc8Uk9Q7M=; h=Message-ID:Date:Subject:From:To:References:In-Reply-To: Content-Type:MIME-Version; b=Kbz7sleir3in1nsKM7U67RY056hLDOxomA2kaCqnSPvZttK3VK72Ih4Ay0hguXN5zHwBsP12bM9NBnWt6Hd8yIZJcp7k9hi7ZvY9q27v4DXwh6uaOncAGSsWh+TQJOaPhthXRF5clNbik/WebW+LmZWphtolpPLf7rZ4B09mxjw= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=NdN/ARTC; arc=fail smtp.client-ip=40.107.94.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="NdN/ARTC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XrL55YsF4WlTSflZ6GXFXCDrjuHSKHe16YxgLHExQdbVDlTF6+vL39fFt2nXCLqBQGiLrKYeHNdFJVDS8P27dXGgCJtpgFr7HXCjwH01RoYKTjqdeS+Wz/6ekH94+J58sR5Fm4+Xf7kx2uDgPe8CRRtNPXeJaZPoTYvkUe4qfBvBO+3OS3gO8d9usZkuBUtMYFKs4/lDxikw+GU8m3IfpBEcdMXp/cCi58Xo6JueFKte4KibwWczOzPbS33SKP+bbcIwRLHkVaHO0ty+FtueFmyo22qCW+A2E+cH1JiUzpAAhvpxqKoD2Z0ixAsD6mIOa+o03WeNplEsyhKNf1ISiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5VlMeftaCoOgHP26z/lG7BxBebTX/5t1H4OpB6Znyd4=; b=OlQgYARem1sVxB1NV2VptJx//TBcwBqNfuKqE191kz9CzF3qwV6FBwnT/wGUz+oOJG9f2noMaQPhDBG0gHnjKpNUWgvuESzyI6w2aRDS/lejUT16mbB0SUUn8oUk6rq1Zjzy0/qEQSHsyqbR6TW9ut1kFk90tNHcmod1i5HLJkud7iK+JjRdES0QyWAh9/KME1o1yOhpPUlYFccaBab1Dig0mK3eV5KvtMFimOu2ekOWMmWHO1iVYAqY3ja+C0lPKU7h3/CYUcIn8SFTtUwSaJsVbkPP4VpyqcJD7w99yU7lwl5LRriezl/1Ie/4cVbDN3ZtAzCt4OUYWo/0nbsETQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5VlMeftaCoOgHP26z/lG7BxBebTX/5t1H4OpB6Znyd4=; b=NdN/ARTCSKhTTpL0yUBmKkuKb3wMJZTi/FuTbR+H+lRftQy3k0mUoTLe1XflxIQvajnDD0wvC/rXkzbgfSCJ7EMLs1dHugjSUiEVccDg4AQNJYc4QCh2vz2lOOFMApcftzjS0PVpspKa/5lC80SHV6IdFTEaMSELChUWk6IjqTM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) by SN7PR12MB8057.namprd12.prod.outlook.com (2603:10b6:806:34a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Thu, 9 Jan 2025 08:09:56 +0000 Received: from PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5]) by PH7PR12MB5685.namprd12.prod.outlook.com ([fe80::46fb:96f2:7667:7ca5%5]) with mapi id 15.20.8335.010; Thu, 9 Jan 2025 08:09:56 +0000 Message-ID: Date: Thu, 9 Jan 2025 09:09:46 +0100 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 01/12] dma-buf: Introduce dma_buf_get_pfn_unlocked() kAPI From: =?UTF-8?Q?Christian_K=C3=B6nig?= To: Xu Yilun , Jason Gunthorpe , Christoph Hellwig , Leon Romanovsky , kvm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, sumit.semwal@linaro.org, pbonzini@redhat.com, seanjc@google.com, alex.williamson@redhat.com, vivek.kasireddy@intel.com, dan.j.williams@intel.com, aik@amd.com, yilun.xu@intel.com, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, lukas@wunner.de, yan.y.zhao@intel.com, leon@kernel.org, baolu.lu@linux.intel.com, zhenzhong.duan@intel.com, tao1.su@intel.com References: <20250107142719.179636-1-yilun.xu@linux.intel.com> <20250107142719.179636-2-yilun.xu@linux.intel.com> <20250108132358.GP5556@nvidia.com> <20250108145843.GR5556@nvidia.com> <5a858e00-6fea-4a7a-93be-f23b66e00835@amd.com> <20250108162227.GT5556@nvidia.com> <58e97916-e6fd-41ef-84b4-bbf53ed0e8e4@amd.com> Content-Language: en-US In-Reply-To: <58e97916-e6fd-41ef-84b4-bbf53ed0e8e4@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR5P281CA0029.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f1::13) To PH7PR12MB5685.namprd12.prod.outlook.com (2603:10b6:510:13c::22) Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH7PR12MB5685:EE_|SN7PR12MB8057:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d81a712-e97f-48e6-c2ad-08dd308500b4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|366016|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?OHRpbmY5bGpwUUlyT1YxS0RZeWFGaWwwdnpQWExteUFVN2grbVJTSGUwTXJO?= =?utf-8?B?bmRiZXNjUTdLRFZDU2puSmtTTlAycGJ6Y0lXbkc0S1g3U2N6QytzeWlHYzNP?= =?utf-8?B?dXBsUlhud3NjbUpmWTJ3TTd3a3hTS1dVejB0bzAzSURMWGVyTVhCd0xmV1pQ?= =?utf-8?B?eEhkajhldVoyWTJNY05TZUphenJqNnc1VjVMT1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BSDI3YTIyWW1CZkxKeDhveDNFUm9NNGpyTTk2TjRJbmZWQUZX?= =?utf-8?B?MUlRRnNDZk5BZXB3VWk3OGJtMlV6eFpzVzJta251cGVwZzZLUjZ5Qms4L2Ry?= =?utf-8?B?ZzE3YVhpcXR0MkF1OXNad2xSRXZYdll2d3dNUnRlT2pVNm0xbnBhY0R0cjI1?= =?utf-8?B?dzhEN0pqamFEZ1FOSVIwYjZTaU9jbGhBN2VYRUprMTVhTGRrZngwZTVGK1Jv?= =?utf-8?B?ZFZXOFVtUXhkZVBjSFNCWnM1Mm44VUpwZDZXUmxjS0E3dGNMUnFmVWxPV0g0?= =?utf-8?B?LzZER0RYWG1xMk8vV3JOZFJTdHZ5Y1RTK25TU20yNXQxOTEvR0MwZXZXdndH?= =?utf-8?B?bkpyTkNUd1NVd1NHNnY2cTBHcWlBOUpFTml6NXozY3BZUFA5a3VFMFB5aDRs?= =?utf-8?Q?ECUwqV709FlJJpMi7nWQLXqeI?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d81a712-e97f-48e6-c2ad-08dd308500b4 X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB5685.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2025 08:09:56.0091 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5/maxXa1MuommCAMxKNk0JW3jCwK7lPq0UvAt9+JFmGvVzDJyiZC2lEXtKt/WB2F X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8057 Answering on my reply once more as pure text mail. I love AMDs mail servers. Cheers, Christian. Am 09.01.25 um 09:04 schrieb Christian König: > Am 08.01.25 um 20:22 schrieb Xu Yilun: >> On Wed, Jan 08, 2025 at 07:44:54PM +0100, Simona Vetter wrote: >>> On Wed, Jan 08, 2025 at 12:22:27PM -0400, Jason Gunthorpe wrote: >>>> On Wed, Jan 08, 2025 at 04:25:54PM +0100, Christian König wrote: >>>>> Am 08.01.25 um 15:58 schrieb Jason Gunthorpe: >>>>>> I have imagined a staged approach were DMABUF gets a new API that >>>>>> works with the new DMA API to do importer mapping with "P2P source >>>>>> information" and a gradual conversion. >>>>> To make it clear as maintainer of that subsystem I would reject such a step >>>>> with all I have. >>>> This is unexpected, so you want to just leave dmabuf broken? Do you >>>> have any plan to fix it, to fix the misuse of the DMA API, and all >>>> the problems I listed below? This is a big deal, it is causing real >>>> problems today. >>>> >>>> If it going to be like this I think we will stop trying to use dmabuf >>>> and do something simpler for vfio/kvm/iommufd :( >>> As the gal who help edit the og dma-buf spec 13 years ago, I think adding >>> pfn isn't a terrible idea. By design, dma-buf is the "everything is >>> optional" interface. And in the beginning, even consistent locking was >>> optional, but we've managed to fix that by now :-/ > > Well you were also the person who mangled the struct page pointers in > the scatterlist because people were abusing this and getting a bloody > nose :) > >>> Where I do agree with Christian is that stuffing pfn support into the >>> dma_buf_attachment interfaces feels a bit much wrong. >> So it could a dmabuf interface like mmap/vmap()? I was also wondering >> about that. But finally I start to use dma_buf_attachment interface >> because of leveraging existing buffer pin and move_notify. > > Exactly that's the point, sharing pfn doesn't work with the pin and > move_notify interfaces because of the MMU notifier approach Sima > mentioned. > >>>>> We have already gone down that road and it didn't worked at all and >>>>> was a really big pain to pull people back from it. >>>> Nobody has really seriously tried to improve the DMA API before, so I >>>> don't think this is true at all. >>> Aside, I really hope this finally happens! > > Sorry my fault. I was not talking about the DMA API, but rather that > people tried to look behind the curtain of DMA-buf backing stores. > > In other words all the fun we had with scatterlists and that people > try to modify the struct pages inside of them. > > Improving the DMA API is something I really really hope for as well. > >>>>>> 3) Importing devices need to know if they are working with PCI P2P >>>>>> addresses during mapping because they need to do things like turn on >>>>>> ATS on their DMA. As for multi-path we have the same hacks inside mlx5 >>>>>> today that assume DMABUFs are always P2P because we cannot determine >>>>>> if things are P2P or not after being DMA mapped. >>>>> Why would you need ATS on PCI P2P and not for system memory accesses? >>>> ATS has a significant performance cost. It is mandatory for PCI P2P, >>>> but ideally should be avoided for CPU memory. >>> Huh, I didn't know that. And yeah kinda means we've butchered the pci p2p >>> stuff a bit I guess ... > > Hui? Why should ATS be mandatory for PCI P2P? > > We have tons of production systems using PCI P2P without ATS. And it's > the first time I hear that. > >>>>>> 5) iommufd and kvm are both using CPU addresses without DMA. No >>>>>> exporter mapping is possible >>>>> We have customers using both KVM and XEN with DMA-buf, so I can clearly >>>>> confirm that this isn't true. >>>> Today they are mmaping the dma-buf into a VMA and then using KVM's >>>> follow_pfn() flow to extract the CPU pfn from the PTE. Any mmapable >>>> dma-buf must have a CPU PFN. >>>> >>>> Here Xu implements basically the same path, except without the VMA >>>> indirection, and it suddenly not OK? Illogical. >>> So the big difference is that for follow_pfn() you need mmu_notifier since >>> the mmap might move around, whereas with pfn smashed into >>> dma_buf_attachment you need dma_resv_lock rules, and the move_notify >>> callback if you go dynamic. >>> >>> So I guess my first question is, which locking rules do you want here for >>> pfn importers? >> follow_pfn() is unwanted for private MMIO, so dma_resv_lock. > > As Sima explained you either have follow_pfn() and mmu_notifier or you > have DMA addresses and dma_resv lock / dma_fence. > > Just giving out PFNs without some lifetime associated with them is one > of the major problems we faced before and really not something you can do. > >>> If mmu notifiers is fine, then I think the current approach of follow_pfn >>> should be ok. But if you instead dma_resv_lock rules (or the cpu mmap >>> somehow is an issue itself), then I think the clean design is create a new >> cpu mmap() is an issue, this series is aimed to eliminate userspace >> mapping for private MMIO resources. > > Why? > >>> separate access mechanism just for that. It would be the 5th or so (kernel >>> vmap, userspace mmap, dma_buf_attach and driver private stuff like >>> virtio_dma_buf.c where you access your buffer with a uuid), so really not >>> a big deal. >> OK, will think more about that. > > Please note that we have follow_pfn() + mmu_notifier working for > KVM/XEN with MMIO mappings and P2P. And that required exactly zero > DMA-buf changes :) > > I don't fully understand your use case, but I think it's quite likely > that we already have that working. > > Regards, > Christian. > >> Thanks, >> Yilun >> >>> And for non-contrived exporters we might be able to implement the other >>> access methods in terms of the pfn method generically, so this wouldn't >>> even be a terrible maintenance burden going forward. And meanwhile all the >>> contrived exporters just keep working as-is. >>> >>> The other part is that cpu mmap is optional, and there's plenty of strange >>> exporters who don't implement. But you can dma map the attachment into >>> plenty devices. This tends to mostly be a thing on SoC devices with some >>> very funky memory. But I guess you don't care about these use-case, so >>> should be ok. >>> >>> I couldn't come up with a good name for these pfn users, maybe >>> dma_buf_pfn_attachment? This does _not_ have a struct device, but maybe >>> some of these new p2p source specifiers (or a list of those which are >>> allowed, no idea how this would need to fit into the new dma api). >>> >>> Cheers, Sima >>> -- >>> Simona Vetter >>> Software Engineer, Intel Corporation >>> http://blog.ffwll.ch >