linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>,
	Dan Williams <dan.j.williams@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jens Axboe <axboe@kernel.dk>,
	Steve Wise <swise@opengridcomputing.com>,
	Stephen Bates <sbates@raithlin.com>,
	Max Gurtovoy <maxg@mellanox.com>,
	Keith Busch <keith.busch@intel.com>,
	linux-pci@vger.kernel.org,
	linux-scsi <linux-scsi@vger.kernel.org>,
	linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org,
	linux-nvdimm <linux-nvdimm@ml01.01.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Jerome Glisse <jglisse@redhat.com>
Subject: Re: [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory
Date: Tue, 18 Apr 2017 15:31:58 -0600	[thread overview]
Message-ID: <9fc9352f-86fe-3a9e-e372-24b3346b518c@deltatee.com> (raw)
In-Reply-To: <20170418210339.GA24257@obsidianresearch.com>



On 18/04/17 03:03 PM, Jason Gunthorpe wrote:
> What about something more incremental like this instead:
> - dma_ops will set map_sg_p2p == map_sg when they are updated to
>   support p2p, otherwise DMA on P2P pages will fail for those ops.
> - When all ops support p2p we remove the if and ops->map_sg then
>   just call map_sg_p2p
> - For now the scatterlist maintains a bit when pages are added indicating if
>   p2p memory might be present in the list.
> - Unmap for p2p and non-p2p is the same, the underlying ops driver has
>   to make it work.
> 
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 0977317c6835c2..505ed7d502053d 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -103,6 +103,9 @@ struct dma_map_ops {
>  	int (*map_sg)(struct device *dev, struct scatterlist *sg,
>  		      int nents, enum dma_data_direction dir,
>  		      unsigned long attrs);
> +	int (*map_sg_p2p)(struct device *dev, struct scatterlist *sg,
> +			  int nents, enum dma_data_direction dir,
> +			  unsigned long attrs);
>  	void (*unmap_sg)(struct device *dev,
>  			 struct scatterlist *sg, int nents,
>  			 enum dma_data_direction dir,
> @@ -244,7 +247,15 @@ static inline int dma_map_sg_attrs(struct device *dev, struct scatterlist *sg,
>  	for_each_sg(sg, s, nents, i)
>  		kmemcheck_mark_initialized(sg_virt(s), s->length);
>  	BUG_ON(!valid_dma_direction(dir));
> -	ents = ops->map_sg(dev, sg, nents, dir, attrs);
> +
> +	if (sg_has_p2p(sg)) {
> +		if (ops->map_sg_p2p)
> +			ents = ops->map_sg_p2p(dev, sg, nents, dir, attrs);
> +		else
> +			return 0;
> +	} else
> +		ents = ops->map_sg(dev, sg, nents, dir, attrs);
> +
>  	BUG_ON(ents < 0);
>  	debug_dma_map_sg(dev, sg, nents, ents, dir);

I could get behind this. Though a couple of points:

1) It means that sg_has_p2p has to walk the entire sg and check every
page. Then map_sg_p2p/map_sg has to walk it again and repeat the check
then do some operation per page. If anyone is concerned about the
dma_map performance this could be an issue.

2) Without knowing exactly what the arch specific code may need to do
it's hard to say that this is exactly the right approach. If every
dma_ops provider has to do exactly this on every page it may lead to a
lot of duplicate code:

foreach_sg page:
   if (pci_page_is_p2p(page)) {
        dma_addr = pci_p2p_map_page(page)
	if (!dma_addr)
		return 0;
        continue
   }
   ...

The only thing I'm presently aware of is the segment check and applying
the offset to the physical address -- neither of which has much to do
with the specific dma_ops providers. It _may_ be that this needs to be
bus specific and not arch specific which I think is what Dan may be
getting at. So it may make sense to just have a pci_map_sg_p2p() which
takes a dma_ops struct it would use for any page that isn't a p2p page.

Logan

  parent reply	other threads:[~2017-04-18 21:32 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-16 15:44 [RFC 0/8] Copy Offload with Peer-to-Peer PCI Memory Dan Williams
2017-04-16 16:47 ` Logan Gunthorpe
2017-04-16 22:32   ` Benjamin Herrenschmidt
2017-04-17  5:13     ` Logan Gunthorpe
2017-04-17  7:20       ` Benjamin Herrenschmidt
2017-04-17 16:52         ` Logan Gunthorpe
2017-04-17 17:04           ` Dan Williams
2017-04-18  5:22             ` Logan Gunthorpe
2017-04-17 18:04           ` Jerome Glisse
2017-04-18  6:14             ` Logan Gunthorpe
2017-04-17 21:11           ` Benjamin Herrenschmidt
2017-04-18  5:43             ` Logan Gunthorpe
2017-04-18  6:29               ` Benjamin Herrenschmidt
2017-04-16 22:23 ` Benjamin Herrenschmidt
2017-04-18 16:45   ` Jason Gunthorpe
2017-04-18 17:27     ` Dan Williams
2017-04-18 18:00       ` Jason Gunthorpe
2017-04-18 18:34         ` Dan Williams
2017-04-19  1:13         ` Benjamin Herrenschmidt
2017-04-18 22:46       ` Benjamin Herrenschmidt
2017-04-18 22:52         ` Dan Williams
2017-04-18 18:30     ` Logan Gunthorpe
2017-04-18 19:01       ` Jason Gunthorpe
2017-04-18 19:35         ` Logan Gunthorpe
2017-04-18 19:48           ` Dan Williams
2017-04-18 20:29             ` Jerome Glisse
2017-04-18 20:31               ` Dan Williams
2017-04-18 20:48                 ` Logan Gunthorpe
2017-04-19  1:17                   ` Benjamin Herrenschmidt
2017-04-18 21:03             ` Jason Gunthorpe
2017-04-18 21:11               ` Dan Williams
2017-04-18 21:22                 ` Jason Gunthorpe
2017-04-18 21:36                   ` Dan Williams
2017-04-18 22:15                     ` Logan Gunthorpe
2017-04-18 22:28                       ` Dan Williams
2017-04-18 22:42                         ` Jason Gunthorpe
2017-04-18 22:51                           ` Dan Williams
2017-04-18 23:21                             ` Jason Gunthorpe
2017-04-19  1:25                               ` Benjamin Herrenschmidt
2017-04-18 22:48                         ` Logan Gunthorpe
2017-04-18 22:50                           ` Dan Williams
2017-04-18 22:56                             ` Logan Gunthorpe
2017-04-18 23:02                               ` Dan Williams
2017-04-19  1:21                   ` Benjamin Herrenschmidt
2017-04-18 21:31               ` Logan Gunthorpe [this message]
2017-04-18 22:24                 ` Jason Gunthorpe
2017-04-18 23:03                   ` Logan Gunthorpe
2017-04-19  1:23                   ` Benjamin Herrenschmidt
2017-04-19  1:20               ` Benjamin Herrenschmidt
2017-04-19 15:55                 ` Jason Gunthorpe
2017-04-19 16:48                   ` Logan Gunthorpe
2017-04-19 17:01                     ` Dan Williams
2017-04-19 17:32                       ` Jerome Glisse
2017-04-19 17:41                         ` Dan Williams
2017-04-19 18:11                           ` Logan Gunthorpe
2017-04-19 18:19                             ` Logan Gunthorpe
2017-04-19 18:30                               ` Dan Williams
2017-04-19 18:41                                 ` Logan Gunthorpe
2017-04-19 18:44                                   ` Dan Williams
2017-04-20 20:43                           ` Stephen  Bates
2017-04-20 20:47                             ` Dan Williams
2017-04-20 23:07                               ` Stephen  Bates
2017-04-21  4:59                                 ` Dan Williams
2017-04-19 17:14                     ` Jason Gunthorpe
2017-04-19 18:01                       ` Logan Gunthorpe
2017-04-19 18:32                         ` Jason Gunthorpe
2017-04-19 19:02                           ` Logan Gunthorpe
2017-04-19 19:31                             ` Jason Gunthorpe
2017-04-19 19:41                               ` Logan Gunthorpe
2017-04-19 20:48                                 ` Jason Gunthorpe
2017-04-19 22:55                                   ` Logan Gunthorpe
2017-04-20  0:07                                     ` Dan Williams
2017-04-18 19:48           ` Jason Gunthorpe
2017-04-18 20:06             ` Logan Gunthorpe
  -- strict thread matches above, loose matches on Subject: below --
2017-03-30 22:12 Logan Gunthorpe
2017-04-12  5:22 ` Benjamin Herrenschmidt
2017-04-12 17:09   ` Logan Gunthorpe
2017-04-12 21:55     ` Benjamin Herrenschmidt
2017-04-13 21:22       ` Logan Gunthorpe
2017-04-13 22:37         ` Benjamin Herrenschmidt
2017-04-13 23:26         ` Bjorn Helgaas
2017-04-14  4:16           ` Jason Gunthorpe
2017-04-14  4:40             ` Logan Gunthorpe
2017-04-14 11:37               ` Benjamin Herrenschmidt
2017-04-14 11:39                 ` Benjamin Herrenschmidt
2017-04-14 11:37             ` Benjamin Herrenschmidt
2017-04-14 17:30               ` Logan Gunthorpe
2017-04-14 19:04                 ` Bjorn Helgaas
2017-04-14 22:07                   ` Benjamin Herrenschmidt
2017-04-15 17:41                     ` Logan Gunthorpe
2017-04-15 22:09                       ` Dan Williams
2017-04-16  3:01                         ` Benjamin Herrenschmidt
2017-04-16  4:46                           ` Logan Gunthorpe
2017-04-16 15:53                           ` Dan Williams
2017-04-16 16:34                             ` Logan Gunthorpe
2017-04-16 22:31                               ` Benjamin Herrenschmidt
2017-04-24  7:36                                 ` Knut Omang
2017-04-24 16:14                                   ` Logan Gunthorpe
2017-04-25  6:30                                     ` Knut Omang
2017-04-25 17:03                                       ` Logan Gunthorpe
2017-04-25 21:23                                         ` Stephen  Bates
2017-04-25 21:23                                   ` Stephen  Bates
2017-04-16 22:26                             ` Benjamin Herrenschmidt
2017-04-15 22:17                       ` Benjamin Herrenschmidt
2017-04-16  5:36                         ` Logan Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fc9352f-86fe-3a9e-e372-24b3346b518c@deltatee.com \
    --to=logang@deltatee.com \
    --cc=axboe@kernel.dk \
    --cc=benh@kernel.crashing.org \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=helgaas@kernel.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=jglisse@redhat.com \
    --cc=jgunthorpe@obsidianresearch.com \
    --cc=keith.busch@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@ml01.01.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=maxg@mellanox.com \
    --cc=sagi@grimberg.me \
    --cc=sbates@raithlin.com \
    --cc=swise@opengridcomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).