From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Chris Wilson" <chris@chris-wilson.co.uk>,
"Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace
Date: Wed, 15 Nov 2017 19:56:43 +0100 [thread overview]
Message-ID: <0e57934b-4189-719b-d93f-03d4fcec2073@gmail.com> (raw)
In-Reply-To: <151076779232.19172.5265207291862820032@mail.alporthouse.com>
Am 15.11.2017 um 18:43 schrieb Chris Wilson:
> Quoting Christian König (2017-11-15 17:34:07)
>> Am 15.11.2017 um 17:55 schrieb Chris Wilson:
>>> Quoting Chris Wilson (2017-11-14 14:34:05)
>>>> Quoting Christian König (2017-11-14 14:24:44)
>>>>> Am 06.11.2017 um 17:22 schrieb Chris Wilson:
>>>>>> Quoting Christian König (2017-10-30 14:59:04)
>>>>>>> @@ -126,17 +127,28 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
>>>>>>> dma_fence_put(old_fence);
>>>>>>> return;
>>>>>>> }
>>>>>>> +
>>>>>>> + if (!signaled && dma_fence_is_signaled(old_fence)) {
>>>>>>> + signaled = old_fence;
>>>>>>> + signaled_idx = i;
>>>>>>> + }
>>>>>> How much do we care about only keeping one fence per-ctx here? You could
>>>>>> rearrange this to break on old_fence->context == fence->context ||
>>>>>> dma_fence_is_signaled(old_fence) then everyone can use the final block.
>>>>> Yeah, that is what David Zhou suggested as well.
>>>>>
>>>>> I've rejected this approach for now cause I think we still have cases
>>>>> where we rely on one fence per ctx (but I'm not 100% sure).
>>>>>
>>>>> I changed patch #1 in this series as you suggest and going to send that
>>>>> out once more in a minute.
>>>>>
>>>>> Can we get this upstream as is for now? I won't have much more time
>>>>> working on this.
>>>> Sure, we are only discussing how we might make it look tidier, pure
>>>> micro-optimisation with the caveat of losing the one-fence-per-ctx
>>>> guarantee.
>>> Ah, one thing to note is that extra checking pushed one of our corner
>>> case tests over its time limit.
>>>
>>> If we can completely forgo the one-fence-per-ctx here, what works really
>>> well in testing is
>>>
>>> diff --git a/drivers/dma-buf/reservation.c b/drivers/dma-buf/reservation.c
>>> index 5319ac478918..5755e95fab1b 100644
>>> --- a/drivers/dma-buf/reservation.c
>>> +++ b/drivers/dma-buf/reservation.c
>>> @@ -104,39 +104,19 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,
>>> struct reservation_object_list *fobj,
>>> struct dma_fence *fence)
>>> {
>>> - struct dma_fence *replace = NULL;
>>> - u32 ctx = fence->context;
>>> - u32 i;
>>> -
>>> dma_fence_get(fence);
>>>
>>> preempt_disable();
>>> write_seqcount_begin(&obj->seq);
>>>
>>> - for (i = 0; i < fobj->shared_count; ++i) {
>>> - struct dma_fence *check;
>>> -
>>> - check = rcu_dereference_protected(fobj->shared[i],
>>> - reservation_object_held(obj));
>>> -
>>> - if (check->context == ctx || dma_fence_is_signaled(check)) {
>>> - replace = old_fence;
>>> - break;
>>> - }
>>> - }
>>> -
>>> /*
>>> * memory barrier is added by write_seqcount_begin,
>>> * fobj->shared_count is protected by this lock too
>>> */
>>> - RCU_INIT_POINTER(fobj->shared[i], fence);
>>> - if (!replace)
>>> - fobj->shared_count++;
>>> + RCU_INIT_POINTER(fobj->shared[fobj->shared_count++], fence);
>>>
>>> write_seqcount_end(&obj->seq);
>>> preempt_enable();
>>> -
>>> - dma_fence_put(replace);
>>> }
>>>
>>> static void
>>>
>>> i.e. don't check when not replacing the shared[], on creating the new
>>> buffer we then discard all the old fences.
>>>
>>> It should work for amdgpu as well since you do a ht to coalesce
>>> redundant fences before queuing.
>> That won't work for all cases. This way the reservation object would
>> keep growing without a chance to ever shrink.
> We only keep the active fences when it grows, which is effective enough
> to keep it in check on the workloads I can find in the hour since
> noticing the failure in CI ;)
Not sure what tests you run, but this change means that we basically
just add the fence to an ever growing list of fences on every command
submission which is only reaped when we double the list size.
That is a serious no-go as far as I can see. What we could do is improve
reservation_object_reserve_shared() as well to figure out how many
signaled fences are actually in the array when we reallocate it.
> And on the workloads where it is being
> flooded with live fences from many contexts, the order of magnitude
> throughput improvement is not easy to ignore.
Well not sure about the Intel driver, but since we started to mostly use
a single reservation object per process the time spend in those
functions on amdgpu are completely negligible.
Regards,
Christian.
> -Chris
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-11-15 18:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-30 14:59 [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v2 Christian König
2017-10-30 14:59 ` [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Christian König
2017-11-06 16:22 ` Chris Wilson
[not found] ` <150998532204.10527.4781311190552781355-M6iVdVfohj6unts5RBS2dVaTQe2KTcn/@public.gmane.org>
2017-11-14 14:24 ` Christian König
[not found] ` <4fc05061-e92d-1702-a0f6-ee337b7d3eb3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-14 14:34 ` Chris Wilson
2017-11-15 16:55 ` Chris Wilson
2017-11-15 17:34 ` Christian König
[not found] ` <1a565164-85cf-0678-b6ab-802ec047bb91-5C7GfCeVMHo@public.gmane.org>
2017-11-15 17:43 ` Chris Wilson
2017-11-15 18:56 ` Christian König [this message]
2017-11-15 19:30 ` Chris Wilson
[not found] ` <20171030145904.18584-1-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-11-02 12:26 ` [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v2 Sumit Semwal
2017-11-06 16:18 ` Chris Wilson
-- strict thread matches above, loose matches on Subject: below --
2017-11-14 14:24 [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v3 Christian König
[not found] ` <20171114142436.1360-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-11-14 14:24 ` [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Christian König
2017-11-14 14:41 ` Chris Wilson
2017-10-31 8:43 [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v2 Christian König
[not found] ` <20171031084306.1986-1-christian.koenig-5C7GfCeVMHo@public.gmane.org>
2017-10-31 8:43 ` [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Christian König
2017-10-31 8:41 [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v2 Christian König
[not found] ` <20171031084137.1925-1-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-10-31 8:41 ` [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Christian König
2017-10-24 13:55 [PATCH 1/2] dma-buf: keep only not signaled fence in reservation_object_add_shared_replace Christian König
2017-10-24 13:55 ` [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace Christian König
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=0e57934b-4189-719b-d93f-03d4fcec2073@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=chris@chris-wilson.co.uk \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.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).