Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1039563lqt; Tue, 19 Mar 2024 10:54:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXosG+ZZuFy16dM9zNyGrc+DmVvemNaG3bWIk81pBTw229do/rSMjVuBgmhSGktwIphwVaH3A1rCNVVqG7sHGpxPk5Sdo1wPeNWl9Mk3Q== X-Google-Smtp-Source: AGHT+IEsTWtsSPVH35NB5ck0tfvFfPQh8HNtjJsc6VNQD/99KRBP+bm2ErfSPHJAUhJ6m8O9E5WW X-Received: by 2002:a05:6402:2898:b0:568:b447:163d with SMTP id eg24-20020a056402289800b00568b447163dmr2468435edb.9.1710870893106; Tue, 19 Mar 2024 10:54:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710870893; cv=pass; d=google.com; s=arc-20160816; b=ft/xDfVHVrKcUb1RfN2OCLbeE3DH87y7qfdMnmrpR7lwjAjEsynchsHSn3R3Q4qD8C SvUg+DL8YnSuHZS13uCGXDKlOBTN05gTslEjF+zKud9wGut7FP2/1pVIj0PnUdKizpmc iIX9JKuYTLQdpBFZ+hAYXmQqzC/ObDeT1w0d0zrM+R2c5rWewxJM62BoyOBAAXI8+eUK wcat/qB8Q9hf/fmFYwNxRMxwSJSBZUouqao9p9Ygvn76oI48U5/5MUJmGQOXnT0jkEf6 G/9JOdE+T95lm5Wpmsg65Fg2lAtuhJ+l01VBSOe07X6Ox4lfPPjAUacb4S6eXh5X2Ika v7iA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=D7H3WfkclcieHpBg89GTkZxaS3r7II1qq9xezXi0hVM=; fh=7lN46OkU8lMWhNjYxAyfxZ9xLteexoLI8dVZYbMEu0A=; b=FaHBiQxjrKy/kXIGUD5RUeRbxpnHJydRV3hUh+0GGdwqouRl8oqKI/VpeHljKIdog1 5ycGIPKOQnLVgu3OC11BopvcEo5DCO8qHPuFOrN/h7WvVCb8R74W02UHs0R+EcOlCgx7 BPuTT0zak0shqPlPo80hWf6noG2SbiaEYTUxm1WvEKo6n9qFbkW7dDYHYuLkAQ6wwXkm 0+s0ppgVpL11SElcXJvqtzkjors1P4XMnKFeDrZQgnXJF6F16hAGojQBj/TlVjwhd7GZ onjD196030WDMfcBcxwa7ybA8kR8rKthxGUim5G1UOSPCsQVUG5gNFr/VdKDgCfAME4c B8tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=fiSQBkCC; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-107953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107953-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q5-20020a056402248500b00568c18ba317si3551473eda.610.2024.03.19.10.54.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 10:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=fiSQBkCC; arc=pass (i=1 spf=pass spfdomain=ziepe.ca dkim=pass dkdomain=ziepe.ca); spf=pass (google.com: domain of linux-kernel+bounces-107953-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107953-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A5B471F246CF for ; Tue, 19 Mar 2024 17:54:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5677B2C1A7; Tue, 19 Mar 2024 17:54:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="fiSQBkCC" Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67B0125569 for ; Tue, 19 Mar 2024 17:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710870870; cv=none; b=s+lo/RXCzuoFCwP/UqN5vs9RNffHL73tK0VJmTDY/XXICl9bchLAjoqZkr3JGdRepNh/Piw2GSZrBrOBSkPKd/n+26XphCm2yDjcfYHrQuhB6KPnLVHec/H7H63ADHHyg1noPpYAis8RvGxA9Ou/jAiNemoaMPGNk3FSn/+rvao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710870870; c=relaxed/simple; bh=Ao9hwGJl4g/w2wap7dwa291kK0JPcDjzl89BAK46zVI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rlcqCx4Z6NjIOcR2RdkzbZwJaLmG/XKopeq+Auo9ht3wIKFSh6zed9sX9iR9pUeftQG9bWCvXObaTMxQWCaREHPUt8+Sd/q5I8324fgtKu+LHSdfrBcnTPYzr7HeRIecDfVwWoEkmVjPPKt5xU6WHHNVc2w6w9DbnB3MND4jTDU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=fiSQBkCC; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6e673ffbd79so3220302a34.2 for ; Tue, 19 Mar 2024 10:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1710870867; x=1711475667; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=D7H3WfkclcieHpBg89GTkZxaS3r7II1qq9xezXi0hVM=; b=fiSQBkCCoYVMvJ7hKOIWrIUIQtWnudcxCwuRJ3SDAmfcoUJ3LKW/OSOt0XJv0ppBom r1b7EUVzGEU34UNgXl0Xub2wg6VFMC2Ly8xIcAY78NHYVcXijpAahLq3KrnWiEfepI+P K3bumXlIk6qPY69qQGjZxTur6D4Xb2RFW85NT0G9m4KZ2ko8G/knkqvxD72SooihwK+Z WaMPr00ehDA2unHvbCRW9HCn68HsloTpQ5rMYa4Uyj9mIfkuCzQfSnPQejaSEhgNZfAo vO51olQglynGFY2d82cFKRUtHCtTWvMs7dccTYup7df0Q48rdZL147340AdvneF3HcRw D7dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710870867; x=1711475667; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=D7H3WfkclcieHpBg89GTkZxaS3r7II1qq9xezXi0hVM=; b=DGiY6DARn5G4xMIa/Ste3u/GqyEr+imhL2P4SvxOVjFdEEHcpNL1ySJ7RB1t9dX/OL n7r29R/I/rK/4Dgtx5OXEKF3Qmx1ExkbARvIG6LmT32pJ5/EXoa3KH7XDvR/V7oU3Mpu CohrGKM2b2hSEtm1bCPFEBijD3iPGaJD/qraYZtHkDYaSBzYgZUXvXnrNIIJ2EVmV54C /FaHdOzCyi5TLrrh1FsvSv35C3D/7DWUONEziQgwynusO3H5BVdLDtSMAQJ8G03QIFru 1v3nrac8Qb2mUfRZefusiunUDqEiKvfg+kVISwGhXtHwkyZQHWyP89PKfUx7qU8mE1Py ZW+Q== X-Forwarded-Encrypted: i=1; AJvYcCXSNwXuzULtKrNt0arha3ajW/8iyOdONf7xIHj+GdU3p1A/T3cPamIEj6/moRVMbPtQZKP4csenePK/ZcejugtO7+ckCxn9swaMACNp X-Gm-Message-State: AOJu0YyIPhJ2B/tAOCvXxeeSI1H1QD8UgqbqDUf7fF1+jfzgN2v+FbkA X221VC+eJ6dNnWInHcTYHUIc52DWSt8oEgj7qIztpFfk4AWV5f1+4R+0+fRdcK0= X-Received: by 2002:a05:6870:d20e:b0:222:99cb:2215 with SMTP id g14-20020a056870d20e00b0022299cb2215mr3580439oac.28.1710870867581; Tue, 19 Mar 2024 10:54:27 -0700 (PDT) Received: from ziepe.ca ([12.97.180.36]) by smtp.gmail.com with ESMTPSA id gh11-20020a056638698b00b00477716fcbb8sm2429986jab.40.2024.03.19.10.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 10:54:26 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1rmbVk-001elO-4L; Tue, 19 Mar 2024 12:36:20 -0300 Date: Tue, 19 Mar 2024 12:36:20 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: Leon Romanovsky , Robin Murphy , Marek Szyprowski , Joerg Roedel , Will Deacon , Chaitanya Kulkarni , Jonathan Corbet , Jens Axboe , Keith Busch , Sagi Grimberg , Yishai Hadas , Shameer Kolothum , Kevin Tian , Alex Williamson , =?utf-8?B?SsOpcsO0bWU=?= Glisse , Andrew Morton , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, iommu@lists.linux.dev, linux-nvme@lists.infradead.org, kvm@vger.kernel.org, linux-mm@kvack.org, Bart Van Assche , Damien Le Moal , Amir Goldstein , "josef@toxicpanda.com" , "Martin K. Petersen" , "daniel@iogearbox.net" , Dan Williams , "jack@suse.com" , Zhu Yanjun Subject: Re: [RFC RESEND 00/16] Split IOMMU DMA mapping operation to two steps Message-ID: <20240319153620.GB66976@ziepe.ca> References: <20240306154328.GM9225@ziepe.ca> <20240306162022.GB28427@lst.de> <20240306174456.GO9225@ziepe.ca> <20240306221400.GA8663@lst.de> <20240307000036.GP9225@ziepe.ca> <20240307150505.GA28978@lst.de> <20240307210116.GQ9225@ziepe.ca> <20240308164920.GA17991@lst.de> <20240308202342.GZ9225@ziepe.ca> <20240309161418.GA27113@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240309161418.GA27113@lst.de> On Sat, Mar 09, 2024 at 05:14:18PM +0100, Christoph Hellwig wrote: > On Fri, Mar 08, 2024 at 04:23:42PM -0400, Jason Gunthorpe wrote: > > > The DMA API callers really need to know what is P2P or not for > > > various reasons. And they should generally have that information > > > available, either from pin_user_pages that needs to special case > > > it or from the in-kernel I/O submitter that build it from P2P and > > > normal memory. > > > > I think that is a BIO thing. RDMA just calls with FOLL_PCI_P2PDMA and > > shoves the resulting page list into in a scattertable. It never checks > > if any returned page is P2P - it has no reason to care. dma_map_sg() > > does all the work. > > Right now it does, but that's not really a good interface. If we have > a pin_user_pages variant that only pins until the next relevant P2P > boundary and tells you about we can significantly simplify the overall > interface. Sorry for the delay, I was away.. I kind of understand your thinking on the DMA side, but I don't see how this is good for users of the API beyond BIO. How will this make RDMA better? We have one MR, the MR has pages, the HW doesn't care about the SW distinction of p2p, swiotlb, direct, encrypted, iommu, etc. It needs to create one HW page list for whatever user VA range was given. Or worse, whatever thing is inside a DMABUF from a DRM driver. DMABUF's can have a (dynamic!) mixture of P2P and regular AFAIK based on the GPU's migration behavior. Or triple worse, ODP can dynamically change on a page by page basis the type depending on what hmm_range_fault() returns. So I take it as a requirement that RDMA MUST make single MR's out of a hodgepodge of page types. RDMA MRs cannot be split. Multiple MR's are not a functional replacement for a single MR. Go back to the start of what are we trying to do here: 1) Make a DMA API that can support hmm_range_fault() users in a sensible and performant way 2) Make a DMA API that can support RDMA MR's backed by DMABUF's, and user VA's without restriction 3) Allow to remove scatterlist from BIO paths 4) Provide a DMABUF API that is not scatterlist that can feed into the new DMA API - again supporting DMABUF's hodgepodge of types. I'd like to do all of these things. I know 3 is your highest priority, but it is my lowest :) So, if the new API can only do uniformity I immediately loose #1 - hmm_range_fault() can't guarentee anything, so it looses the IOVA optimization that Leon's patches illustrate. For uniformity #2 probably needs multiple DMA API "transactions". This is doable, but it is less performant than one "transaction". #3 is perfectly happy because BIO already creates uniformity #4 is like #2, there is not guarenteed uniformity inside DMABUF so every DMABUF importer needs to take some complexity to deal with it. There are many DMABUF importers so this feels like a poor API abstraction if we force everyone there to take on complexity. So I'm just not seeing why this would be better. I think Leon's series shows the cost of non-uniformity support is actually pretty small. Still, we could do better, if the caller can optionally indicate it knows it has uniformity then that can be optimized futher. I'd like to find something that works well for all of the above, and I think abstracting non-uniformity at the API level is important for the above reasons. Can we tweak what Leon has done to keep the hmm_range_fault support and non-uniformity for RDMA but add a uniformity optimized flow for BIO? Jason