From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: Leon Romanovsky <leon@kernel.org> Cc: linux-rdma@vger.kernel.org, intel-gfx@lists.freedesktop.org, Roland Scheidegger <sroland@vmware.com>, dri-devel@lists.freedesktop.org, Maor Gottlieb <maorg@mellanox.com>, David Airlie <airlied@linux.ie>, Doug Ledford <dledford@redhat.com>, VMware Graphics <linux-graphics-maintainer@vmware.com>, Jason Gunthorpe <jgg@nvidia.com>, Maor Gottlieb <maorg@nvidia.com>, Christoph Hellwig <hch@lst.de> Subject: Re: [Intel-gfx] [PATCH rdma-next v3 1/2] lib/scatterlist: Add support in dynamic allocation of SG table from pages Date: Fri, 25 Sep 2020 12:41:29 +0100 [thread overview] Message-ID: <adff5752-582c-2065-89e2-924ef732911a@linux.intel.com> (raw) In-Reply-To: <20200925071330.GA2280698@unreal> On 25/09/2020 08:13, Leon Romanovsky wrote: > On Thu, Sep 24, 2020 at 09:21:20AM +0100, Tvrtko Ursulin wrote: >> >> On 22/09/2020 09:39, Leon Romanovsky wrote: >>> From: Maor Gottlieb <maorg@mellanox.com> >>> >>> Extend __sg_alloc_table_from_pages to support dynamic allocation of >>> SG table from pages. It should be used by drivers that can't supply >>> all the pages at one time. >>> >>> This function returns the last populated SGE in the table. Users should >>> pass it as an argument to the function from the second call and forward. >>> As before, nents will be equal to the number of populated SGEs (chunks). >> >> So it's appending and growing the "list", did I get that right? Sounds handy >> indeed. Some comments/questions below. > > Yes, we (RDMA) use this function to chain contiguous pages. I will eveluate if i915 could start using it. We have some loops which build page by page and coalesce. [snip] >>> if (unlikely(ret)) >>> diff --git a/tools/testing/scatterlist/main.c b/tools/testing/scatterlist/main.c >>> index 0a1464181226..4899359a31ac 100644 >>> --- a/tools/testing/scatterlist/main.c >>> +++ b/tools/testing/scatterlist/main.c >>> @@ -55,14 +55,13 @@ int main(void) >>> for (i = 0, test = tests; test->expected_segments; test++, i++) { >>> struct page *pages[MAX_PAGES]; >>> struct sg_table st; >>> - int ret; >>> + struct scatterlist *sg; >>> >>> set_pages(pages, test->pfn, test->num_pages); >>> >>> - ret = __sg_alloc_table_from_pages(&st, pages, test->num_pages, >>> - 0, test->size, test->max_seg, >>> - GFP_KERNEL); >>> - assert(ret == test->alloc_ret); >>> + sg = __sg_alloc_table_from_pages(&st, pages, test->num_pages, 0, >>> + test->size, test->max_seg, NULL, 0, GFP_KERNEL); >>> + assert(PTR_ERR_OR_ZERO(sg) == test->alloc_ret); >> >> Some test coverage for relatively complex code would be very welcomed. Since >> the testing framework is already there, even if it bit-rotted a bit, but >> shouldn't be hard to fix. >> >> A few tests to check append/grow works as expected, in terms of how the end >> table looks like given the initial state and some different page patterns >> added to it. And both crossing and not crossing into sg chaining scenarios. > > This function is basic for all RDMA devices and we are pretty confident > that the old and new flows are tested thoroughly. > > We will add proper test in next kernel cycle. Patch seems to be adding a requirement that all callers of (__)sg_alloc_table_from_pages pass in zeroed struct sg_table, which wasn't the case so far. Have you audited all the callers and/or fixed them? There seems to be quite a few. Gut feel says problem would probably be better solved in lib/scatterlist.c and not by making all the callers memset. Should be possible if you make sure you only read st->nents if prev was passed in? I've fixed the unit test and with this change the existing tests do pass. But without zeroing it does fail on the very first, single page, test scenario. You can pull the unit test hacks from git://people.freedesktop.org/~tursulin/drm-intel sgtest. Regards, Tvrtko _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
WARNING: multiple messages have this Message-ID (diff)
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> To: Leon Romanovsky <leon@kernel.org> Cc: linux-rdma@vger.kernel.org, intel-gfx@lists.freedesktop.org, Roland Scheidegger <sroland@vmware.com>, dri-devel@lists.freedesktop.org, Maor Gottlieb <maorg@mellanox.com>, David Airlie <airlied@linux.ie>, Doug Ledford <dledford@redhat.com>, VMware Graphics <linux-graphics-maintainer@vmware.com>, Jason Gunthorpe <jgg@nvidia.com>, Maor Gottlieb <maorg@nvidia.com>, Christoph Hellwig <hch@lst.de> Subject: Re: [Intel-gfx] [PATCH rdma-next v3 1/2] lib/scatterlist: Add support in dynamic allocation of SG table from pages Date: Fri, 25 Sep 2020 12:41:29 +0100 [thread overview] Message-ID: <adff5752-582c-2065-89e2-924ef732911a@linux.intel.com> (raw) In-Reply-To: <20200925071330.GA2280698@unreal> On 25/09/2020 08:13, Leon Romanovsky wrote: > On Thu, Sep 24, 2020 at 09:21:20AM +0100, Tvrtko Ursulin wrote: >> >> On 22/09/2020 09:39, Leon Romanovsky wrote: >>> From: Maor Gottlieb <maorg@mellanox.com> >>> >>> Extend __sg_alloc_table_from_pages to support dynamic allocation of >>> SG table from pages. It should be used by drivers that can't supply >>> all the pages at one time. >>> >>> This function returns the last populated SGE in the table. Users should >>> pass it as an argument to the function from the second call and forward. >>> As before, nents will be equal to the number of populated SGEs (chunks). >> >> So it's appending and growing the "list", did I get that right? Sounds handy >> indeed. Some comments/questions below. > > Yes, we (RDMA) use this function to chain contiguous pages. I will eveluate if i915 could start using it. We have some loops which build page by page and coalesce. [snip] >>> if (unlikely(ret)) >>> diff --git a/tools/testing/scatterlist/main.c b/tools/testing/scatterlist/main.c >>> index 0a1464181226..4899359a31ac 100644 >>> --- a/tools/testing/scatterlist/main.c >>> +++ b/tools/testing/scatterlist/main.c >>> @@ -55,14 +55,13 @@ int main(void) >>> for (i = 0, test = tests; test->expected_segments; test++, i++) { >>> struct page *pages[MAX_PAGES]; >>> struct sg_table st; >>> - int ret; >>> + struct scatterlist *sg; >>> >>> set_pages(pages, test->pfn, test->num_pages); >>> >>> - ret = __sg_alloc_table_from_pages(&st, pages, test->num_pages, >>> - 0, test->size, test->max_seg, >>> - GFP_KERNEL); >>> - assert(ret == test->alloc_ret); >>> + sg = __sg_alloc_table_from_pages(&st, pages, test->num_pages, 0, >>> + test->size, test->max_seg, NULL, 0, GFP_KERNEL); >>> + assert(PTR_ERR_OR_ZERO(sg) == test->alloc_ret); >> >> Some test coverage for relatively complex code would be very welcomed. Since >> the testing framework is already there, even if it bit-rotted a bit, but >> shouldn't be hard to fix. >> >> A few tests to check append/grow works as expected, in terms of how the end >> table looks like given the initial state and some different page patterns >> added to it. And both crossing and not crossing into sg chaining scenarios. > > This function is basic for all RDMA devices and we are pretty confident > that the old and new flows are tested thoroughly. > > We will add proper test in next kernel cycle. Patch seems to be adding a requirement that all callers of (__)sg_alloc_table_from_pages pass in zeroed struct sg_table, which wasn't the case so far. Have you audited all the callers and/or fixed them? There seems to be quite a few. Gut feel says problem would probably be better solved in lib/scatterlist.c and not by making all the callers memset. Should be possible if you make sure you only read st->nents if prev was passed in? I've fixed the unit test and with this change the existing tests do pass. But without zeroing it does fail on the very first, single page, test scenario. You can pull the unit test hacks from git://people.freedesktop.org/~tursulin/drm-intel sgtest. Regards, Tvrtko _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2020-09-25 11:41 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-22 8:39 [PATCH rdma-next v3 0/2] Dynamicaly allocate SG table from the pages Leon Romanovsky 2020-09-22 8:39 ` [Intel-gfx] " Leon Romanovsky 2020-09-22 8:39 ` Leon Romanovsky 2020-09-22 8:39 ` [PATCH rdma-next v3 1/2] lib/scatterlist: Add support in dynamic allocation of SG table from pages Leon Romanovsky 2020-09-22 8:39 ` [Intel-gfx] " Leon Romanovsky 2020-09-22 8:39 ` Leon Romanovsky 2020-09-23 5:42 ` Christoph Hellwig 2020-09-23 5:42 ` [Intel-gfx] " Christoph Hellwig 2020-09-24 8:21 ` Tvrtko Ursulin 2020-09-24 8:21 ` Tvrtko Ursulin 2020-09-25 7:13 ` Leon Romanovsky 2020-09-25 7:13 ` Leon Romanovsky 2020-09-25 7:13 ` Leon Romanovsky 2020-09-25 11:41 ` Tvrtko Ursulin [this message] 2020-09-25 11:41 ` Tvrtko Ursulin 2020-09-25 11:58 ` Jason Gunthorpe 2020-09-25 11:58 ` Jason Gunthorpe 2020-09-25 11:58 ` Jason Gunthorpe 2020-09-25 12:29 ` Tvrtko Ursulin 2020-09-25 12:29 ` Tvrtko Ursulin 2020-09-25 12:29 ` Tvrtko Ursulin 2020-09-25 12:34 ` Jason Gunthorpe 2020-09-25 12:34 ` Jason Gunthorpe 2020-09-25 12:34 ` Jason Gunthorpe 2020-09-25 12:13 ` Maor Gottlieb 2020-09-25 12:13 ` Maor Gottlieb 2020-09-25 12:13 ` Maor Gottlieb 2020-09-25 11:55 ` Jason Gunthorpe 2020-09-25 11:55 ` Jason Gunthorpe 2020-09-25 11:55 ` Jason Gunthorpe 2020-09-25 12:18 ` Maor Gottlieb 2020-09-25 12:18 ` Maor Gottlieb 2020-09-25 12:18 ` Maor Gottlieb 2020-09-25 12:33 ` Tvrtko Ursulin 2020-09-25 12:33 ` Tvrtko Ursulin 2020-09-25 12:33 ` Tvrtko Ursulin 2020-09-25 13:39 ` Maor Gottlieb 2020-09-25 13:39 ` Maor Gottlieb 2020-09-25 13:39 ` Maor Gottlieb 2020-09-25 13:54 ` Tvrtko Ursulin 2020-09-25 13:54 ` Tvrtko Ursulin 2020-09-25 13:54 ` Tvrtko Ursulin 2020-09-22 8:39 ` [PATCH rdma-next v3 2/2] RDMA/umem: Move to allocate " Leon Romanovsky
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=adff5752-582c-2065-89e2-924ef732911a@linux.intel.com \ --to=tvrtko.ursulin@linux.intel.com \ --cc=airlied@linux.ie \ --cc=dledford@redhat.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=hch@lst.de \ --cc=intel-gfx@lists.freedesktop.org \ --cc=jgg@nvidia.com \ --cc=leon@kernel.org \ --cc=linux-graphics-maintainer@vmware.com \ --cc=linux-rdma@vger.kernel.org \ --cc=maorg@mellanox.com \ --cc=maorg@nvidia.com \ --cc=sroland@vmware.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.