Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1527033 > unrolled thread
| Started by | "Deucher, Alexander" <Alexander.Deucher@amd.com> |
|---|---|
| First post | 2016-11-21 21:40 +0100 |
| Last post | 2016-11-25 09:30 +0100 |
| Articles | 20 on this page of 28 — 8 participants |
Back to article view | Back to linux.kernel
Enabling peer to peer device transactions for PCIe devices "Deucher, Alexander" <Alexander.Deucher@amd.com> - 2016-11-21 21:40 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-22 19:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-22 21:10 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-22 21:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Daniel Vetter <daniel@ffwll.ch> - 2016-11-22 21:40 +0100
Re: Enabling peer to peer device transactions for PCIe devices Daniel Vetter <daniel@ffwll.ch> - 2016-11-22 22:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-22 22:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices "Sagalovitch, Serguei" <Serguei.Sagalovitch@amd.com> - 2016-11-22 23:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Daniel Vetter <daniel@ffwll.ch> - 2016-11-23 08:50 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dave Hansen <dave.hansen@linux.intel.com> - 2016-11-23 18:10 +0100
Re: Enabling peer to peer device transactions for PCIe devices Logan Gunthorpe <logang@deltatee.com> - 2016-11-23 18:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-23 19:50 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-23 20:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-23 20:10 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-23 20:40 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-23 21:40 +0100
Re: Enabling peer to peer device transactions for PCIe devices Logan Gunthorpe <logang@deltatee.com> - 2016-11-23 22:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-23 23:40 +0100
Re: Enabling peer to peer device transactions for PCIe devices Dan Williams <dan.j.williams@intel.com> - 2016-11-23 23:50 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-24 00:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-24 17:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Logan Gunthorpe <logang@deltatee.com> - 2016-11-24 19:00 +0100
Re: Enabling peer to peer device transactions for PCIe devices "Sagalovitch, Serguei" <Serguei.Sagalovitch@amd.com> - 2016-11-24 01:50 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-24 17:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Logan Gunthorpe <logang@deltatee.com> - 2016-11-24 02:30 +0100
Re: Enabling peer to peer device transactions for PCIe devices Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-11-24 17:50 +0100
Re: Enabling peer to peer device transactions for PCIe devices Logan Gunthorpe <logang@deltatee.com> - 2016-11-24 19:20 +0100
Re: Enabling peer to peer device transactions for PCIe devices Christoph Hellwig <hch@infradead.org> - 2016-11-25 09:30 +0100
Page 1 of 2 [1] 2 Next page →
| From | "Deucher, Alexander" <Alexander.Deucher@amd.com> |
|---|---|
| Date | 2016-11-21 21:40 +0100 |
| Subject | Enabling peer to peer device transactions for PCIe devices |
| Message-ID | <sG3xE-616-29@gated-at.bofh.it> |
This is certainly not the first time this has been brought up, but I'd like to try and get some consensus on the best way to move this forward. Allowing devices to talk directly improves performance and reduces latency by avoiding the use of staging buffers in system memory. Also in cases where both devices are behind a switch, it avoids the CPU entirely. Most current APIs (DirectGMA, PeerDirect, CUDA, HSA) that deal with this are pointer based. Ideally we'd be able to take a CPU virtual address and be able to get to a physical address taking into account IOMMUs, etc. Having struct pages for the memory would allow it to work more generally and wouldn't require as much explicit support in drivers that wanted to use it. Some use cases: 1. Storage devices streaming directly to GPU device memory 2. GPU device memory to GPU device memory streaming 3. DVB/V4L/SDI devices streaming directly to GPU device memory 4. DVB/V4L/SDI devices streaming directly to storage devices Here is a relatively simple example of how this could work for testing. This is obviously not a complete solution. - Device memory will be registered with Linux memory sub-system by created corresponding struct page structures for device memory - get_user_pages_fast() will return corresponding struct pages when CPU address points to the device memory - put_page() will deal with struct pages for device memory Previously proposed solutions and related proposals: 1.P2P DMA DMA-API/PCI map_peer_resource support for peer-to-peer (http://www.spinics.net/lists/linux-pci/msg44560.html) Pros: Low impact, already largely reviewed. Cons: requires explicit support in all drivers that want to support it, doesn't handle S/G in device memory. 2. ZONE_DEVICE IO Direct I/O and DMA for persistent memory (https://lwn.net/Articles/672457/) Add support for ZONE_DEVICE IO memory with struct pages. (https://patchwork.kernel.org/patch/8583221/) Pro: Doesn't waste system memory for ZONE metadata Cons: CPU access to ZONE metadata slow, may be lost, corrupted on device reset. 3. DMA-BUF RDMA subsystem DMA-BUF support (http://www.spinics.net/lists/linux-rdma/msg38748.html) Pros: uses existing dma-buf interface Cons: dma-buf is handle based, requires explicit dma-buf support in drivers. 4. iopmem iopmem : A block device for PCIe memory (https://lwn.net/Articles/703895/) 5. HMM Heterogeneous Memory Management (http://lkml.iu.edu/hypermail/linux/kernel/1611.2/02473.html) 6. Some new mmap-like interface that takes a userptr and a length and returns a dma-buf and offset? Alex
[toc] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-22 19:20 +0100 |
| Message-ID | <sGnPH-2mW-1@gated-at.bofh.it> |
| In reply to | #1527033 |
On Mon, Nov 21, 2016 at 12:36 PM, Deucher, Alexander <Alexander.Deucher@amd.com> wrote: > This is certainly not the first time this has been brought up, but I'd like to try and get some consensus on the best way to move this forward. Allowing devices to talk directly improves performance and reduces latency by avoiding the use of staging buffers in system memory. Also in cases where both devices are behind a switch, it avoids the CPU entirely. Most current APIs (DirectGMA, PeerDirect, CUDA, HSA) that deal with this are pointer based. Ideally we'd be able to take a CPU virtual address and be able to get to a physical address taking into account IOMMUs, etc. Having struct pages for the memory would allow it to work more generally and wouldn't require as much explicit support in drivers that wanted to use it. > > Some use cases: > 1. Storage devices streaming directly to GPU device memory > 2. GPU device memory to GPU device memory streaming > 3. DVB/V4L/SDI devices streaming directly to GPU device memory > 4. DVB/V4L/SDI devices streaming directly to storage devices > > Here is a relatively simple example of how this could work for testing. This is obviously not a complete solution. > - Device memory will be registered with Linux memory sub-system by created corresponding struct page structures for device memory > - get_user_pages_fast() will return corresponding struct pages when CPU address points to the device memory > - put_page() will deal with struct pages for device memory > [..] > 4. iopmem > iopmem : A block device for PCIe memory (https://lwn.net/Articles/703895/) The change I suggest for this particular approach is to switch to "device-DAX" [1]. I.e. a character device for establishing DAX mappings rather than a block device plus a DAX filesystem. The pro of this approach is standard user pointers and struct pages rather than a new construct. The con is that this is done via an interface separate from the existing gpu and storage device. For example it would require a /dev/dax instance alongside a /dev/nvme interface, but I don't see that as a significant blocking concern. [1]: https://lists.01.org/pipermail/linux-nvdimm/2016-October/007496.html
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-22 21:10 +0100 |
| Message-ID | <sGpya-3s5-37@gated-at.bofh.it> |
| In reply to | #1527824 |
On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch <serguei.sagalovitch@amd.com> wrote: > Dan, > > I personally like "device-DAX" idea but my concerns are: > > - How well it will co-exists with the DRM infrastructure / implementations > in part dealing with CPU pointers? Inside the kernel a device-DAX range is "just memory" in the sense that you can perform pfn_to_page() on it and issue I/O, but the vma is not migratable. To be honest I do not know how well that co-exists with drm infrastructure. > - How well we will be able to handle case when we need to "move"/"evict" > memory/data to the new location so CPU pointer should point to the new > physical location/address > (and may be not in PCI device memory at all)? So, device-DAX deliberately avoids support for in-kernel migration or overcommit. Those cases are left to the core mm or drm. The device-dax interface is for cases where all that is needed is a direct-mapping to a statically-allocated physical-address range be it persistent memory or some other special reserved memory range.
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-22 21:30 +0100 |
| Message-ID | <sGpRw-3CL-39@gated-at.bofh.it> |
| In reply to | #1527892 |
On Tue, Nov 22, 2016 at 12:10 PM, Daniel Vetter <daniel@ffwll.ch> wrote: > On Tue, Nov 22, 2016 at 9:01 PM, Dan Williams <dan.j.williams@intel.com> wrote: >> On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch >> <serguei.sagalovitch@amd.com> wrote: >>> I personally like "device-DAX" idea but my concerns are: >>> >>> - How well it will co-exists with the DRM infrastructure / implementations >>> in part dealing with CPU pointers? >> >> Inside the kernel a device-DAX range is "just memory" in the sense >> that you can perform pfn_to_page() on it and issue I/O, but the vma is >> not migratable. To be honest I do not know how well that co-exists >> with drm infrastructure. >> >>> - How well we will be able to handle case when we need to "move"/"evict" >>> memory/data to the new location so CPU pointer should point to the new >>> physical location/address >>> (and may be not in PCI device memory at all)? >> >> So, device-DAX deliberately avoids support for in-kernel migration or >> overcommit. Those cases are left to the core mm or drm. The device-dax >> interface is for cases where all that is needed is a direct-mapping to >> a statically-allocated physical-address range be it persistent memory >> or some other special reserved memory range. > > For some of the fancy use-cases (e.g. to be comparable to what HMM can > pull off) I think we want all the magic in core mm, i.e. migration and > overcommit. At least that seems to be the very strong drive in all > general-purpose gpu abstractions and implementations, where memory is > allocated with malloc, and then mapped/moved into vram/gpu address > space through some magic, but still visible on both the cpu and gpu > side in some form. Special device to allocate memory, and not being > able to migrate stuff around sound like misfeatures from that pov. Agreed. For general purpose P2P use cases where all you want is direct-I/O to a memory range that happens to be on a PCIe device then I think a special device fits the bill. For gpu P2P use cases that already have migration/overcommit expectations then it is not a good fit.
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2016-11-22 21:40 +0100 |
| Message-ID | <sGpRw-3CL-41@gated-at.bofh.it> |
| In reply to | #1527892 |
On Tue, Nov 22, 2016 at 9:01 PM, Dan Williams <dan.j.williams@intel.com> wrote: > On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch > <serguei.sagalovitch@amd.com> wrote: >> I personally like "device-DAX" idea but my concerns are: >> >> - How well it will co-exists with the DRM infrastructure / implementations >> in part dealing with CPU pointers? > > Inside the kernel a device-DAX range is "just memory" in the sense > that you can perform pfn_to_page() on it and issue I/O, but the vma is > not migratable. To be honest I do not know how well that co-exists > with drm infrastructure. > >> - How well we will be able to handle case when we need to "move"/"evict" >> memory/data to the new location so CPU pointer should point to the new >> physical location/address >> (and may be not in PCI device memory at all)? > > So, device-DAX deliberately avoids support for in-kernel migration or > overcommit. Those cases are left to the core mm or drm. The device-dax > interface is for cases where all that is needed is a direct-mapping to > a statically-allocated physical-address range be it persistent memory > or some other special reserved memory range. For some of the fancy use-cases (e.g. to be comparable to what HMM can pull off) I think we want all the magic in core mm, i.e. migration and overcommit. At least that seems to be the very strong drive in all general-purpose gpu abstractions and implementations, where memory is allocated with malloc, and then mapped/moved into vram/gpu address space through some magic, but still visible on both the cpu and gpu side in some form. Special device to allocate memory, and not being able to migrate stuff around sound like misfeatures from that pov. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2016-11-22 22:20 +0100 |
| Message-ID | <sGqDT-493-31@gated-at.bofh.it> |
| In reply to | #1527909 |
On Tue, Nov 22, 2016 at 9:35 PM, Serguei Sagalovitch <serguei.sagalovitch@amd.com> wrote: > > On 2016-11-22 03:10 PM, Daniel Vetter wrote: >> >> On Tue, Nov 22, 2016 at 9:01 PM, Dan Williams <dan.j.williams@intel.com> >> wrote: >>> >>> On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch >>> <serguei.sagalovitch@amd.com> wrote: >>>> >>>> I personally like "device-DAX" idea but my concerns are: >>>> >>>> - How well it will co-exists with the DRM infrastructure / >>>> implementations >>>> in part dealing with CPU pointers? >>> >>> Inside the kernel a device-DAX range is "just memory" in the sense >>> that you can perform pfn_to_page() on it and issue I/O, but the vma is >>> not migratable. To be honest I do not know how well that co-exists >>> with drm infrastructure. >>> >>>> - How well we will be able to handle case when we need to >>>> "move"/"evict" >>>> memory/data to the new location so CPU pointer should point to the >>>> new >>>> physical location/address >>>> (and may be not in PCI device memory at all)? >>> >>> So, device-DAX deliberately avoids support for in-kernel migration or >>> overcommit. Those cases are left to the core mm or drm. The device-dax >>> interface is for cases where all that is needed is a direct-mapping to >>> a statically-allocated physical-address range be it persistent memory >>> or some other special reserved memory range. >> >> For some of the fancy use-cases (e.g. to be comparable to what HMM can >> pull off) I think we want all the magic in core mm, i.e. migration and >> overcommit. At least that seems to be the very strong drive in all >> general-purpose gpu abstractions and implementations, where memory is >> allocated with malloc, and then mapped/moved into vram/gpu address >> space through some magic, > > It is possible that there is other way around: memory is requested to be > allocated and should be kept in vram for performance reason but due > to possible overcommit case we need at least temporally to "move" such > allocation to system memory. With migration I meant migrating both ways of course. And with stuff like numactl we can also influence where exactly the malloc'ed memory is allocated originally, at least if we'd expose the vram range as a very special numa node that happens to be far away and not hold any cpu cores. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-22 22:30 +0100 |
| Message-ID | <sGqNz-4cd-5@gated-at.bofh.it> |
| In reply to | #1527943 |
On Tue, Nov 22, 2016 at 1:03 PM, Daniel Vetter <daniel@ffwll.ch> wrote: > On Tue, Nov 22, 2016 at 9:35 PM, Serguei Sagalovitch > <serguei.sagalovitch@amd.com> wrote: >> >> On 2016-11-22 03:10 PM, Daniel Vetter wrote: >>> >>> On Tue, Nov 22, 2016 at 9:01 PM, Dan Williams <dan.j.williams@intel.com> >>> wrote: >>>> >>>> On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch >>>> <serguei.sagalovitch@amd.com> wrote: >>>>> >>>>> I personally like "device-DAX" idea but my concerns are: >>>>> >>>>> - How well it will co-exists with the DRM infrastructure / >>>>> implementations >>>>> in part dealing with CPU pointers? >>>> >>>> Inside the kernel a device-DAX range is "just memory" in the sense >>>> that you can perform pfn_to_page() on it and issue I/O, but the vma is >>>> not migratable. To be honest I do not know how well that co-exists >>>> with drm infrastructure. >>>> >>>>> - How well we will be able to handle case when we need to >>>>> "move"/"evict" >>>>> memory/data to the new location so CPU pointer should point to the >>>>> new >>>>> physical location/address >>>>> (and may be not in PCI device memory at all)? >>>> >>>> So, device-DAX deliberately avoids support for in-kernel migration or >>>> overcommit. Those cases are left to the core mm or drm. The device-dax >>>> interface is for cases where all that is needed is a direct-mapping to >>>> a statically-allocated physical-address range be it persistent memory >>>> or some other special reserved memory range. >>> >>> For some of the fancy use-cases (e.g. to be comparable to what HMM can >>> pull off) I think we want all the magic in core mm, i.e. migration and >>> overcommit. At least that seems to be the very strong drive in all >>> general-purpose gpu abstractions and implementations, where memory is >>> allocated with malloc, and then mapped/moved into vram/gpu address >>> space through some magic, >> >> It is possible that there is other way around: memory is requested to be >> allocated and should be kept in vram for performance reason but due >> to possible overcommit case we need at least temporally to "move" such >> allocation to system memory. > > With migration I meant migrating both ways of course. And with stuff > like numactl we can also influence where exactly the malloc'ed memory > is allocated originally, at least if we'd expose the vram range as a > very special numa node that happens to be far away and not hold any > cpu cores. I don't think we should be using numa distance to reverse engineer a certain allocation behavior. The latency data should be truthful, but you're right we'll need a mechanism to keep general purpose allocations out of that range by default. Btw, strict isolation is another design point of device-dax, but I think in this case we're describing something between the two extremes of full isolation and full compatibility with existing numactl apis.
[toc] | [prev] | [next] | [standalone]
| From | "Sagalovitch, Serguei" <Serguei.Sagalovitch@amd.com> |
|---|---|
| Date | 2016-11-22 23:30 +0100 |
| Message-ID | <sGrJD-4Po-9@gated-at.bofh.it> |
| In reply to | #1527944 |
> I don't think we should be using numa distance to reverse engineer a
> certain allocation behavior. The latency data should be truthful, but
> you're right we'll need a mechanism to keep general purpose
> allocations out of that range by default.
Just to clarify: Do you propose/thinking to utilize NUMA API for
such (VRAM) allocations?
[toc] | [prev] | [next] | [standalone]
| From | Daniel Vetter <daniel@ffwll.ch> |
|---|---|
| Date | 2016-11-23 08:50 +0100 |
| Message-ID | <sGAtz-1VC-1@gated-at.bofh.it> |
| In reply to | #1527944 |
On Tue, Nov 22, 2016 at 01:21:03PM -0800, Dan Williams wrote: > On Tue, Nov 22, 2016 at 1:03 PM, Daniel Vetter <daniel@ffwll.ch> wrote: > > On Tue, Nov 22, 2016 at 9:35 PM, Serguei Sagalovitch > > <serguei.sagalovitch@amd.com> wrote: > >> > >> On 2016-11-22 03:10 PM, Daniel Vetter wrote: > >>> > >>> On Tue, Nov 22, 2016 at 9:01 PM, Dan Williams <dan.j.williams@intel.com> > >>> wrote: > >>>> > >>>> On Tue, Nov 22, 2016 at 10:59 AM, Serguei Sagalovitch > >>>> <serguei.sagalovitch@amd.com> wrote: > >>>>> > >>>>> I personally like "device-DAX" idea but my concerns are: > >>>>> > >>>>> - How well it will co-exists with the DRM infrastructure / > >>>>> implementations > >>>>> in part dealing with CPU pointers? > >>>> > >>>> Inside the kernel a device-DAX range is "just memory" in the sense > >>>> that you can perform pfn_to_page() on it and issue I/O, but the vma is > >>>> not migratable. To be honest I do not know how well that co-exists > >>>> with drm infrastructure. > >>>> > >>>>> - How well we will be able to handle case when we need to > >>>>> "move"/"evict" > >>>>> memory/data to the new location so CPU pointer should point to the > >>>>> new > >>>>> physical location/address > >>>>> (and may be not in PCI device memory at all)? > >>>> > >>>> So, device-DAX deliberately avoids support for in-kernel migration or > >>>> overcommit. Those cases are left to the core mm or drm. The device-dax > >>>> interface is for cases where all that is needed is a direct-mapping to > >>>> a statically-allocated physical-address range be it persistent memory > >>>> or some other special reserved memory range. > >>> > >>> For some of the fancy use-cases (e.g. to be comparable to what HMM can > >>> pull off) I think we want all the magic in core mm, i.e. migration and > >>> overcommit. At least that seems to be the very strong drive in all > >>> general-purpose gpu abstractions and implementations, where memory is > >>> allocated with malloc, and then mapped/moved into vram/gpu address > >>> space through some magic, > >> > >> It is possible that there is other way around: memory is requested to be > >> allocated and should be kept in vram for performance reason but due > >> to possible overcommit case we need at least temporally to "move" such > >> allocation to system memory. > > > > With migration I meant migrating both ways of course. And with stuff > > like numactl we can also influence where exactly the malloc'ed memory > > is allocated originally, at least if we'd expose the vram range as a > > very special numa node that happens to be far away and not hold any > > cpu cores. > > I don't think we should be using numa distance to reverse engineer a > certain allocation behavior. The latency data should be truthful, but > you're right we'll need a mechanism to keep general purpose > allocations out of that range by default. Btw, strict isolation is > another design point of device-dax, but I think in this case we're > describing something between the two extremes of full isolation and > full compatibility with existing numactl apis. Yes, agreed. My idea with exposing vram sections using numa nodes wasn't to reuse all the existing allocation policies directly, those won't work. So at boot-up your default numa policy would exclude any vram nodes. But I think (as an -mm layman) that numa gives us a lot of the tools and policy interface that we need to implement what we want for gpus. Wrt isolation: There's a sliding scale of what different users expect, from full auto everything, including migrating pages around if needed to full isolation all seems to be on the table. As long as we keep vram nodes out of any default allocation numasets, full isolation should be possible. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
[toc] | [prev] | [next] | [standalone]
| From | Dave Hansen <dave.hansen@linux.intel.com> |
|---|---|
| Date | 2016-11-23 18:10 +0100 |
| Message-ID | <sGJdv-7F0-11@gated-at.bofh.it> |
| In reply to | #1528163 |
On 11/22/2016 11:49 PM, Daniel Vetter wrote: > Yes, agreed. My idea with exposing vram sections using numa nodes wasn't > to reuse all the existing allocation policies directly, those won't work. > So at boot-up your default numa policy would exclude any vram nodes. > > But I think (as an -mm layman) that numa gives us a lot of the tools and > policy interface that we need to implement what we want for gpus. Are you suggesting creating NUMA nodes for video RAM (I assume that's what you mean by vram) where that RAM is not at all CPU-accessible?
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2016-11-23 18:20 +0100 |
| Message-ID | <sGJnb-7Id-21@gated-at.bofh.it> |
| In reply to | #1527824 |
Hey, On 22/11/16 11:59 AM, Serguei Sagalovitch wrote: > - How well we will be able to handle case when we need to "move"/"evict" > memory/data to the new location so CPU pointer should point to the > new physical location/address > (and may be not in PCI device memory at all)? IMO any memory that has been registered for a P2P transaction should be locked from being evicted. So if there's a get_user_pages call it needs to be pinned until the put_page. The main issue being with the RDMA case: handling an eviction when a chunk of memory has been registered as an MR would be very tricky. The MR may be relied upon by another host and the kernel would have to inform user-space the MR was invalid then user-space would have to tell the remote application. This seems like a lot of burden to place on applications and may be subject to timing issues. Either that or all RDMA applications need to be written with the assumption that their target memory could go away at any time. More generally, if you tell one PCI device to do a DMA transfer to another PCI device's BAR space, and the target memory gets evicted then DMA transaction needs to be aborted which means every driver doing the transfer would need special support for this. If the memory can be relied on to not be evicted than existing drivers should work unmodified (ie O_DIRECT to/from an NVMe card would just work). I feel the better approach is to pin memory subject to P2P transactions as is typically done with DMA transfers to main memory. Logan
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-23 19:50 +0100 |
| Message-ID | <sGKMh-5s-11@gated-at.bofh.it> |
| In reply to | #1528611 |
On Wed, Nov 23, 2016 at 9:27 AM, Bart Van Assche <bart.vanassche@sandisk.com> wrote: > On 11/23/2016 09:13 AM, Logan Gunthorpe wrote: >> >> IMO any memory that has been registered for a P2P transaction should be >> locked from being evicted. So if there's a get_user_pages call it needs >> to be pinned until the put_page. The main issue being with the RDMA >> case: handling an eviction when a chunk of memory has been registered as >> an MR would be very tricky. The MR may be relied upon by another host >> and the kernel would have to inform user-space the MR was invalid then >> user-space would have to tell the remote application. > > > Hello Logan, > > Are you aware that the Linux kernel already supports ODP (On Demand Paging)? > See also the output of git grep -nHi on.demand.paging. See also > https://www.openfabrics.org/images/eventpresos/workshops2014/DevWorkshop/presos/Tuesday/pdf/04_ODP_update.pdf. > I don't think that was designed for the case where the backing memory is a special/static physical address range rather than anonymous "System RAM", right? I think we should handle the graphics P2P concerns separately from the general P2P-DMA case since the latter does not require the higher order memory management facilities. Using ZONE_DEVICE/DAX mappings to avoid changes to every driver that wants to support P2P-DMA separately from typical DMA still seems the path of least resistance.
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-23 20:20 +0100 |
| Message-ID | <sGLfj-uo-3@gated-at.bofh.it> |
| In reply to | #1528689 |
On Wed, Nov 23, 2016 at 10:40:47AM -0800, Dan Williams wrote: > I don't think that was designed for the case where the backing memory > is a special/static physical address range rather than anonymous > "System RAM", right? The hardware doesn't care where the memory is. ODP is just a generic mechanism to provide demand-fault behavior for a mirrored page table. ODP has the same issue as everything else, it needs to translate a page table entry into a DMA address, and we have no API to do that when the page table points to peer-peer memory. Jason
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-23 20:10 +0100 |
| Message-ID | <sGL5E-rk-23@gated-at.bofh.it> |
| In reply to | #1528611 |
On Wed, Nov 23, 2016 at 10:13:03AM -0700, Logan Gunthorpe wrote: > an MR would be very tricky. The MR may be relied upon by another host > and the kernel would have to inform user-space the MR was invalid then > user-space would have to tell the remote application. As Bart says, it would be best to be combined with something like Mellanox's ODP MRs, which allows a page to be evicted and then trigger a CPU interrupt if a DMA is attempted so it can be brought back. This includes the usual fencing mechanism so the CPU can block, flush, and then evict a page coherently. This is the general direction the industry is going in: Link PCI DMA directly to dynamic user page tabels, including support for demand faulting and synchronicity. Mellanox ODP is a rough implementation of mirroring a process's page table via the kernel, while IBM's CAPI (and CCIX, PCI ATS?) is probably a good example of where this is ultimately headed. CAPI allows a PCI DMA to directly target an ASID associated with a user process and then use the usual CPU machinery to do the page translation for the DMA. This includes page faults for evicted pages, and obviously allows eviction and migration.. So, of all the solutions in the original list, I would discard anything that isn't VMA focused. Emulating what CAPI does in hardware with software is probably the best choice, or we have to do it all again when CAPI style hardware broadly rolls out :( DAX and GPU allocators should create VMAs and manipulate them in the usual way to achieve migration, windowing, cache&mirror, movement or swap of the potentially peer-peer memory pages. They would have to respect the usual rules for a VMA, including pinning. DMA drivers would use the usual approaches for dealing with DMA from a VMA: short term pin or long term coherent translation mirror. So, to my view (looking from RDMA), the main problem with peer-peer is how do you DMA translate VMA's that point at non struct page memory? Does HMM solve the peer-peer problem? Does it do it generically or only for drivers that are mirroring translation tables? From a RDMA perspective we could use something other than get_user_pages() to pin and DMA translate a VMA if the core community could decide on an API. eg get_user_dma_sg() would probably be quite usable. Jason
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-23 20:40 +0100 |
| Message-ID | <sGLyF-Aw-5@gated-at.bofh.it> |
| In reply to | #1528701 |
On Wed, Nov 23, 2016 at 02:14:40PM -0500, Serguei Sagalovitch wrote: > > On 2016-11-23 02:05 PM, Jason Gunthorpe wrote: > >As Bart says, it would be best to be combined with something like > >Mellanox's ODP MRs, which allows a page to be evicted and then trigger > >a CPU interrupt if a DMA is attempted so it can be brought back. > Please note that in the general case (including MR one) we could have > "page fault" from the different PCIe device. So all PCIe device must > be synchronized. Standard RDMA MRs require pinned pages, the DMA address cannot change while the MR exists (there is no hardware support for this at all), so page faulting from any other device is out of the question while they exist. This is the same requirement as typical simple driver DMA which requires pages pinned until the simple device completes DMA. ODP RDMA MRs do not require that, they just page fault like the CPU or really anything and the kernel has to make sense of concurrant page faults from multiple sources. The upshot is that GPU scenarios that rely on highly dynamic virtual->physical translation cannot sanely be combined with standard long-life RDMA MRs. Certainly, any solution for GPUs must follow the typical page pinning semantics, changing the DMA address of a page must be blocked while any DMA is in progress. > >Does HMM solve the peer-peer problem? Does it do it generically or > >only for drivers that are mirroring translation tables? > In current form HMM doesn't solve peer-peer problem. Currently it allow > "mirroring" of "malloc" memory on GPU which is not always what needed. > Additionally there is need to have opportunity to share VRAM allocations > between different processes. Humm, so it can be removed from Alexander's list then :\ As Dan suggested, maybe we need to do both. Some kind of fix for get_user_pages() for smaller mappings (eg ZONE_DEVICE) and a mandatory API conversion to get_user_dma_sg() for other cases? Jason
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-23 21:40 +0100 |
| Message-ID | <sGMuJ-1d5-7@gated-at.bofh.it> |
| In reply to | #1528710 |
On Wed, Nov 23, 2016 at 02:58:38PM -0500, Serguei Sagalovitch wrote: > We do not want to have "highly" dynamic translation due to > performance cost. We need to support "overcommit" but would > like to minimize impact. To support RDMA MRs for GPU/VRAM/PCIe > device memory (which is must) we need either globally force > pinning for the scope of "get_user_pages() / "put_pages" or have > special handling for RDMA MRs and similar cases. As I said, there is no possible special handling. Standard IB hardware does not support changing the DMA address once a MR is created. Forget about doing that. Only ODP hardware allows changing the DMA address on the fly, and it works at the page table level. We do not need special handling for RDMA. > Generally it could be difficult to correctly handle "DMA in > progress" due to the facts that (a) DMA could originate from > numerous PCIe devices simultaneously including requests to > receive network data. We handle all of this today in kernel via the page pinning mechanism. This needs to be copied into peer-peer memory and GPU memory schemes as well. A pinned page means the DMA address channot be changed and there is active non-CPU access to it. Any hardware that does not support page table mirroring must go this route. > (b) in HSA case DMA could originated from user space without kernel > driver knowledge. So without corresponding h/w support > everywhere I do not see how it could be solved effectively. All true user triggered DMA must go through some kind of coherent page table mirroring scheme (eg this is what CAPI does, presumably AMDs HSA is similar). A page table mirroring scheme is basically the same as what ODP does. Like I said, this is the direction the industry seems to be moving in, so any solution here should focus on VMAs/page tables as the way to link the peer-peer devices. To me this means at least items #1 and #3 should be removed from Alexander's list. Jason
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2016-11-23 22:20 +0100 |
| Message-ID | <sGN7r-1Fi-5@gated-at.bofh.it> |
| In reply to | #1528763 |
On 23/11/16 01:33 PM, Jason Gunthorpe wrote: > On Wed, Nov 23, 2016 at 02:58:38PM -0500, Serguei Sagalovitch wrote: > >> We do not want to have "highly" dynamic translation due to >> performance cost. We need to support "overcommit" but would >> like to minimize impact. To support RDMA MRs for GPU/VRAM/PCIe >> device memory (which is must) we need either globally force >> pinning for the scope of "get_user_pages() / "put_pages" or have >> special handling for RDMA MRs and similar cases. > > As I said, there is no possible special handling. Standard IB hardware > does not support changing the DMA address once a MR is created. Forget > about doing that. Yeah, that's essentially the point I was trying to make. Not to mention all the other unrelated hardware that can't DMA to an address that might disappear mid-transfer. > Only ODP hardware allows changing the DMA address on the fly, and it > works at the page table level. We do not need special handling for > RDMA. I am aware of ODP but, noted by others, it doesn't provide a general solution to the points above. > Like I said, this is the direction the industry seems to be moving in, > so any solution here should focus on VMAs/page tables as the way to link > the peer-peer devices. Yes, this was the appeal to us of using ZONE_DEVICE. > To me this means at least items #1 and #3 should be removed from > Alexander's list. It's also worth noting that #4 makes use of ZONE_DEVICE (#2) so they are really the same option. iopmem is really just one way to get BAR addresses to user-space while inside the kernel it's ZONE_DEVICE. Logan
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-23 23:40 +0100 |
| Message-ID | <sGOmR-2pg-21@gated-at.bofh.it> |
| In reply to | #1528780 |
On Wed, Nov 23, 2016 at 02:11:29PM -0700, Logan Gunthorpe wrote: > > As I said, there is no possible special handling. Standard IB hardware > > does not support changing the DMA address once a MR is created. Forget > > about doing that. > > Yeah, that's essentially the point I was trying to make. Not to mention > all the other unrelated hardware that can't DMA to an address that might > disappear mid-transfer. Right, it is impossible to ask for generic page migration with ongoing DMA. That is simply not supported by any of the hardware at all. > > Only ODP hardware allows changing the DMA address on the fly, and it > > works at the page table level. We do not need special handling for > > RDMA. > > I am aware of ODP but, noted by others, it doesn't provide a general > solution to the points above. How do you mean? Perhaps I am not following what Serguei is asking for, but I understood the desire was for a complex GPU allocator that could migrate pages between GPU and CPU memory under control of the GPU driver, among other things. The desire is for DMA to continue to work even after these migrations happen. Page table mirroring *is* the general solution for this problem. The GPU driver controls the VMA and the DMA driver mirrors that VMA. Do you know of another option that doesn't just degenerate to page table mirroring?? Remember, there are two facets to the RDMA ODP implementation, I feel there is some confusion here.. The crucial part for this discussion is the ability to fence and block DMA for a specific range. This is the hardware capability that lets page migration happen: fence&block DMA, migrate page, update page table in HCA, unblock DMA. Without that hardware support the DMA address must be unchanging, and there is nothing we can do about it. This is why standard IB hardware must have fixed MRs - it lacks the fence&block capability. The other part is the page faulting implementation, but that is not required, and to Serguei's point, is not desired for GPU anyhow. > > To me this means at least items #1 and #3 should be removed from > > Alexander's list. > > It's also worth noting that #4 makes use of ZONE_DEVICE (#2) so they are > really the same option. iopmem is really just one way to get BAR > addresses to user-space while inside the kernel it's ZONE_DEVICE. Seems fine for RDMA? Didn't we just strike off everything on the list except #2? :\ Jason
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2016-11-23 23:50 +0100 |
| Message-ID | <sGOwy-2sG-3@gated-at.bofh.it> |
| In reply to | #1528812 |
On Wed, Nov 23, 2016 at 1:55 PM, Jason Gunthorpe <jgunthorpe@obsidianresearch.com> wrote: > On Wed, Nov 23, 2016 at 02:11:29PM -0700, Logan Gunthorpe wrote: >> > As I said, there is no possible special handling. Standard IB hardware >> > does not support changing the DMA address once a MR is created. Forget >> > about doing that. >> >> Yeah, that's essentially the point I was trying to make. Not to mention >> all the other unrelated hardware that can't DMA to an address that might >> disappear mid-transfer. > > Right, it is impossible to ask for generic page migration with ongoing > DMA. That is simply not supported by any of the hardware at all. > >> > Only ODP hardware allows changing the DMA address on the fly, and it >> > works at the page table level. We do not need special handling for >> > RDMA. >> >> I am aware of ODP but, noted by others, it doesn't provide a general >> solution to the points above. > > How do you mean? > > Perhaps I am not following what Serguei is asking for, but I > understood the desire was for a complex GPU allocator that could > migrate pages between GPU and CPU memory under control of the GPU > driver, among other things. The desire is for DMA to continue to work > even after these migrations happen. > > Page table mirroring *is* the general solution for this problem. The > GPU driver controls the VMA and the DMA driver mirrors that VMA. > > Do you know of another option that doesn't just degenerate to page > table mirroring?? > > Remember, there are two facets to the RDMA ODP implementation, I feel > there is some confusion here.. > > The crucial part for this discussion is the ability to fence and block > DMA for a specific range. This is the hardware capability that lets > page migration happen: fence&block DMA, migrate page, update page > table in HCA, unblock DMA. Wait, ODP requires migratable pages, ZONE_DEVICE pages are not migratable. You can't replace a PCIe mapping with just any other System RAM physical address, right? At least not without a filesystem recording where things went, but at point we're no longer talking about the base P2P-DMA mapping mechanism and are instead talking about something like pnfs-rdma to a DAX filesystem.
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2016-11-24 00:30 +0100 |
| Message-ID | <sGP9g-2Vz-25@gated-at.bofh.it> |
| In reply to | #1528817 |
On Wed, Nov 23, 2016 at 02:42:12PM -0800, Dan Williams wrote: > > The crucial part for this discussion is the ability to fence and block > > DMA for a specific range. This is the hardware capability that lets > > page migration happen: fence&block DMA, migrate page, update page > > table in HCA, unblock DMA. > > Wait, ODP requires migratable pages, ZONE_DEVICE pages are not > migratable. Does it? I didn't think so.. Does ZONE_DEVICE break MMU notifiers/etc or something? There is certainly nothing about the hardware that cares about ZONE_DEVICE vs System memory. I used 'migration' in the broader sense of doing any transformation to the page such that the DMA address changes - not the specific kernel MM process... > You can't replace a PCIe mapping with just any other System RAM > physical address, right? I thought that was exactly what HMM was trying to do? Migrate pages between CPU and GPU memory as needed. As Serguei has said this process needs to be driven by the GPU driver. The peer-peer issue is how do you do that while RDMA is possible on those pages, because when the page migrates to GPU memory you want the RDMA to follow it seamlessly. This is why page table mirroring is the best solution - use the existing mm machinery to link the DMA driver and whatever is controlling the VMA. > At least not without a filesystem recording where things went, but > at point we're no longer talking about the base P2P-DMA mapping In the filesystem/DAX case, it would be the filesystem that initiates any change in the page physical address. ODP *follows* changes in the VMA it does not cause any change in address mapping. That has to be done by whoever is in charge of the VMA. > something like pnfs-rdma to a DAX filesystem. Something in the kernel (ie nfs-rdma) would be entirely different. We generally don't do long lived mappings in the kernel for RDMA (certainly not for NFS), so it is much more like your basic every day DMA operation: map, execute, unmap. We probably don't need to use page table mirroring for this. ODP comes in when userpsace mmaps a DAX file and then tries to use it for RDMA. Page table mirroring lets the DAX filesystem decide to move the backing pages at any time. When it wants to do that it interacts with the MM in the usual way which links to ODP and makes sure the migration is seamless. Jason
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web