dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v3
PATCH 1/2 dma-buf: keep only not signaled fence in reservation_object_add_shared_replace v3
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now.
Optimize the list by keeping only the not signaled yet fences around.
v2: temporary put the signaled fences at the end of the new container
v3: put the old fence at the end of the new container as well.
--- drivers/dma-buf/reservation.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-)
drivers/dma-buf/reservation.c +21 -17
@@ -145,8 +145,7 @@ reservation_object_add_shared_replace(struct reservation_object *obj,struct reservation_object_list *fobj, struct dma_fence *fence) { - unsigned i; -struct dma_fence *old_fence =NULL ; + unsigned i, j, k;dma_fence_get (fence);
@@ -162,24 +161,21 @@ reservation_object_add_shared_replace(struct reservation_object *obj,* references from the old struct are carried over to * the new. */ - fobj->shared_count = old->shared_count; - -for (i =0 ; i < old->shared_count; ++i) { +for (i =0 , j =0 , k = fobj->shared_max; i < old->shared_count; ++i) {struct dma_fence *check; check =rcu_dereference_protected (old->shared[i],reservation_object_held (obj)); -if (!old_fence && check->context == fence->context) { - old_fence = check; -RCU_INIT_POINTER (fobj->shared[i], fence); - }else -RCU_INIT_POINTER (fobj->shared[i], check); - } -if (!old_fence) { -RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); - fobj->shared_count++; +if (check->context == fence->context || +dma_fence_is_signaled (check)) +RCU_INIT_POINTER (fobj->shared[--k], check); +else +RCU_INIT_POINTER (fobj->shared[j++], check); } + fobj->shared_count = j; +RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); + fobj->shared_count++; done:preempt_disable ();
@@ -192,10 +188,18 @@ reservation_object_add_shared_replace(struct reservation_object *obj,write_seqcount_end (&obj->seq);preempt_enable (); -if (old) -kfree_rcu (old, rcu); +if (!old) +return ; -dma_fence_put (old_fence); +/* Drop the references to the signaled fences */ +for (i = k; i < fobj->shared_max; ++i) { +struct dma_fence *f; + + f =rcu_dereference_protected (fobj->shared[i], +reservation_object_held (obj)); +dma_fence_put (f); + } +kfree_rcu (old, rcu); }/**
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20171114142436.1360-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now.
Optimize the handling by replacing a signaled fence when adding a new shared one.
--- drivers/dma-buf/reservation.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/dma-buf/reservation.c +15 -3
@@ -104,7 +104,8 @@ reservation_object_add_shared_inplace(struct reservation_object *obj,struct reservation_object_list *fobj, struct dma_fence *fence) { - u32 i; + struct dma_fence *signaled = NULL; +u32 i, signaled_idx;dma_fence_get (fence);
@@ -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; + } }/* * memory barrier is added by write_seqcount_begin, * fobj->shared_count is protected by this lock too */ -RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); - fobj->shared_count++; +if (signaled) { +RCU_INIT_POINTER (fobj->shared[signaled_idx], fence); + }else { +RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); + fobj->shared_count++; + }write_seqcount_end (&obj->seq);preempt_enable (); + +dma_fence_put (signaled); } static void
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] dma-buf: try to replace a signaled fence in reservation_object_add_shared_inplace
Quoting Christian König (2017-11-14 14:24:36)
Quoted 7 lines
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now.
Optimize the handling by replacing a signaled fence when adding a new shared one.
Signed-off-by Christian König <[email protected]>
Does what you say, but not quite the same patch I've been testing. -Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoting Christian König (2017-11-14 14:24:35)
Quoted 12 lines
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now.
Optimize the list by keeping only the not signaled yet fences around.
v2: temporary put the signaled fences at the end of the new container
v3: put the old fence at the end of the new container as well.Signed-off-by Christian König <[email protected]>---
drivers/dma-buf/reservation.c +0
-2-if (!old_fence) { -RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence);
drivers/dma-buf/reservation.c reservation_object_add_shared_replace(struct reservation_object *obj, · line 178
Quoted 10 lines
drivers/dma-buf/reservation.c +8
-1- fobj->shared_count++; +if (check->context == fence->context || +dma_fence_is_signaled (check)) +RCU_INIT_POINTER (fobj->shared[--k], check); +else +RCU_INIT_POINTER (fobj->shared[j++], check); } + fobj->shared_count = j; +RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); + fobj->shared_count++;
I would keep the INIT_PTR(fobj->shared[j++], fence); fobj->shared_count = j;
I've been running an equivalent patch through our CI with nothing to report.
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 151067036925.20436.15268979839911647349-M6iVdVfohj6unts5RBS2dVaTQe2KTcn/@public.gmane.org
Chris Wilson
Tested-byQuoting Chris Wilson (2017-11-14 14:39:29)
Quoted 24 lines
Quoting Christian König (2017-11-14 14:24:35)
Quoted 12 lines
The amdgpu issue to also need signaled fences in the reservation objects should be fixed by now.
Optimize the list by keeping only the not signaled yet fences around.
v2: temporary put the signaled fences at the end of the new container
v3: put the old fence at the end of the new container as well.Signed-off-by Christian König <[email protected]>---
drivers/dma-buf/reservation.c +0
-2-if (!old_fence) { -RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence);drivers/dma-buf/reservation.c reservation_object_add_shared_replace(struct reservation_object *obj, · line 178
Quoted 10 lines
drivers/dma-buf/reservation.c +8
-1- fobj->shared_count++; +if (check->context == fence->context || +dma_fence_is_signaled (check)) +RCU_INIT_POINTER (fobj->shared[--k], check); +else +RCU_INIT_POINTER (fobj->shared[j++], check); } + fobj->shared_count = j; +RCU_INIT_POINTER (fobj->shared[fobj->shared_count], fence); + fobj->shared_count++;
Quoted 7 lines
I would keep the
INIT_PTR(fobj->shared[j++], fence);fobj->shared_count= j;Reviewed-by Chris Wilson <[email protected]>I've been running an equivalent patch through our CI with nothing to report.
Make as well make that formal,
-Chris
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx