All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Emily Deng <Emily.Deng-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amdgpu: add rcu_barrier after entity fini
Date: Thu, 17 May 2018 13:07:30 +0200	[thread overview]
Message-ID: <ec5de5ac-f9b8-53e5-0db4-3e0791469b40@gmail.com> (raw)
In-Reply-To: <1526551432-12599-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>

Am 17.05.2018 um 12:03 schrieb Emily Deng:
> 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
>
> Change-Id: I8dcadd3372f97e72461bf46b41cc26d90f09b8df
> Signed-off-by: Emily Deng <Emily.Deng@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> index 39ec6b8..42be65b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
> @@ -69,6 +69,7 @@ int amdgpu_fence_slab_init(void)
>   void amdgpu_fence_slab_fini(void)
>   {
>   	rcu_barrier();
> +	rcu_barrier();

Well, you should have noted that there is already an rcu_barrier here 
and adding another one shouldn't have any additional effect. So your 
explanation and the proposed solution doesn't make to much sense.

I think the problem you run into is rather that the fence is reference 
counted and might live longer than the module who created it.

Complicated issue, one possible solution would be to release 
fence->parent earlier in the scheduler fence but that doesn't sound like 
a general purpose solution.

Christian.

>   	kmem_cache_destroy(amdgpu_fence_slab);
>   }
>   /*

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-05-17 11:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-17 10:03 [PATCH] drm/amdgpu: add rcu_barrier after entity fini Emily Deng
     [not found] ` <1526551432-12599-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>
2018-05-17 11:07   ` Christian König [this message]
     [not found]     ` <ec5de5ac-f9b8-53e5-0db4-3e0791469b40-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-05-18  3:20       ` Deng, Emily
     [not found]         ` <CY4PR12MB112526B02190A3D892CCB84F8F900-rpdhrqHFk07v2MZdTKcfDgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-18  9:41           ` Deng, Emily
     [not found]             ` <BN6PR12MB11210121E65A155D901B94AE8F900-/b2+HYfkarSgw6z4+5+8kgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-18  9:45               ` Christian König
     [not found]                 ` <3f9070bd-ebce-77d4-5979-6ce383885064-5C7GfCeVMHo@public.gmane.org>
2018-05-18  9:56                   ` Deng, Emily
     [not found]                     ` <BN6PR12MB1121DDBFDB283E01AC198B038F900-/b2+HYfkarSgw6z4+5+8kgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-18 10:35                       ` Christian König
     [not found]                         ` <bc3fbefd-957a-9b89-8096-22b44f6dc3d2-5C7GfCeVMHo@public.gmane.org>
2018-05-21  7:54                           ` Deng, Emily
  -- strict thread matches above, loose matches on Subject: below --
2018-05-21  8:08 Emily Deng
     [not found] ` <1526890130-673-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>
2018-05-23  5:25   ` Deng, Emily
     [not found]     ` <CY4PR12MB1125509E5759D4FDB7C097998F6B0-rpdhrqHFk07v2MZdTKcfDgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-05-23  7:32       ` Christian König
     [not found]         ` <c19068bf-4c4d-bb74-f31c-f5b71a2f8333-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-05-23  7:47           ` Deng, Emily
2018-05-17  3:05 Emily Deng
     [not found] ` <1526526326-5130-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org>
2018-05-17  3:32   ` Zhou, David(ChunMing)
2018-05-17  7:42   ` Michel Dänzer
2018-05-17  8:39   ` Christian König
     [not found]     ` <a2990863-eea0-ecdd-0e86-f208fd91d59c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-05-17 10:01       ` Deng, Emily

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=ec5de5ac-f9b8-53e5-0db4-3e0791469b40@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Emily.Deng-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.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.