From: "Xiong, Jianxin" <jianxin.xiong@intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"Doug Ledford" <dledford@redhat.com>,
Leon Romanovsky <leon@kernel.org>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
Christian Koenig <christian.koenig@amd.com>,
"Vetter, Daniel" <daniel.vetter@intel.com>
Subject: RE: [PATCH v6 1/4] RDMA/umem: Support importing dma-buf as user memory region
Date: Tue, 27 Oct 2020 20:11:54 +0000 [thread overview]
Message-ID: <MW3PR11MB45554BC784229BAF55469390E5160@MW3PR11MB4555.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201027200010.GW36674@ziepe.ca>
> -----Original Message-----
> From: Jason Gunthorpe <jgg@ziepe.ca>
> Sent: Tuesday, October 27, 2020 1:00 PM
> To: Xiong, Jianxin <jianxin.xiong@intel.com>
> Cc: linux-rdma@vger.kernel.org; dri-devel@lists.freedesktop.org; Doug Ledford <dledford@redhat.com>; Leon Romanovsky
> <leon@kernel.org>; Sumit Semwal <sumit.semwal@linaro.org>; Christian Koenig <christian.koenig@amd.com>; Vetter, Daniel
> <daniel.vetter@intel.com>
> Subject: Re: [PATCH v6 1/4] RDMA/umem: Support importing dma-buf as user memory region
>
> On Fri, Oct 23, 2020 at 09:39:58AM -0700, Jianxin Xiong wrote:
> > +/*
> > + * Generate a new dma sg list from a sub range of an existing dma sg list.
> > + * Both the input and output have their entries page aligned.
> > + */
> > +static int ib_umem_dmabuf_sgt_slice(struct sg_table *sgt, u64 offset,
> > + u64 length, struct sg_table *new_sgt) {
> > + struct scatterlist *sg, *new_sg;
> > + u64 start, end, off, addr, len;
> > + unsigned int new_nents;
> > + int err;
> > + int i;
> > +
> > + start = ALIGN_DOWN(offset, PAGE_SIZE);
> > + end = ALIGN(offset + length, PAGE_SIZE);
> > +
> > + offset = start;
> > + length = end - start;
> > + new_nents = 0;
> > + for_each_sgtable_dma_sg(sgt, sg, i) {
> > + len = sg_dma_len(sg);
> > + off = min(len, offset);
> > + len -= off;
> > + len = min(len, length);
> > + if (len)
> > + new_nents++;
> > + length -= len;
> > + offset -= off;
> > + }
> > +
> > + err = sg_alloc_table(new_sgt, new_nents, GFP_KERNEL);
> > + if (err)
> > + return err;
>
> I would really rather not allocate an entirely new table just to take a slice of an existing SGT. Ideally the expoter API from DMA buf would
> prepare the SGL slice properly instead of always giving a whole buffer.
>
> Alternatively making some small edit to rdma_umem_for_each_dma_block() and ib_umem_find_best_pgsz() would let it slice the SGL at
> runtime
>
> You need to rebase on top of this series:
>
> https://patchwork.kernel.org/project/linux-rdma/list/?series=370437
>
> Which makes mlx5 use those new APIs
>
> Jason
Thanks. Will rebase and work on the runtime slicing.
next prev parent reply other threads:[~2020-10-27 20:12 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-23 16:39 [PATCH v6 0/4] RDMA: Add dma-buf support Jianxin Xiong
2020-10-23 16:39 ` [PATCH v6 1/4] RDMA/umem: Support importing dma-buf as user memory region Jianxin Xiong
2020-10-23 16:49 ` Daniel Vetter
2020-10-23 18:09 ` Xiong, Jianxin
2020-10-23 18:13 ` Daniel Vetter
2020-10-23 18:20 ` Jason Gunthorpe
2020-10-24 1:45 ` Daniel Vetter
2020-11-03 17:36 ` Xiong, Jianxin
2020-11-03 20:43 ` Daniel Vetter
2020-11-04 0:01 ` Xiong, Jianxin
2020-11-05 15:02 ` Jason Gunthorpe
2020-10-24 7:48 ` Christoph Hellwig
2020-10-26 12:26 ` Jason Gunthorpe
2020-10-27 8:08 ` Christoph Hellwig
2020-10-27 17:32 ` Xiong, Jianxin
2020-10-27 19:51 ` Jason Gunthorpe
2020-10-27 20:00 ` Jason Gunthorpe
2020-10-27 20:11 ` Xiong, Jianxin [this message]
2020-10-23 16:39 ` [PATCH v6 2/4] RDMA/core: Add device method for registering dma-buf base " Jianxin Xiong
2020-10-23 16:40 ` [PATCH v6 3/4] RDMA/uverbs: Add uverbs command for dma-buf based MR registration Jianxin Xiong
2020-10-23 16:40 ` [PATCH v6 4/4] RDMA/mlx5: Support dma-buf based userspace memory region Jianxin Xiong
2020-10-27 20:08 ` Jason Gunthorpe
2020-10-27 20:33 ` Xiong, Jianxin
2020-10-28 16:35 ` Jason Gunthorpe
2020-10-28 17:29 ` Xiong, Jianxin
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=MW3PR11MB45554BC784229BAF55469390E5160@MW3PR11MB4555.namprd11.prod.outlook.com \
--to=jianxin.xiong@intel.com \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@intel.com \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
/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).