Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6279902imu; Wed, 30 Jan 2019 11:54:54 -0800 (PST) X-Google-Smtp-Source: AHgI3IaEOcRJ67jLl1IxzzbuQXUbl/eR5hI/kLOm0lUtCbFyUJdqHXcuucvDqJd4MrjT0tjOUvb5 X-Received: by 2002:a17:902:e01:: with SMTP id 1mr16915090plw.251.1548878094287; Wed, 30 Jan 2019 11:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548878094; cv=none; d=google.com; s=arc-20160816; b=L3+5Py5r7o5heNPpAGIbnQlHOT4Gi9HWRpeeqtloojtWh8gz6fQwAWJxJMrxY703CO S9xYKOwfPRViYiJfw1sfLJboWKufd5WwoU2Q4Lr65KyNUNubi9zKmQBKEsxwoXcen8k4 pxAgcuSLJLVeR2sM4wDmiKqO7kuUdpJFTYBKxOtzWabJr8w56b+B36OZTwEfLX+wLUAh WwtytQJ0Hi+tcvfA+ZoDDvX/aX46VswjcDvYBiFQBuwaa6P0+veC0qaoVItVS9sLSU+o LhqhZP3z4wlOM/JXnBZDkaNE636HFVXhoH8JQ86533SigtEFAhSsLkDiEGcjQmxnTIrk PJgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=UZOyb2K3qZ3k2izC2QpfIelAk/lnLJm+DT4s53M75qg=; b=BCG0n8vTQbRbkTsrRvea2O2EMDG2Afgl+GnaVaBI6EM6RjWMjy2iIeb1lZW+u6swkE 3g1bJl/cWGq23DWJedjATJjM9/o6ll+ejwAHmnv/Vdb22cIniqQ0igvJkPTlhC9rs4mE Oc8RXp/1XXozq4p+4kuExfiNE1gKtleODgssGzl0q4t0ZNbAT6PhzZuLGl84VjEpm9MX 7vpkmd14esGyxeHvVqyoinR8LlivD/M7ckiZf77UBePOV2riuJV71cOnOFDOLP9WH3Ms N2M/4BquvZaDDykK/0ZCm9PY1RtDpfW94aI+N1Ah7OEeW2QPf5wjPeF2s2T9Rtd75WIw ZA5w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d142si2277941pfd.93.2019.01.30.11.54.38; Wed, 30 Jan 2019 11:54:54 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733156AbfA3Tw7 (ORCPT + 99 others); Wed, 30 Jan 2019 14:52:59 -0500 Received: from ale.deltatee.com ([207.54.116.67]:40932 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728715AbfA3Tw6 (ORCPT ); Wed, 30 Jan 2019 14:52:58 -0500 Received: from s01061831bf6ec98c.cg.shawcable.net ([68.147.80.180] helo=[192.168.6.205]) by ale.deltatee.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1govui-0008T2-Ew; Wed, 30 Jan 2019 12:52:49 -0700 To: Jerome Glisse , Jason Gunthorpe Cc: "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" 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> <20190130192234.GD5061@redhat.com> From: Logan Gunthorpe Message-ID: <5a60507e-e781-d0a4-353e-32105ca7ace3@deltatee.com> Date: Wed, 30 Jan 2019 12:52:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190130192234.GD5061@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 68.147.80.180 X-SA-Exim-Rcpt-To: iommu@lists.linux-foundation.org, jroedel@suse.de, robin.murphy@arm.com, m.szyprowski@samsung.com, hch@lst.de, dri-devel@lists.freedesktop.org, linux-pci@vger.kernel.org, Felix.Kuehling@amd.com, christian.koenig@amd.com, bhelgaas@google.com, rafael@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, jgg@mellanox.com, jglisse@redhat.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [RFC PATCH 3/5] mm/vma: add support for peer to peer to device vma X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-01-30 12:22 p.m., Jerome Glisse wrote: > 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. I think we have to consider the struct pages to track the address space, not what backs it (essentially what HMM is doing). If we need to add operations for the driver to map the address space/struct pages back to physical memory then do that. Creating a whole new idea that's tied to userspace VMAs still seems wrong to me. Logan