All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Subject: Re: RFC: unpinned DMA-buf exporting v2
Date: Mon, 19 Mar 2018 15:09:36 +0100	[thread overview]
Message-ID: <20180319140936.GO14155@phenom.ffwll.local> (raw)
In-Reply-To: <20180316132049.1748-1-christian.koenig@amd.com>

On Fri, Mar 16, 2018 at 02:20:44PM +0100, Christian König wrote:
> Hi everybody,
> 
> since I've got positive feedback from Daniel I continued working on this approach.
> 
> A few issues are still open:
> 1. Daniel suggested that I make the invalidate_mappings callback a parameter of dma_buf_attach().
> 
> This approach unfortunately won't work because when the attachment is
> created the importer is not necessarily ready to handle invalidation
> events.

Why do you have this constraint? This sounds a bit like inverted
create/teardown sequence troubles, where you make an object "life" before
the thing is fully set up.

Can't we fix this by creating the entire ttm scaffolding you'll need for a
dma-buf upfront, and only once you have everything we grab the dma_buf
attachment? At that point you really should be able to evict buffers
again.

Not requiring invalidate_mapping to be set together with the attachment
means we can't ever require importers to support it (e.g. to address your
concern with the userspace dma-buf userptr magic).

> E.g. in the amdgpu example we first need to setup the imported GEM/TMM
> objects and install that in the attachment.
> 
> My solution is to introduce a separate function to grab the locks and
> set the callback, this function could then be used to pin the buffer
> later on if that turns out to be necessary after all.
> 
> 2. With my example setup this currently results in a ping/pong situation
> because the exporter prefers a VRAM placement while the importer prefers
> a GTT placement.
> 
> This results in quite a performance drop, but can be fixed by a simple
> mesa patch which allows shred BOs to be placed in both VRAM and GTT.
> 
> Question is what should we do in the meantime? Accept the performance
> drop or only allow unpinned sharing with new Mesa?

Maybe the exporter should not try to move stuff back into VRAM as long as
there's an active dma-buf? I mean it's really cool that it works, but
maybe let's just do this for a tech demo :-)

Of course if it then runs out of TT then it could still try to move it
back in. And "let's not move it when it's imported" is probably too stupid
too, and will need to be improved again with more heuristics, but would at
least get it off the ground.

Long term you might want to move perhaps once per 10 seconds or so, to get
idle importers to detach. Adjust 10s to match whatever benchmark/workload
you care about.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel-/w4YWyX8dFk@public.gmane.org>
To: "Christian König"
	<ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linaro-mm-sig-cunTk1MwBs8s++Sfvej+rw@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	linux-media-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: RFC: unpinned DMA-buf exporting v2
Date: Mon, 19 Mar 2018 15:09:36 +0100	[thread overview]
Message-ID: <20180319140936.GO14155@phenom.ffwll.local> (raw)
In-Reply-To: <20180316132049.1748-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>

On Fri, Mar 16, 2018 at 02:20:44PM +0100, Christian König wrote:
> Hi everybody,
> 
> since I've got positive feedback from Daniel I continued working on this approach.
> 
> A few issues are still open:
> 1. Daniel suggested that I make the invalidate_mappings callback a parameter of dma_buf_attach().
> 
> This approach unfortunately won't work because when the attachment is
> created the importer is not necessarily ready to handle invalidation
> events.

Why do you have this constraint? This sounds a bit like inverted
create/teardown sequence troubles, where you make an object "life" before
the thing is fully set up.

Can't we fix this by creating the entire ttm scaffolding you'll need for a
dma-buf upfront, and only once you have everything we grab the dma_buf
attachment? At that point you really should be able to evict buffers
again.

Not requiring invalidate_mapping to be set together with the attachment
means we can't ever require importers to support it (e.g. to address your
concern with the userspace dma-buf userptr magic).

> E.g. in the amdgpu example we first need to setup the imported GEM/TMM
> objects and install that in the attachment.
> 
> My solution is to introduce a separate function to grab the locks and
> set the callback, this function could then be used to pin the buffer
> later on if that turns out to be necessary after all.
> 
> 2. With my example setup this currently results in a ping/pong situation
> because the exporter prefers a VRAM placement while the importer prefers
> a GTT placement.
> 
> This results in quite a performance drop, but can be fixed by a simple
> mesa patch which allows shred BOs to be placed in both VRAM and GTT.
> 
> Question is what should we do in the meantime? Accept the performance
> drop or only allow unpinned sharing with new Mesa?

Maybe the exporter should not try to move stuff back into VRAM as long as
there's an active dma-buf? I mean it's really cool that it works, but
maybe let's just do this for a tech demo :-)

Of course if it then runs out of TT then it could still try to move it
back in. And "let's not move it when it's imported" is probably too stupid
too, and will need to be improved again with more heuristics, but would at
least get it off the ground.

Long term you might want to move perhaps once per 10 seconds or so, to get
idle importers to detach. Adjust 10s to match whatever benchmark/workload
you care about.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-03-19 14:09 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 13:20 RFC: unpinned DMA-buf exporting v2 Christian König
2018-03-16 13:20 ` Christian König
2018-03-16 13:20 ` [PATCH 1/5] dma-buf: add optional invalidate_mappings callback v2 Christian König
2018-03-16 13:20   ` Christian König
2018-03-16 13:51   ` Chris Wilson
2018-03-16 13:51     ` Chris Wilson
2018-03-16 14:22     ` Christian König
2018-03-16 14:22       ` Christian König
2018-03-19 15:53       ` Chris Wilson
2018-03-19 15:53         ` Chris Wilson
2018-03-19 16:23         ` Christian König
2018-03-19 16:23           ` Christian König
2018-03-20  7:44           ` [Linaro-mm-sig] " Daniel Vetter
2018-03-20  7:44             ` Daniel Vetter
2018-03-20 10:54             ` Christian König
2018-03-20 10:54               ` Christian König
2018-03-20 14:08               ` Daniel Vetter
2018-03-20 14:08                 ` Daniel Vetter
2018-03-20 17:47                 ` Christian König
2018-03-20 17:47                   ` Christian König
2018-03-21  8:18                   ` Daniel Vetter
2018-03-21  8:18                     ` Daniel Vetter
2018-03-21  9:34                     ` Christian König
2018-03-21  9:34                       ` Christian König
2018-03-22  7:14                       ` Daniel Vetter
2018-03-22  7:14                         ` Daniel Vetter
2018-03-22  9:37                         ` Christian König
2018-03-22  9:37                           ` Christian König
2018-03-26  7:51                           ` Daniel Vetter
2018-03-26  7:51                             ` Daniel Vetter
2018-03-21  8:28                   ` Daniel Vetter
2018-03-21  8:28                     ` Daniel Vetter
2018-03-21 11:54                     ` Christian König
2018-03-21 11:54                       ` Christian König
2018-03-22  7:18                       ` Daniel Vetter
2018-03-22  7:18                         ` Daniel Vetter
2018-03-22  9:58                         ` Christian König
2018-03-22  9:58                           ` Christian König
2018-03-26  8:01                           ` Daniel Vetter
2018-03-26  8:01                             ` Daniel Vetter
2018-03-26 15:42                             ` Jerome Glisse
2018-03-26 15:42                               ` Jerome Glisse
2018-03-27  7:35                               ` Christian König
2018-03-27  7:35                                 ` Christian König
2018-03-27  7:53                                 ` Daniel Vetter
2018-03-27  7:53                                   ` Daniel Vetter
2018-03-27  8:06                                   ` Christian König
2018-03-27  8:06                                     ` Christian König
2018-03-27  8:27                                     ` Daniel Vetter
2018-03-27  8:27                                       ` Daniel Vetter
2018-03-19 14:04   ` Daniel Vetter
2018-03-19 14:04     ` Daniel Vetter
2018-03-16 13:20 ` [PATCH 2/5] drm/ttm: keep a reference to transfer pipelined BOs Christian König
2018-03-16 13:20   ` Christian König
2018-03-27  3:32   ` He, Roger
2018-03-27  3:32     ` He, Roger
2018-03-16 13:20 ` [PATCH 3/5] drm/ttm: remove the backing store if no placement is given Christian König
2018-03-16 13:20   ` Christian König
2018-03-16 13:20 ` [PATCH 4/5] drm/amdgpu: add independent DMA-buf export v2 Christian König
2018-03-16 13:20   ` Christian König
2018-03-16 13:20 ` [PATCH 5/5] drm/amdgpu: add independent DMA-buf import v2 Christian König
2018-03-16 13:20   ` Christian König
2018-03-19 14:09 ` Daniel Vetter [this message]
2018-03-19 14:09   ` RFC: unpinned DMA-buf exporting v2 Daniel Vetter

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=20180319140936.GO14155@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.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 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.