drm/amdgpu: add rcu_barrier after entity fini

Submitted by Deng, Emily on May 21, 2018, 8:08 a.m.

Details

Message ID 1526890130-673-1-git-send-email-Emily.Deng@amd.com
State New
Headers show
Series "drm/amdgpu: add rcu_barrier after entity fini" ( rev: 4 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Deng, Emily May 21, 2018, 8:08 a.m.
To free the fence from the amdgpu_fence_slab, need twice call_rcu, to avoid
the amdgpu_fence_slab_fini call kmem_cache_destroy(amdgpu_fence_slab) before
kmem_cache_free(amdgpu_fence_slab, fence), add rcu_barrier after drm_sched_entity_fini.

The kmem_cache_free(amdgpu_fence_slab, fence)'s call trace as below:
1.drm_sched_entity_fini ->
drm_sched_entity_cleanup ->
dma_fence_put(entity->last_scheduled) ->
drm_sched_fence_release_finished ->
drm_sched_fence_release_scheduled ->
call_rcu(&fence->finished.rcu, drm_sched_fence_free)

2.drm_sched_fence_free ->
dma_fence_put(fence->parent) ->
amdgpu_fence_release ->
call_rcu(&f->rcu, amdgpu_fence_free) ->
kmem_cache_free(amdgpu_fence_slab, fence);

v2:put the barrier before the kmem_cache_destroy
v3:put the dma_fence_put(fence->parent) before call_rcu in
drm_sched_fence_release_scheduled

Change-Id: I8dcadd3372f97e72461bf46b41cc26d90f09b8df
Signed-off-by: Emily Deng <Emily.Deng@amd.com>
---
 drivers/gpu/drm/scheduler/sched_fence.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/scheduler/sched_fence.c b/drivers/gpu/drm/scheduler/sched_fence.c
index 786b47f..df44616 100644
--- a/drivers/gpu/drm/scheduler/sched_fence.c
+++ b/drivers/gpu/drm/scheduler/sched_fence.c
@@ -98,7 +98,6 @@  static void drm_sched_fence_free(struct rcu_head *rcu)
 	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
 	struct drm_sched_fence *fence = to_drm_sched_fence(f);
 
-	dma_fence_put(fence->parent);
 	kmem_cache_free(sched_fence_slab, fence);
 }
 
@@ -114,6 +113,7 @@  static void drm_sched_fence_release_scheduled(struct dma_fence *f)
 {
 	struct drm_sched_fence *fence = to_drm_sched_fence(f);
 
+	dma_fence_put(fence->parent);
 	call_rcu(&fence->finished.rcu, drm_sched_fence_free);
 }
 

Comments

Ping ......

> -----Original Message-----
> From: Emily Deng [mailto:Emily.Deng@amd.com]
> Sent: Monday, May 21, 2018 4:09 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Deng, Emily <Emily.Deng@amd.com>
> Subject: [PATCH] drm/amdgpu: add rcu_barrier after entity fini
> 
> To free the fence from the amdgpu_fence_slab, need twice call_rcu, to
> avoid the amdgpu_fence_slab_fini call
> kmem_cache_destroy(amdgpu_fence_slab) before
> kmem_cache_free(amdgpu_fence_slab, fence), add rcu_barrier after
> drm_sched_entity_fini.
> 
> The kmem_cache_free(amdgpu_fence_slab, fence)'s call trace as below:
> 1.drm_sched_entity_fini ->
> drm_sched_entity_cleanup ->
> dma_fence_put(entity->last_scheduled) ->
> drm_sched_fence_release_finished ->
> drm_sched_fence_release_scheduled -> call_rcu(&fence->finished.rcu,
> drm_sched_fence_free)
> 
> 2.drm_sched_fence_free ->
> dma_fence_put(fence->parent) ->
> amdgpu_fence_release ->
> call_rcu(&f->rcu, amdgpu_fence_free) ->
> kmem_cache_free(amdgpu_fence_slab, fence);
> 
> v2:put the barrier before the kmem_cache_destroy v3:put the
> dma_fence_put(fence->parent) before call_rcu in
> drm_sched_fence_release_scheduled
> 
> Change-Id: I8dcadd3372f97e72461bf46b41cc26d90f09b8df
> Signed-off-by: Emily Deng <Emily.Deng@amd.com>
> ---
>  drivers/gpu/drm/scheduler/sched_fence.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c
> b/drivers/gpu/drm/scheduler/sched_fence.c
> index 786b47f..df44616 100644
> --- a/drivers/gpu/drm/scheduler/sched_fence.c
> +++ b/drivers/gpu/drm/scheduler/sched_fence.c
> @@ -98,7 +98,6 @@ static void drm_sched_fence_free(struct rcu_head *rcu)
>  	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
>  	struct drm_sched_fence *fence = to_drm_sched_fence(f);
> 
> -	dma_fence_put(fence->parent);
>  	kmem_cache_free(sched_fence_slab, fence);  }
> 
> @@ -114,6 +113,7 @@ static void
> drm_sched_fence_release_scheduled(struct dma_fence *f)  {
>  	struct drm_sched_fence *fence = to_drm_sched_fence(f);
> 
> +	dma_fence_put(fence->parent);
>  	call_rcu(&fence->finished.rcu, drm_sched_fence_free);  }
> 
> --
> 2.7.4
Sorry missed that one.

Patch is Reviewed-by: Christian König <christian.koenig@amd.com>.

Nice work,
Christian.

Am 23.05.2018 um 07:25 schrieb Deng, Emily:
> Ping ......
>
>> -----Original Message-----
>> From: Emily Deng [mailto:Emily.Deng@amd.com]
>> Sent: Monday, May 21, 2018 4:09 PM
>> To: amd-gfx@lists.freedesktop.org
>> Cc: Deng, Emily <Emily.Deng@amd.com>
>> Subject: [PATCH] drm/amdgpu: add rcu_barrier after entity fini
>>
>> To free the fence from the amdgpu_fence_slab, need twice call_rcu, to
>> avoid the amdgpu_fence_slab_fini call
>> kmem_cache_destroy(amdgpu_fence_slab) before
>> kmem_cache_free(amdgpu_fence_slab, fence), add rcu_barrier after
>> drm_sched_entity_fini.
>>
>> The kmem_cache_free(amdgpu_fence_slab, fence)'s call trace as below:
>> 1.drm_sched_entity_fini ->
>> drm_sched_entity_cleanup ->
>> dma_fence_put(entity->last_scheduled) ->
>> drm_sched_fence_release_finished ->
>> drm_sched_fence_release_scheduled -> call_rcu(&fence->finished.rcu,
>> drm_sched_fence_free)
>>
>> 2.drm_sched_fence_free ->
>> dma_fence_put(fence->parent) ->
>> amdgpu_fence_release ->
>> call_rcu(&f->rcu, amdgpu_fence_free) ->
>> kmem_cache_free(amdgpu_fence_slab, fence);
>>
>> v2:put the barrier before the kmem_cache_destroy v3:put the
>> dma_fence_put(fence->parent) before call_rcu in
>> drm_sched_fence_release_scheduled
>>
>> Change-Id: I8dcadd3372f97e72461bf46b41cc26d90f09b8df
>> Signed-off-by: Emily Deng <Emily.Deng@amd.com>
>> ---
>>   drivers/gpu/drm/scheduler/sched_fence.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c
>> b/drivers/gpu/drm/scheduler/sched_fence.c
>> index 786b47f..df44616 100644
>> --- a/drivers/gpu/drm/scheduler/sched_fence.c
>> +++ b/drivers/gpu/drm/scheduler/sched_fence.c
>> @@ -98,7 +98,6 @@ static void drm_sched_fence_free(struct rcu_head *rcu)
>>   	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);
>>   	struct drm_sched_fence *fence = to_drm_sched_fence(f);
>>
>> -	dma_fence_put(fence->parent);
>>   	kmem_cache_free(sched_fence_slab, fence);  }
>>
>> @@ -114,6 +113,7 @@ static void
>> drm_sched_fence_release_scheduled(struct dma_fence *f)  {
>>   	struct drm_sched_fence *fence = to_drm_sched_fence(f);
>>
>> +	dma_fence_put(fence->parent);
>>   	call_rcu(&fence->finished.rcu, drm_sched_fence_free);  }
>>
>> --
>> 2.7.4
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Thanks.

Best Wishes,
Emily Deng

> -----Original Message-----

> From: Christian König [mailto:ckoenig.leichtzumerken@gmail.com]

> Sent: Wednesday, May 23, 2018 3:33 PM

> To: Deng, Emily <Emily.Deng@amd.com>; amd-gfx@lists.freedesktop.org

> Subject: Re: [PATCH] drm/amdgpu: add rcu_barrier after entity fini

> 

> Sorry missed that one.

> 

> Patch is Reviewed-by: Christian König <christian.koenig@amd.com>.

> 

> Nice work,

> Christian.

> 

> Am 23.05.2018 um 07:25 schrieb Deng, Emily:

> > Ping ......

> >

> >> -----Original Message-----

> >> From: Emily Deng [mailto:Emily.Deng@amd.com]

> >> Sent: Monday, May 21, 2018 4:09 PM

> >> To: amd-gfx@lists.freedesktop.org

> >> Cc: Deng, Emily <Emily.Deng@amd.com>

> >> Subject: [PATCH] drm/amdgpu: add rcu_barrier after entity fini

> >>

> >> To free the fence from the amdgpu_fence_slab, need twice call_rcu, to

> >> avoid the amdgpu_fence_slab_fini call

> >> kmem_cache_destroy(amdgpu_fence_slab) before

> >> kmem_cache_free(amdgpu_fence_slab, fence), add rcu_barrier after

> >> drm_sched_entity_fini.

> >>

> >> The kmem_cache_free(amdgpu_fence_slab, fence)'s call trace as below:

> >> 1.drm_sched_entity_fini ->

> >> drm_sched_entity_cleanup ->

> >> dma_fence_put(entity->last_scheduled) ->

> >> drm_sched_fence_release_finished ->

> drm_sched_fence_release_scheduled

> >> -> call_rcu(&fence->finished.rcu,

> >> drm_sched_fence_free)

> >>

> >> 2.drm_sched_fence_free ->

> >> dma_fence_put(fence->parent) ->

> >> amdgpu_fence_release ->

> >> call_rcu(&f->rcu, amdgpu_fence_free) ->

> >> kmem_cache_free(amdgpu_fence_slab, fence);

> >>

> >> v2:put the barrier before the kmem_cache_destroy v3:put the

> >> dma_fence_put(fence->parent) before call_rcu in

> >> drm_sched_fence_release_scheduled

> >>

> >> Change-Id: I8dcadd3372f97e72461bf46b41cc26d90f09b8df

> >> Signed-off-by: Emily Deng <Emily.Deng@amd.com>

> >> ---

> >>   drivers/gpu/drm/scheduler/sched_fence.c | 2 +-

> >>   1 file changed, 1 insertion(+), 1 deletion(-)

> >>

> >> diff --git a/drivers/gpu/drm/scheduler/sched_fence.c

> >> b/drivers/gpu/drm/scheduler/sched_fence.c

> >> index 786b47f..df44616 100644

> >> --- a/drivers/gpu/drm/scheduler/sched_fence.c

> >> +++ b/drivers/gpu/drm/scheduler/sched_fence.c

> >> @@ -98,7 +98,6 @@ static void drm_sched_fence_free(struct rcu_head

> *rcu)

> >>   	struct dma_fence *f = container_of(rcu, struct dma_fence, rcu);

> >>   	struct drm_sched_fence *fence = to_drm_sched_fence(f);

> >>

> >> -	dma_fence_put(fence->parent);

> >>   	kmem_cache_free(sched_fence_slab, fence);  }

> >>

> >> @@ -114,6 +113,7 @@ static void

> >> drm_sched_fence_release_scheduled(struct dma_fence *f)  {

> >>   	struct drm_sched_fence *fence = to_drm_sched_fence(f);

> >>

> >> +	dma_fence_put(fence->parent);

> >>   	call_rcu(&fence->finished.rcu, drm_sched_fence_free);  }

> >>

> >> --

> >> 2.7.4

> > _______________________________________________

> > amd-gfx mailing list

> > amd-gfx@lists.freedesktop.org

> > https://lists.freedesktop.org/mailman/listinfo/amd-gfx