drm/amdgpu: put ctx's ref count in amdgpu_ctx_mgr_entity_fini()
Subsystems (2)
PATCH 1/1 drm/amdgpu: put ctx's ref count in amdgpu_ctx_mgr_entity_fini()
patch "daf823f1d0cd drm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will cause amdgpu_ctx_fini() cannot be called and then cause some finished fence that added by amdgpu_ctx_add_fence() cannot be released and cause memleak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1 -0
@@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)drm_sched_entity_fini (entity); } } +kref_put (&ctx->refcount, amdgpu_ctx_fini); } }
Signature · 1 line
2.46.1
Quoted 4 lines · Lin.Cao
patch "
daf823f1d0cddrm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will causeamdgpu_ctx_fini()cannot be called and then cause some finished fence that added byamdgpu_ctx_add_fence()cannot be released and cause memleak.
Ouch I removed the wrong one. :( Probably misread kref_put as kref_read..
But is the SHA correct? I see it is dd64956685fa.
Which would mean adding:
Regards,
Tvrtko
Quoted 17 lines
Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1
-0@@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)drm_sched_entity_fini (entity); } } +kref_put (&ctx->refcount, amdgpu_ctx_fini); } }
Quoted 10 lines · Tvrtko Ursulin
Quoted 4 lines · Lin.Cao
patch "
daf823f1d0cddrm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will causeamdgpu_ctx_fini()cannot be called and then cause some finished fence that added byamdgpu_ctx_add_fence()cannot be released and cause memleak.Ouch I removed the wrong one. :( Probably misread
kref_putaskref_read..Reviewed-by Tvrtko Ursulin <[email protected]>
Quoted 2 lines
But is the SHA correct? I see it is
dd64956685fa.
That could be because our internal branch is not yet rebased.
Quoted 4 lines
Which would mean adding:
Fixes dd64956685fa ("drm/amdgpu: Remove duplicated "context still alive" check")
And maybe CC stable? Or in which release is that patch upstream?
Regards,
Christian.
Quoted 23 lines
Regards,
Tvrtko
Quoted 17 lines
Signed-off-by Lin.Cao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c| 1 +1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1
-0@@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) drm_sched_entity_fini(entity); } } + kref_put(&ctx->refcount, amdgpu_ctx_fini); } }
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Ursulin, Christian,
I find the upstream patch: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dd64956685fa48358c4152d952070c8c073e5f89
May I ask if I can modify the commit msg as:
drm/amdgpu: Fix memory leak in amdgpu_ctx_mgr_entity_fini
patch "dd64956685fa drm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will cause amdgpu_ctx_fini() cannot be called and then cause some finished fence that added by amdgpu_ctx_add_fence() cannot be released and cause memleak.
Thanks,
Lin
________________________________
From: Koenig, Christian <[email protected]>
Sent: Tuesday, June 24, 2025 21:11
To: Tvrtko Ursulin <[email protected]>; cao, lin <[email protected]>; [email protected] <[email protected]>
Cc: Chang, HaiJun <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: put ctx's ref count in amdgpu_ctx_mgr_entity_fini()
Quoted 10 lines · Tvrtko Ursulin
Quoted 4 lines · Lin.Cao
patch "
daf823f1d0cddrm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will causeamdgpu_ctx_fini()cannot be called and then cause some finished fence that added byamdgpu_ctx_add_fence()cannot be released and cause memleak.Ouch I removed the wrong one. :( Probably misread
kref_putaskref_read..Reviewed-by Tvrtko Ursulin <[email protected]>
Quoted 2 lines
But is the SHA correct? I see it is
dd64956685fa.
That could be because our internal branch is not yet rebased.
Quoted 4 lines
Which would mean adding:
Fixes dd64956685fa ("drm/amdgpu: Remove duplicated "context still alive" check")
And maybe CC stable? Or in which release is that patch upstream?
Regards,
Christian.
Quoted 23 lines
Regards,
Tvrtko
Quoted 17 lines
Signed-off-by Lin.Cao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 1 + 1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1
-0@@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr)drm_sched_entity_fini (entity); } } +kref_put (&ctx->refcount, amdgpu_ctx_fini); } }
Quoted 16 lines · lin
[AMD Official Use Only - AMD Internal Distribution Only]
Hi Ursulin, Christian,
I find the upstream patch: https://git.kernel.org/pub/scm/linux/kernel/ git/torvalds/linux.git/commit/? id=dd64956685fa48358c4152d952070c8c073e5f89 <https://git.kernel.org/pub/ scm/linux/kernel/git/torvalds/linux.git/commit/? id=dd64956685fa48358c4152d952070c8c073e5f89>
May I ask if I can modify the commit msg as:
drm/amdgpu: Fix memory leak in
amdgpu_ctx_mgr_entity_finipatch "
dd64956685fadrm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will causeamdgpu_ctx_fini()cannot be called and then cause some finished fence that added byamdgpu_ctx_add_fence()cannot be released and cause memleak.
Quoted 4 lines
Fixes dd64956685fa ("drm/amdgpu: Remove duplicated "context still alive" check")Signed-off-by Lin.Cao <[email protected]>Reviewed-by Tvrtko Ursulin <[email protected]>Acked-by Christian König <[email protected]>
Looks good to me.
Regards,
Tvrtko
Quoted 59 lines
------------------------------------------------------------------------
*From:* Koenig, Christian <[email protected]>
*Sent:* Tuesday, June 24, 2025 21:11
*To:* Tvrtko Ursulin <[email protected]>; cao, lin <[email protected]>; [email protected] <[email protected]> *Cc:* Chang, HaiJun <[email protected]>
*Subject:* Re: [PATCH] drm/amdgpu: put ctx's ref count inamdgpu_ctx_mgr_entity_fini()Quoted 10 lines · Tvrtko Ursulin
Quoted 4 lines · Lin.Cao
patch "
daf823f1d0cddrm/amdgpu: Remove duplicated "context still alive" check" removed ctx put, which will causeamdgpu_ctx_fini()cannot be called and then cause some finished fence that added byamdgpu_ctx_add_fence()cannot be released and cause memleak.Ouch I removed the wrong one. :( Probably misread
kref_putaskref_read..Reviewed-by Tvrtko Ursulin <[email protected]>Acked-by Christian König <[email protected]>Quoted 2 lines
But is the SHA correct? I see it is
dd64956685fa.That could be because our internal branch is not yet rebased.
Quoted 4 lines
Which would mean adding:
Fixes dd64956685fa ("drm/amdgpu: Remove duplicated "context still alive" check")And maybe CC stable? Or in which release is that patch upstream?
Regards,
Christian.Quoted 23 lines
Regards,
Tvrtko
Quoted 17 lines
Signed-off-by Lin.Cao <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c| 1 +1 file changed, 1 insertion(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +1
-0@@ -944,6 +944,7 @@ static void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr) drm_sched_entity_fini(entity); } } + kref_put(&ctx->refcount, amdgpu_ctx_fini); } }