dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Thomas Hellström (VMware)" <thomas_os@shipmail.org>,
	"Daniel Vetter" <daniel@ffwll.ch>
Cc: "moderated list:DMA BUFFER SHARING FRAMEWORK"
	<linaro-mm-sig@lists.linaro.org>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	"open list:DMA BUFFER SHARING FRAMEWORK"
	<linux-media@vger.kernel.org>
Subject: Re: [PATCH 5/5] drm/amdgpu: implement amdgpu_gem_prime_move_notify v2
Date: Mon, 24 Feb 2020 19:46:59 +0100	[thread overview]
Message-ID: <7d73bdfa-63d0-11af-7029-382ad1015c4c@amd.com> (raw)
In-Reply-To: <8f29b152-9c7b-3427-efa2-4a39f0daced8@shipmail.org>

Am 23.02.20 um 17:54 schrieb Thomas Hellström (VMware):
> On 2/23/20 4:45 PM, Christian König wrote:
>> Am 21.02.20 um 18:12 schrieb Daniel Vetter:
>>> [SNIP]
>>> Yeah the Great Plan (tm) is to fully rely on ww_mutex slowly 
>>> degenerating
>>> into essentially a global lock. But only when there's actual contention
>>> and thrashing.
>>
>> Yes exactly. A really big problem in TTM is currently that we drop 
>> the lock after evicting BOs because they tend to move in again 
>> directly after that.
>>
>> From practice I can also confirm that there is exactly zero benefit 
>> from dropping locks early and reacquire them for example for the VM 
>> page tables. That's just makes it more likely that somebody needs to 
>> roll back and this is what we need to avoid in the first place.
>
> If you have a benchmarking setup available it would be very 
> interesting for future reference to see how changing from WD to WW 
> mutexes affects the roll back frequency. WW is known to cause 
> rollbacks much less frequently but there is more work associated with 
> each rollback.

Not of hand. To be honest I still have a hard time to get a grip on the 
difference between WD and WW from the algorithm point of view. So I 
can't judge that difference at all.

>> Contention on BO locks during command submission is perfectly fine as 
>> long as this is as lightweight as possible while we don't have 
>> trashing. When we have trashing multi submission performance is best 
>> archived to just favor a single process to finish its business and 
>> block everybody else.
>
> Hmm. Sounds like we need a per-manager ww_rwsem protecting manager 
> allocation, taken in write-mode then there's thrashing. In read-mode 
> otherwise. That would limit the amount of "unnecessary" locks we'd 
> have to keep and reduce unwanted side-effects, (see below):

Well per-manager (you mean per domain here don't you?) doesn't sound 
like that useful because we rarely use only one domain, but I'm actually 
questioning for quite a while if the per BO lock scheme was the right 
approach.

See from the performance aspect the closest to ideal solution I can 
think of would be a ww_rwsem per user of a resource.

In other words we don't lock BOs, but instead a list of all their users 
and when you want to evict a BO you need to walk that list and inform 
all users that the BO will be moving.

During command submission you then have the fast path which rather just 
grabs the read side of the user lock and check if all BOs are still in 
the expected place.

If some BOs were evicted you back off and start the slow path, e.g. 
maybe even copy additional data from userspace then grab the write side 
of the lock etc.. etc...

That approach is similar to what we use in amdgpu with the per-VM BOs, 
but goes a step further. Problem is that we are so used to per BO locks 
in the kernel that this is probably not doable any more.

>> Because of this I would actually vote for forbidding to release 
>> individual ww_mutex() locks in a context.
>
> Yes, I see the problem.
>
> But my first reaction is that this might have undersirable 
> side-effects. Let's say somebody wanted to swap the evicted BOs out?

Please explain further, I off hand don't see the problem here.

In general I actually wanted to re-work TTM in a way that BOs in the 
SYSTEM/SWAPABLE domain are always backed by a shmem file instead of the 
struct page array we currently have.

> Or cpu-writes to them causing faults, that might also block the 
> mm_sem, which in turn blocks hugepaged?

Mhm, I also only have a higher level view how hugepaged works so why 
does it grabs the mm_sem on the write side?

Thanks,
Christian.

>
> Still it's a fairly simple solution to a problem that seems otherwise 
> hard to solve efficiently.
>
> Thanks,
> Thomas
>
>
>>
>> Regards,
>> Christian.
>>
>>> -Daniel
>
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-02-24 18:47 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 15:45 RFC: Unpinned DMA-buf handling Christian König
2020-02-17 15:45 ` [PATCH 1/5] dma-buf: add dynamic DMA-buf handling v14 Christian König
2020-02-17 15:50   ` Christian König
2020-02-17 15:45 ` [PATCH 2/5] drm/ttm: remove the backing store if no placement is given Christian König
2020-02-17 15:45 ` [PATCH 3/5] drm/amdgpu: use allowed_domains for exported DMA-bufs Christian König
2020-02-17 15:45 ` [PATCH 4/5] drm/amdgpu: add amdgpu_dma_buf_pin/unpin v2 Christian König
2020-02-17 15:45 ` [PATCH 5/5] drm/amdgpu: implement amdgpu_gem_prime_move_notify v2 Christian König
2020-02-17 17:55   ` Daniel Vetter
2020-02-17 18:58     ` Christian König
2020-02-17 19:38       ` Daniel Vetter
2020-02-18 10:42         ` Christian König
2020-02-18 20:17     ` Thomas Hellström (VMware)
2020-02-18 21:01       ` Daniel Vetter
2020-02-19  6:42         ` Thomas Hellström (VMware)
2020-02-20  9:39           ` Thomas Hellström (VMware)
2020-02-20 18:04             ` Daniel Vetter
2020-02-20 19:46               ` Thomas Hellström (VMware)
2020-02-20 20:08                 ` Daniel Vetter
2020-02-20 22:51                   ` Thomas Hellström (VMware)
2020-02-21 17:12                     ` Daniel Vetter
2020-02-21 19:45                       ` Thomas Hellström (VMware)
2020-02-23 15:45                       ` Christian König
2020-02-23 16:54                         ` Thomas Hellström (VMware)
2020-02-24 18:46                           ` Christian König [this message]
2020-02-24 21:11                             ` Thomas Hellström (VMware)
2020-02-25 17:16                             ` Daniel Vetter
2020-02-26 16:32                               ` Daniel Vetter
2020-02-27  9:20                                 ` Christian König
2020-02-27  9:38                                   ` 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=7d73bdfa-63d0-11af-7029-382ad1015c4c@amd.com \
    --to=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=thomas_os@shipmail.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).