Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1621832 > unrolled thread
| Started by | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| First post | 2017-04-12 08:30 +0200 |
| Last post | 2017-04-16 07:40 +0200 |
| Articles | 20 on this page of 26 — 7 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-12 08:30 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-12 19:20 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-13 00:00 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-13 23:30 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-14 00:40 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Bjorn Helgaas <helgaas@kernel.org> - 2017-04-14 01:30 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-04-14 06:20 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 06:50 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@au1.ibm.com> - 2017-04-14 13:50 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-14 15:00 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-14 13:40 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-14 19:40 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Bjorn Helgaas <helgaas@kernel.org> - 2017-04-14 21:10 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-15 00:10 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-15 19:50 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Dan Williams <dan.j.williams@intel.com> - 2017-04-16 00:10 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-16 05:10 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-16 06:50 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Dan Williams <dan.j.williams@intel.com> - 2017-04-16 18:00 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-16 18:40 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-17 01:00 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Knut Omang <knut.omang@oracle.com> - 2017-04-24 09:40 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-24 18:20 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-17 00:30 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2017-04-16 00:20 +0200
Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Logan Gunthorpe <logang@deltatee.com> - 2017-04-16 07:40 +0200
Page 1 of 2 [1] 2 Next page →
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-12 08:30 +0200 |
| Subject | Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory |
| Message-ID | <tvjWV-13J-1@gated-at.bofh.it> |
On Thu, 2017-03-30 at 16:12 -0600, Logan Gunthorpe wrote: > Hello, > > As discussed at LSF/MM we'd like to present our work to enable > copy offload support in NVMe fabrics RDMA targets. We'd appreciate > some review and feedback from the community on our direction. > This series is not intended to go upstream at this point. > > The concept here is to use memory that's exposed on a PCI BAR as > data buffers in the NVME target code such that data can be transferred > from an RDMA NIC to the special memory and then directly to an NVMe > device avoiding system memory entirely. The upside of this is better > QoS for applications running on the CPU utilizing memory and lower > PCI bandwidth required to the CPU (such that systems could be designed > with fewer lanes connected to the CPU). However, presently, the trade-off > is currently a reduction in overall throughput. (Largely due to hardware > issues that would certainly improve in the future). Another issue of course is that not all systems support P2P between host bridges :-) (Though almost all switches can enable it). > Due to these trade-offs we've designed the system to only enable using > the PCI memory in cases where the NIC, NVMe devices and memory are all > behind the same PCI switch. Ok. I suppose that's a reasonable starting point. Do I haven't looked at the patches in detail yet but it would be nice if that policy was in a well isolated component so it can potentially be affected by arch/platform code. Do you handle funky address translation too ? IE. the fact that the PCI addresses aren't the same as the CPU physical addresses for a BAR ? > This will mean many setups that could likely > work well will not be supported so that we can be more confident it > will work and not place any responsibility on the user to understand > their topology. (We've chosen to go this route based on feedback we > received at LSF). > > In order to enable this functionality we introduce a new p2pmem device > which can be instantiated by PCI drivers. The device will register some > PCI memory as ZONE_DEVICE and provide an genalloc based allocator for > users of these devices to get buffers. I don't completely understand this. This is actual memory on the PCI bus ? Where does it come from ? Or are you just trying to create struct pages that cover your PCIe DMA target ? > We give an example of enabling > p2p memory with the cxgb4 driver, however currently these devices have > some hardware issues that prevent their use so we will likely be > dropping this patch in the future. Ideally, we'd want to enable this > functionality with NVME CMB buffers, however we don't have any hardware > with this feature at this time. So correct me if I'm wrong, you are trying to create struct page's that map a PCIe BAR right ? I'm trying to understand how that interacts with what Jerome is doing for HMM. The reason is that the HMM currently creates the struct pages with "fake" PFNs pointing to a hole in the address space rather than covering the actual PCIe memory of the GPU. He does that to deal with the fact that some GPUs have a smaller aperture on PCIe than their total memory. However, I have asked him to only apply that policy if the aperture is indeed smaller, and if not, create struct pages that directly cover the PCIe BAR of the GPU instead, which will work better on systems or architecture that don't have a "pinhole" window limitation. However he was under the impression that this was going to collide with what you guys are doing, so I'm trying to understand how. > In nvmet-rdma, we attempt to get an appropriate p2pmem device at > queue creation time and if a suitable one is found we will use it for > all the (non-inlined) memory in the queue. An 'allow_p2pmem' configfs > attribute is also created which is required to be set before any p2pmem > is attempted. > > This patchset also includes a more controversial patch which provides an > interface for userspace to obtain p2pmem buffers through an mmap call on > a cdev. This enables userspace to fairly easily use p2pmem with RDMA and > O_DIRECT interfaces. However, the user would be entirely responsible for > knowing what their doing and inspecting sysfs to understand the pci > topology and only using it in sane situations. > > Thanks, > > Logan > > > Logan Gunthorpe (6): > Introduce Peer-to-Peer memory (p2pmem) device > nvmet: Use p2pmem in nvme target > scatterlist: Modify SG copy functions to support io memory. > nvmet: Be careful about using iomem accesses when dealing with p2pmem > p2pmem: Support device removal > p2pmem: Added char device user interface > > Steve Wise (2): > cxgb4: setup pcie memory window 4 and create p2pmem region > p2pmem: Add debugfs "stats" file > > drivers/memory/Kconfig | 5 + > drivers/memory/Makefile | 2 + > drivers/memory/p2pmem.c | 697 ++++++++++++++++++++++++ > drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 + > drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 97 +++- > drivers/net/ethernet/chelsio/cxgb4/t4_regs.h | 5 + > drivers/nvme/target/configfs.c | 31 ++ > drivers/nvme/target/core.c | 18 +- > drivers/nvme/target/fabrics-cmd.c | 28 +- > drivers/nvme/target/nvmet.h | 2 + > drivers/nvme/target/rdma.c | 183 +++++-- > drivers/scsi/scsi_debug.c | 7 +- > include/linux/p2pmem.h | 120 ++++ > include/linux/scatterlist.h | 7 +- > lib/scatterlist.c | 64 ++- > 15 files changed, 1189 insertions(+), 80 deletions(-) > create mode 100644 drivers/memory/p2pmem.c > create mode 100644 include/linux/p2pmem.h > > -- > 2.1.4
[toc] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-12 19:20 +0200 |
| Message-ID | <tvu5X-7gS-3@gated-at.bofh.it> |
| In reply to | #1621832 |
On 11/04/17 11:22 PM, Benjamin Herrenschmidt wrote: > Another issue of course is that not all systems support P2P > between host bridges :-) (Though almost all switches can enable it). Yes, I'm either going to just let the user enable and test or limit it to switches only to start. However, currently our bigger issue is working on a way to not violate iomem safety. > Ok. I suppose that's a reasonable starting point. Do I haven't looked > at the patches in detail yet but it would be nice if that policy was in > a well isolated component so it can potentially be affected by > arch/platform code. The policy is isolated in the new p2pmem driver. There's no reason the policy couldn't become arbitrarily complex with specific arch exceptions. It's just people would have to do the work to create those exceptions. > Do you handle funky address translation too ? IE. the fact that the PCI > addresses aren't the same as the CPU physical addresses for a BAR ? No, we use the CPU physical address of the BAR. If it's not mapped that way we can't use it. >> This will mean many setups that could likely >> work well will not be supported so that we can be more confident it >> will work and not place any responsibility on the user to understand >> their topology. (We've chosen to go this route based on feedback we >> received at LSF). >> >> In order to enable this functionality we introduce a new p2pmem device >> which can be instantiated by PCI drivers. The device will register some >> PCI memory as ZONE_DEVICE and provide an genalloc based allocator for >> users of these devices to get buffers. > > I don't completely understand this. This is actual memory on the PCI > bus ? Where does it come from ? Or are you just trying to create struct > pages that cover your PCIe DMA target ? Yes, the memory is on the PCI bus in a BAR. For now we have a special PCI card for this, but in the future it would likely be the CMB in an NVMe card. These patches create struct pages to map these BAR addresses using ZONE_DEVICE. > So correct me if I'm wrong, you are trying to create struct page's that > map a PCIe BAR right ? I'm trying to understand how that interacts with > what Jerome is doing for HMM. Yes, well we are using ZONE_DEVICE in the exact same way as the dax code is. These patches use the existing API with no modifications. As I understand it, HMM was using ZONE_DEVICE in a way that was quite different to how it was originally designed. > The reason is that the HMM currently creates the struct pages with > "fake" PFNs pointing to a hole in the address space rather than > covering the actual PCIe memory of the GPU. He does that to deal with > the fact that some GPUs have a smaller aperture on PCIe than their > total memory. I'm aware of what HMM is trying to do and although I'm not familiar with the intimate details, I saw it as fairly orthogonal to what we are attempting to do. > However, I have asked him to only apply that policy if the aperture is > indeed smaller, and if not, create struct pages that directly cover the > PCIe BAR of the GPU instead, which will work better on systems or > architecture that don't have a "pinhole" window limitation. > However he was under the impression that this was going to collide with > what you guys are doing, so I'm trying to understand how. I'm not sure I understand how either. However, I suspect if you collide with these patches then you'd also be breaking dax too. Logan
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-13 00:00 +0200 |
| Message-ID | <tvysV-1QL-3@gated-at.bofh.it> |
| In reply to | #1622386 |
On Wed, 2017-04-12 at 11:09 -0600, Logan Gunthorpe wrote: > > > Do you handle funky address translation too ? IE. the fact that the PCI > > addresses aren't the same as the CPU physical addresses for a BAR ? > > No, we use the CPU physical address of the BAR. If it's not mapped that > way we can't use it. Ok, you need to fix that or a bunch of architectures won't work. Look at pcibios_resource_to_bus() and pcibios_bus_to_resource(). They will perform the conversion between the struct resource content (CPU physical address) and the actual PCI bus side address. When behind the same switch you need to use PCI addresses. If one tries later to do P2P between host bridges (via the CPU fabric) things get more complex and one will have to use either CPU addresses or something else alltogether (probably would have to teach the arch DMA mapping routines to work with those struct pages you create and return the right thing). > > > This will mean many setups that could likely > > > work well will not be supported so that we can be more confident it > > > will work and not place any responsibility on the user to understand > > > their topology. (We've chosen to go this route based on feedback we > > > received at LSF). > > > > > > In order to enable this functionality we introduce a new p2pmem device > > > which can be instantiated by PCI drivers. The device will register some > > > PCI memory as ZONE_DEVICE and provide an genalloc based allocator for > > > users of these devices to get buffers. > > > > I don't completely understand this. This is actual memory on the PCI > > bus ? Where does it come from ? Or are you just trying to create struct > > pages that cover your PCIe DMA target ? > > Yes, the memory is on the PCI bus in a BAR. For now we have a special > PCI card for this, but in the future it would likely be the CMB in an > NVMe card. These patches create struct pages to map these BAR addresses > using ZONE_DEVICE. Ok. So ideally we'd want things like dma_map_* to be able to be fed those struct pages and do the right thing which is ... tricky, especially with the address translation I mentioned since the address will be different whether the initiator is on the same host bridge as the target or not. > > So correct me if I'm wrong, you are trying to create struct page's that > > map a PCIe BAR right ? I'm trying to understand how that interacts with > > what Jerome is doing for HMM. > > Yes, well we are using ZONE_DEVICE in the exact same way as the dax code > is. These patches use the existing API with no modifications. As I > understand it, HMM was using ZONE_DEVICE in a way that was quite > different to how it was originally designed. Sort-of. I don't see why there would be a conflict with the struct pages use though. Jerome can you chime in ? Jerome: It looks like they are just laying out struct page over a BAR which is the same thing I think you should do when the BAR is "large enough" for the GPU memory. The case where HMM uses "holes" in the address space for its struct page is somewhat orthogonal but I also see no conflict here. > > The reason is that the HMM currently creates the struct pages with > > "fake" PFNs pointing to a hole in the address space rather than > > covering the actual PCIe memory of the GPU. He does that to deal with > > the fact that some GPUs have a smaller aperture on PCIe than their > > total memory. > > I'm aware of what HMM is trying to do and although I'm not familiar with > the intimate details, I saw it as fairly orthogonal to what we are > attempting to do. Right. > > However, I have asked him to only apply that policy if the aperture is > > indeed smaller, and if not, create struct pages that directly cover the > > PCIe BAR of the GPU instead, which will work better on systems or > > architecture that don't have a "pinhole" window limitation. > > However he was under the impression that this was going to collide with > > what you guys are doing, so I'm trying to understand how. > > I'm not sure I understand how either. However, I suspect if you collide > with these patches then you'd also be breaking dax too. Possibly but as I said, I don't see why so I'll let Jerome chime in since he was under the impression that there was a conflict here :-) Cheers, Ben.
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-13 23:30 +0200 |
| Message-ID | <tvUts-jx-17@gated-at.bofh.it> |
| In reply to | #1622576 |
On 12/04/17 03:55 PM, Benjamin Herrenschmidt wrote: > Look at pcibios_resource_to_bus() and pcibios_bus_to_resource(). They > will perform the conversion between the struct resource content (CPU > physical address) and the actual PCI bus side address. Ah, thanks for the tip! On my system, this translation returns the same address so it was not necessary. And, yes, that means this would have to find its way into the dma mapping routine somehow. This means we'll eventually need a way to look-up the p2pmem device from the struct page. Which means we will likely need a new flag bit in the struct page or something. The big difficulty I see is testing. Do you know what architectures or in what circumstances are these translations used? > When behind the same switch you need to use PCI addresses. If one tries > later to do P2P between host bridges (via the CPU fabric) things get > more complex and one will have to use either CPU addresses or something > else alltogether (probably would have to teach the arch DMA mapping > routines to work with those struct pages you create and return the > right thing). Probably for starters we'd want to explicitly deny cases between host bridges and add that later if someone wants to do the testing. Thanks, Logan
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-14 00:40 +0200 |
| Message-ID | <tvVzb-11z-5@gated-at.bofh.it> |
| In reply to | #1623363 |
On Thu, 2017-04-13 at 15:22 -0600, Logan Gunthorpe wrote: > > On 12/04/17 03:55 PM, Benjamin Herrenschmidt wrote: > > Look at pcibios_resource_to_bus() and pcibios_bus_to_resource(). They > > will perform the conversion between the struct resource content (CPU > > physical address) and the actual PCI bus side address. > > Ah, thanks for the tip! On my system, this translation returns the same > address so it was not necessary. And, yes, that means this would have to > find its way into the dma mapping routine somehow. This means we'll > eventually need a way to look-up the p2pmem device from the struct page. > Which means we will likely need a new flag bit in the struct page or > something. The big difficulty I see is testing. Do you know what > architectures or in what circumstances are these translations used? I think a bunch of non-x86 architectures but I don't know which ones outside of powerpc. > > When behind the same switch you need to use PCI addresses. If one tries > > later to do P2P between host bridges (via the CPU fabric) things get > > more complex and one will have to use either CPU addresses or something > > else alltogether (probably would have to teach the arch DMA mapping > > routines to work with those struct pages you create and return the > > right thing). > > Probably for starters we'd want to explicitly deny cases between host > bridges and add that later if someone wants to do the testing. Cheers, Ben. > Thanks, > > Logan
[toc] | [prev] | [next] | [standalone]
| From | Bjorn Helgaas <helgaas@kernel.org> |
|---|---|
| Date | 2017-04-14 01:30 +0200 |
| Message-ID | <tvWlz-1Bt-7@gated-at.bofh.it> |
| In reply to | #1623363 |
On Thu, Apr 13, 2017 at 03:22:06PM -0600, Logan Gunthorpe wrote: > > > On 12/04/17 03:55 PM, Benjamin Herrenschmidt wrote: > > Look at pcibios_resource_to_bus() and pcibios_bus_to_resource(). They > > will perform the conversion between the struct resource content (CPU > > physical address) and the actual PCI bus side address. > > Ah, thanks for the tip! On my system, this translation returns the same > address so it was not necessary. And, yes, that means this would have to > find its way into the dma mapping routine somehow. This means we'll > eventually need a way to look-up the p2pmem device from the struct page. > Which means we will likely need a new flag bit in the struct page or > something. The big difficulty I see is testing. Do you know what > architectures or in what circumstances are these translations used? Any caller of pci_add_resource_offset() uses CPU addresses different from the PCI bus addresses (unless the offset is zero, of course). All ACPI platforms also support this translation (see "translation_offset"), though in most x86 systems the offset is zero. I'm aware of one x86 system that was tested with a non-zero offset but I don't think it was shipped that way. Bjorn
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-04-14 06:20 +0200 |
| Message-ID | <tw0Se-4NC-9@gated-at.bofh.it> |
| In reply to | #1623421 |
On Thu, Apr 13, 2017 at 06:26:31PM -0500, Bjorn Helgaas wrote: > > Ah, thanks for the tip! On my system, this translation returns the same > > address so it was not necessary. And, yes, that means this would have to > > find its way into the dma mapping routine somehow. This means we'll > > eventually need a way to look-up the p2pmem device from the struct page. > > Which means we will likely need a new flag bit in the struct page or > > something. The big difficulty I see is testing. Do you know what > > architectures or in what circumstances are these translations used? > > Any caller of pci_add_resource_offset() uses CPU addresses different from > the PCI bus addresses (unless the offset is zero, of course). All ACPI > platforms also support this translation (see "translation_offset"), though > in most x86 systems the offset is zero. I'm aware of one x86 system that > was tested with a non-zero offset but I don't think it was shipped that > way. I'd suggest just detecting if there is any translation in bus addresses anywhere and just hard disabling P2P on such systems. On modern hardware with 64 bit BARs there is very little reason to have translation, so I think this is a legacy feature. Jason
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-14 06:50 +0200 |
| Message-ID | <tw1lf-528-5@gated-at.bofh.it> |
| In reply to | #1623501 |
On 13/04/17 10:16 PM, Jason Gunthorpe wrote: > I'd suggest just detecting if there is any translation in bus > addresses anywhere and just hard disabling P2P on such systems. That's a fantastic suggestion. It simplifies things significantly. Unless there are any significant objections I think I will plan on doing that. > On modern hardware with 64 bit BARs there is very little reason to > have translation, so I think this is a legacy feature. Yes, p2pmem users are likely to be designing systems around it (ie JBOFs) and not trying to shoehorn it onto legacy architectures. At the very least, it makes sense to leave it out and if someone comes along who cares they can put in the effort to support the address translation. Thanks, Logan
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@au1.ibm.com> |
|---|---|
| Date | 2017-04-14 13:50 +0200 |
| Message-ID | <tw7TI-Aq-9@gated-at.bofh.it> |
| In reply to | #1623503 |
On Fri, 2017-04-14 at 21:37 +1000, Benjamin Herrenschmidt wrote: > On Thu, 2017-04-13 at 22:40 -0600, Logan Gunthorpe wrote: > > > > On 13/04/17 10:16 PM, Jason Gunthorpe wrote: > > > I'd suggest just detecting if there is any translation in bus > > > addresses anywhere and just hard disabling P2P on such systems. > > > > That's a fantastic suggestion. It simplifies things significantly. > > Unless there are any significant objections I think I will plan on > > doing > > that. > > I object. Note: It would also make your stuff fundamentally incompatible with KVM guest pass-through since KVM plays with remapping BARs all over the place. Ben. > > > On modern hardware with 64 bit BARs there is very little reason > > > to > > > have translation, so I think this is a legacy feature. > > > > Yes, p2pmem users are likely to be designing systems around it (ie > > JBOFs) and not trying to shoehorn it onto legacy architectures. > > > > At the very least, it makes sense to leave it out and if someone > > comes > > along who cares they can put in the effort to support the address > > translation. > > > > Thanks, > > > > Logan
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-14 15:00 +0200 |
| Message-ID | <tw7TI-Aq-11@gated-at.bofh.it> |
| In reply to | #1623503 |
On Thu, 2017-04-13 at 22:40 -0600, Logan Gunthorpe wrote: > > On 13/04/17 10:16 PM, Jason Gunthorpe wrote: > > I'd suggest just detecting if there is any translation in bus > > addresses anywhere and just hard disabling P2P on such systems. > > That's a fantastic suggestion. It simplifies things significantly. > Unless there are any significant objections I think I will plan on > doing > that. I object. > > On modern hardware with 64 bit BARs there is very little reason to > > have translation, so I think this is a legacy feature. > > Yes, p2pmem users are likely to be designing systems around it (ie > JBOFs) and not trying to shoehorn it onto legacy architectures. > > At the very least, it makes sense to leave it out and if someone > comes > along who cares they can put in the effort to support the address > translation. > > Thanks, > > Logan
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-14 13:40 +0200 |
| Message-ID | <tw7K1-x1-5@gated-at.bofh.it> |
| In reply to | #1623501 |
On Thu, 2017-04-13 at 22:16 -0600, Jason Gunthorpe wrote: > > Any caller of pci_add_resource_offset() uses CPU addresses different from > > the PCI bus addresses (unless the offset is zero, of course). All ACPI > > platforms also support this translation (see "translation_offset"), though > > in most x86 systems the offset is zero. I'm aware of one x86 system that > > was tested with a non-zero offset but I don't think it was shipped that > > way. > > I'd suggest just detecting if there is any translation in bus > addresses anywhere and just hard disabling P2P on such systems. I object to designing a subsystem that by design cannot work on whole categories of architectures out there. > On modern hardware with 64 bit BARs there is very little reason to > have translation, so I think this is a legacy feature. No it's not. Cheers, Ben.
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-14 19:40 +0200 |
| Message-ID | <twdmq-3Wz-19@gated-at.bofh.it> |
| In reply to | #1623641 |
On 14/04/17 05:37 AM, Benjamin Herrenschmidt wrote: > I object to designing a subsystem that by design cannot work on whole > categories of architectures out there. Hardly. That's extreme. We'd design a subsystem that works for the easy cases and needs more work to support the offset cases. It would not be designed in such a way that it could _never_ support those architectures. It would simply be such that it only permits use by the cases that are known to work. Then those cases could be expanded as time goes on and people work on adding more support. There's tons of stuff that needs to be done to get this upstream. I'd rather not require it to work for every possible architecture from the start. The testing alone would be impossible. Many subsystems start by working for x86 first and then adding support in other architectures later. (Often with that work done by the people who care about those systems and actually have the hardware to test with.) Logan
[toc] | [prev] | [next] | [standalone]
| From | Bjorn Helgaas <helgaas@kernel.org> |
|---|---|
| Date | 2017-04-14 21:10 +0200 |
| Message-ID | <tweLv-4WH-1@gated-at.bofh.it> |
| In reply to | #1623810 |
On Fri, Apr 14, 2017 at 11:30:14AM -0600, Logan Gunthorpe wrote: > On 14/04/17 05:37 AM, Benjamin Herrenschmidt wrote: > > I object to designing a subsystem that by design cannot work on whole > > categories of architectures out there. > > Hardly. That's extreme. We'd design a subsystem that works for the easy > cases and needs more work to support the offset cases. It would not be > designed in such a way that it could _never_ support those > architectures. It would simply be such that it only permits use by the > cases that are known to work. Then those cases could be expanded as time > goes on and people work on adding more support. I'm a little hesitant about excluding offset support, so I'd like to hear more about this. Is the issue related to PCI BARs that are not completely addressable by the CPU? If so, that sounds like a first-class issue that should be resolved up front because I don't think the PCI core in general would deal well with that. If all the PCI memory of interest is in fact addressable by the CPU, I would think it would be pretty straightforward to support offsets -- everywhere you currently use a PCI bus address, you just use the corresponding CPU physical address instead. > There's tons of stuff that needs to be done to get this upstream. I'd > rather not require it to work for every possible architecture from the > start. The testing alone would be impossible. Many subsystems start by > working for x86 first and then adding support in other architectures > later. (Often with that work done by the people who care about those > systems and actually have the hardware to test with.) I don't think exhaustive testing is that big a deal. PCI offset support is generic, so you shouldn't need any arch-specific code to deal with it. I'd rather have consistent support across the board, even though some arches might not be tested. I think that's simpler and better than adding checks to disable functionality on some arches merely on the grounds that it hasn't been tested there. Bjorn
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-15 00:10 +0200 |
| Message-ID | <twhzI-6JW-5@gated-at.bofh.it> |
| In reply to | #1623861 |
On Fri, 2017-04-14 at 14:04 -0500, Bjorn Helgaas wrote: > I'm a little hesitant about excluding offset support, so I'd like to > hear more about this. > > Is the issue related to PCI BARs that are not completely addressable > by the CPU? If so, that sounds like a first-class issue that should > be resolved up front because I don't think the PCI core in general > would deal well with that. > > If all the PCI memory of interest is in fact addressable by the CPU, > I would think it would be pretty straightforward to support offsets > -- > everywhere you currently use a PCI bus address, you just use the > corresponding CPU physical address instead. It's not *that* easy sadly. The reason is that normal dma map APIs assume the "target" of the DMAs are system memory, there is no way to pass it "another device", in a way that allows it to understand the offsets if needed. That said, dma_map will already be problematic when doing p2p behind the same bridge due to the fact that the iommu is not in the way so you can't use the arch standard ops there. So I assume the p2p code provides a way to address that too via special dma_ops ? Or wrappers ? Basically there are two very different ways you can do p2p, either behind the same host bridge or accross two host bridges: - Behind the same host bridge, you don't go through the iommu, which means that even if your target looks like a struct page, you can't just use dma_map_* on it because what you'll get back from that is an iommu token, not a sibling BAR offset. Additionally, if you use the target struct resource address, you will need to offset it to get back to the actual BAR value on the PCIe bus. - Behind different host bridges, then you go through the iommu and the host remapping. IE. that's actually the easy case. You can probably just use the normal iommu path and normal dma mapping ops, you just need to have your struct page representing the target device BAR *in CPU space* this time. So no offsetting required either. The problem is that the latter while seemingly easier, is also slower and not supported by all platforms and architectures (for example, POWER currently won't allow it, or rather only allows a store-only subset of it under special circumstances). So what people practically want to do is to have 2 devices behind a switch DMA'ing to/from each other. But that brings the 2 problems above. I don't fully understand how p2pmem "solves" that by creating struct pages. The offset problem is one issue. But there's the iommu issue as well, the driver cannot just use the normal dma_map ops. I haven't had a chance to look at the details of the patches but it's not clear from the description in patch 0 how that is solved. Cheers, Ben.
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-15 19:50 +0200 |
| Message-ID | <twzZD-15i-7@gated-at.bofh.it> |
| In reply to | #1623931 |
Thanks, Benjamin, for the summary of some of the issues. On 14/04/17 04:07 PM, Benjamin Herrenschmidt wrote > So I assume the p2p code provides a way to address that too via special > dma_ops ? Or wrappers ? Not at this time. We will probably need a way to ensure the iommus do not attempt to remap these addresses. Though if it does, I'd expect everything would still work you just wouldn't get the performance or traffic flow you are looking for. We've been testing with the software iommu which doesn't have this problem. > The problem is that the latter while seemingly easier, is also slower > and not supported by all platforms and architectures (for example, > POWER currently won't allow it, or rather only allows a store-only > subset of it under special circumstances). Yes, I think situations where we have to cross host bridges will remain unsupported by this work for a long time. There are two many cases where it just doesn't work or it performs too poorly to be useful. > I don't fully understand how p2pmem "solves" that by creating struct > pages. The offset problem is one issue. But there's the iommu issue as > well, the driver cannot just use the normal dma_map ops. We are not using a proper iommu and we are dealing with systems that have zero offset. This case is also easily supported. I expect fixing the iommus to not map these addresses would also be reasonably achievable. Logan
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2017-04-16 00:10 +0200 |
| Message-ID | <twE3f-3U6-1@gated-at.bofh.it> |
| In reply to | #1624122 |
On Sat, Apr 15, 2017 at 10:41 AM, Logan Gunthorpe <logang@deltatee.com> wrote: > Thanks, Benjamin, for the summary of some of the issues. > > On 14/04/17 04:07 PM, Benjamin Herrenschmidt wrote >> So I assume the p2p code provides a way to address that too via special >> dma_ops ? Or wrappers ? > > Not at this time. We will probably need a way to ensure the iommus do > not attempt to remap these addresses. Though if it does, I'd expect > everything would still work you just wouldn't get the performance or > traffic flow you are looking for. We've been testing with the software > iommu which doesn't have this problem. > >> The problem is that the latter while seemingly easier, is also slower >> and not supported by all platforms and architectures (for example, >> POWER currently won't allow it, or rather only allows a store-only >> subset of it under special circumstances). > > Yes, I think situations where we have to cross host bridges will remain > unsupported by this work for a long time. There are two many cases where > it just doesn't work or it performs too poorly to be useful. > >> I don't fully understand how p2pmem "solves" that by creating struct >> pages. The offset problem is one issue. But there's the iommu issue as >> well, the driver cannot just use the normal dma_map ops. > > We are not using a proper iommu and we are dealing with systems that > have zero offset. This case is also easily supported. I expect fixing > the iommus to not map these addresses would also be reasonably achievable. I'm wondering, since this is limited to support behind a single switch, if you could have a software-iommu hanging off that switch device object that knows how to catch and translate the non-zero offset bus address case. We have something like this with VMD driver, and I toyed with a soft pci bridge when trying to support AHCI+NVME bar remapping. When the dma api looks up the iommu for its device it hits this soft-iommu and that driver checks if the page is host memory or device memory to do the dma translation. You wouldn't need a bit in struct page, just a lookup to the hosting struct dev_pagemap in the is_zone_device_page() case and that can point you to p2p details.
[toc] | [prev] | [next] | [standalone]
| From | Benjamin Herrenschmidt <benh@kernel.crashing.org> |
|---|---|
| Date | 2017-04-16 05:10 +0200 |
| Message-ID | <twIJz-6Ug-1@gated-at.bofh.it> |
| In reply to | #1624138 |
On Sat, 2017-04-15 at 15:09 -0700, Dan Williams wrote: > I'm wondering, since this is limited to support behind a single > switch, if you could have a software-iommu hanging off that switch > device object that knows how to catch and translate the non-zero > offset bus address case. We have something like this with VMD driver, > and I toyed with a soft pci bridge when trying to support AHCI+NVME > bar remapping. When the dma api looks up the iommu for its device it > hits this soft-iommu and that driver checks if the page is host memory > or device memory to do the dma translation. You wouldn't need a bit in > struct page, just a lookup to the hosting struct dev_pagemap in the > is_zone_device_page() case and that can point you to p2p details. I was thinking about a hook in the arch DMA ops but that kind of wrapper might work instead indeed. However I'm not sure what's the best way to "instantiate" it. The main issue is that the DMA ops are a function of the initiator, not the target (since the target is supposed to be memory) so things are a bit awkward. One (user ?) would have to know that a given device "intends" to DMA directly to another device. This is awkward because in the ideal scenario, this isn't something the device knows. For example, one could want to have an existing NIC DMA directly to/from NVME pages or GPU pages. The NIC itself doesn't know the characteristic of these pages, but *something* needs to insert itself in the DMA ops of that bridge to make it possible. That's why I wonder if it's the struct page of the target that should be "marked" in such a way that the arch dma'ops can immediately catch that they belong to a device and might require "wrapped" operations. Are ZONE_DEVICE pages identifiable based on the struct page alone ? (a flag ?) That would allow us to keep a fast path for normal memory targets, but also have some kind of way to handle the special cases of such peer 2 peer (or also handle other type of peer to peer that don't necessarily involve PCI address wrangling but could require additional iommu bits). Just thinking out loud ... I don't have a firm idea or a design. But peer to peer is definitely a problem we need to tackle generically, the demand for it keeps coming up. Cheers, Ben.
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-16 06:50 +0200 |
| Message-ID | <twKil-7Me-3@gated-at.bofh.it> |
| In reply to | #1624148 |
On 15/04/17 09:01 PM, Benjamin Herrenschmidt wrote: > Are ZONE_DEVICE pages identifiable based on the struct page alone ? (a > flag ?) Well you can't use ZONE_DEVICE as an indicator. They may be regular RAM, (eg. pmem). It would need a separate flag indicating it is backed by iomem. Logan
[toc] | [prev] | [next] | [standalone]
| From | Dan Williams <dan.j.williams@intel.com> |
|---|---|
| Date | 2017-04-16 18:00 +0200 |
| Message-ID | <twUKK-5ru-7@gated-at.bofh.it> |
| In reply to | #1624148 |
On Sat, Apr 15, 2017 at 8:01 PM, Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote: > On Sat, 2017-04-15 at 15:09 -0700, Dan Williams wrote: >> I'm wondering, since this is limited to support behind a single >> switch, if you could have a software-iommu hanging off that switch >> device object that knows how to catch and translate the non-zero >> offset bus address case. We have something like this with VMD driver, >> and I toyed with a soft pci bridge when trying to support AHCI+NVME >> bar remapping. When the dma api looks up the iommu for its device it >> hits this soft-iommu and that driver checks if the page is host memory >> or device memory to do the dma translation. You wouldn't need a bit in >> struct page, just a lookup to the hosting struct dev_pagemap in the >> is_zone_device_page() case and that can point you to p2p details. > > I was thinking about a hook in the arch DMA ops but that kind of > wrapper might work instead indeed. However I'm not sure what's the best > way to "instantiate" it. > > The main issue is that the DMA ops are a function of the initiator, > not the target (since the target is supposed to be memory) so things > are a bit awkward. > > One (user ?) would have to know that a given device "intends" to DMA > directly to another device. > > This is awkward because in the ideal scenario, this isn't something the > device knows. For example, one could want to have an existing NIC DMA > directly to/from NVME pages or GPU pages. > > The NIC itself doesn't know the characteristic of these pages, but > *something* needs to insert itself in the DMA ops of that bridge to > make it possible. > > That's why I wonder if it's the struct page of the target that should > be "marked" in such a way that the arch dma'ops can immediately catch > that they belong to a device and might require "wrapped" operations. > > Are ZONE_DEVICE pages identifiable based on the struct page alone ? (a > flag ?) Yes, is_zone_device_page(). However I think we're getting to the point with pmem, hmm, cdm, and now p2p where ZONE_DEVICE is losing specific meaning and we need to have explicit type checks like is_hmm_page() is_p2p_page() that internally check is_zone_device_page() plus some other specific type. > That would allow us to keep a fast path for normal memory targets, but > also have some kind of way to handle the special cases of such peer 2 > peer (or also handle other type of peer to peer that don't necessarily > involve PCI address wrangling but could require additional iommu bits). > > Just thinking out loud ... I don't have a firm idea or a design. But > peer to peer is definitely a problem we need to tackle generically, the > demand for it keeps coming up. ZONE_DEVICE allows you to redirect via get_dev_pagemap() to retrieve context about the physical address in question. I'm thinking you can hang bus address translation data off of that structure. This seems vaguely similar to what HMM is doing.
[toc] | [prev] | [next] | [standalone]
| From | Logan Gunthorpe <logang@deltatee.com> |
|---|---|
| Date | 2017-04-16 18:40 +0200 |
| Message-ID | <twVnr-5TD-5@gated-at.bofh.it> |
| In reply to | #1624404 |
On 16/04/17 09:53 AM, Dan Williams wrote: > ZONE_DEVICE allows you to redirect via get_dev_pagemap() to retrieve > context about the physical address in question. I'm thinking you can > hang bus address translation data off of that structure. This seems > vaguely similar to what HMM is doing. Thanks! I didn't realize you had the infrastructure to look up a device from a pfn/page. That would really come in handy for us. Logan
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web