Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6252877imu; Wed, 30 Jan 2019 11:24:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN5iXTpbM75tmCzKfV60/Qwppbg1nCsScoM98yv/qMiWLQG1G4rOiz5gLi6xRzDtLPa898vc X-Received: by 2002:a62:d005:: with SMTP id p5mr31861892pfg.175.1548876247618; Wed, 30 Jan 2019 11:24:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548876247; cv=none; d=google.com; s=arc-20160816; b=PdNGQDvDjLVZAduXUCJg+u9zmKF9OB5A+OzndncbmfB+2vaVceQmAJI5nPAbR+8QOE 73HMsD1fHKCA7jfmX9VhUMNePU2t1RRrpPz1wtH5QEJH2OmG/d6OAPLHMfKAUEDn+Kuk 5z+VV/K0sbeOFLTR4tSAQehONbDzTMNsvaLsUsqnUOCibEd8SBRMsJDpQl97DW9GfWlk S3jAUxVlkNHgKJRA7AgUpMolKDuzTrmTcmnPGTimYj3w893Ws6jmxhjGaXW0GzoOIcbW wa0jahNaz9U9yZ/wmUN/VkCaUxi4bOuYbIY9fxscavt/DYRvME+fpGUszyavVkTRIkV1 HZ1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=zT8e5huoZbXjddEuC956GQ6+r8DBmDIOfeKc8YBpZW8=; b=1Fa8C+HO6GDUcn9K8Tu05TM1AvwA6GRVb56Vvf33s8RgIvRlbWJJU3aB9CmBiu1eyI AKwvJSFIcKohkmQLt4p55wZGlmtmvnB+Xww1NF9NXGEkVAtK8EsgPqV37nLoLn+F94cb Ok+86NDp/7+OUqn46g9o0zSuvhkS5pNEgkwf/F4ha5/pyVu7PMRoNkRLhU7Ds/CV8EFD RkVsB42c6MkmsUHWI0I1ojMqv8KNJ/dFglPe3cImpa7PxbKzpXfLmteOUjBcORTNZ4Y1 BaTVpWca5NbVGI8uhlnd0K6+x7PSurNl/kIok80d52n33zYKTyTEfEqMIiBgP8oi2eKO DzKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b61si2340758plb.70.2019.01.30.11.23.51; Wed, 30 Jan 2019 11:24:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387587AbfA3TWj (ORCPT + 99 others); Wed, 30 Jan 2019 14:22:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50712 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387545AbfA3TWj (ORCPT ); Wed, 30 Jan 2019 14:22:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9CA64C04959F; Wed, 30 Jan 2019 19:22:38 +0000 (UTC) Received: from redhat.com (ovpn-126-0.rdu2.redhat.com [10.10.126.0]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A81C45D96F; Wed, 30 Jan 2019 19:22:36 +0000 (UTC) Date: Wed, 30 Jan 2019 14:22:34 -0500 From: Jerome Glisse To: Jason Gunthorpe Cc: Logan Gunthorpe , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , "Rafael J . Wysocki" , Bjorn Helgaas , Christian Koenig , Felix Kuehling , "linux-pci@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Joerg Roedel , "iommu@lists.linux-foundation.org" Subject: Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma Message-ID: <20190130192234.GD5061@redhat.com> References: <99c228c6-ef96-7594-cb43-78931966c75d@deltatee.com> <20190129205749.GN3176@redhat.com> <2b704e96-9c7c-3024-b87f-364b9ba22208@deltatee.com> <20190129215028.GQ3176@redhat.com> <20190129234752.GR3176@redhat.com> <655a335c-ab91-d1fc-1ed3-b5f0d37c6226@deltatee.com> <20190130041841.GB30598@mellanox.com> <20190130185652.GB17080@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190130185652.GB17080@mellanox.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 30 Jan 2019 19:22:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 30, 2019 at 06:56:59PM +0000, Jason Gunthorpe wrote: > On Wed, Jan 30, 2019 at 10:17:27AM -0700, Logan Gunthorpe wrote: > > > > > > On 2019-01-29 9:18 p.m., Jason Gunthorpe wrote: > > > Every attempt to give BAR memory to struct page has run into major > > > trouble, IMHO, so I like that this approach avoids that. > > > > > > And if you don't have struct page then the only kernel object left to > > > hang meta data off is the VMA itself. > > > > > > It seems very similar to the existing P2P work between in-kernel > > > consumers, just that VMA is now mediating a general user space driven > > > discovery process instead of being hard wired into a driver. > > > > But the kernel now has P2P bars backed by struct pages and it works > > well. > > I don't think it works that well.. > > We ended up with a 'sgl' that is not really a sgl, and doesn't work > with many of the common SGL patterns. sg_copy_buffer doesn't work, > dma_map, doesn't work, sg_page doesn't work quite right, etc. > > Only nvme and rdma got the special hacks to make them understand these > p2p-sgls, and I'm still not convinced some of the RDMA drivers that > want access to CPU addresses from the SGL (rxe, usnic, hfi, qib) don't > break in this scenario. > > Since the SGLs become broken, it pretty much means there is no path to > make GUP work generically, we have to go through and make everything > safe to use with p2p-sgls before allowing GUP. Which, frankly, sounds > impossible with all the competing objections. > > But GPU seems to have a problem unrelated to this - what Jerome wants > is to have two faulting domains for VMA's - visible-to-cpu and > visible-to-dma. The new op is essentially faulting the pages into the > visible-to-dma category and leaving them invisible-to-cpu. > > So that duality would still have to exists, and I think p2p_map/unmap > is a much simpler implementation than trying to create some kind of > special PTE in the VMA.. > > At least for RDMA, struct page or not doesn't really matter. > > We can make struct pages for the BAR the same way NVMe does. GPU is > probably the same, just with more mememory at stake? > > And maybe this should be the first implementation. The p2p_map VMA > operation should return a SGL and the caller should do the existing > pci_p2pdma_map_sg() flow.. For GPU it would not work, GPU might want to use main memory (because it is running out of BAR space) it is a lot easier if the p2p_map callback calls the right dma map function (for page or io) rather than having to define some format that would pass down the information. > > Worry about optimizing away the struct page overhead later? Struct page do not fit well for GPU as the BAR address can be reprogram to point to any page inside the device memory (think 256M BAR versus 16GB device memory). Forcing struct page on GPU driver would require major surgery to the GPU driver inner working and there is no benefit to have from the struct page. So it is hard to justify this. Cheers, J?r?me