drm/scheduler re-insert Bailing job to avoid memleak
Subsystems (4)
PATCH 1/1 drm/scheduler re-insert Bailing job to avoid memleak
re-insert Bailing jobs to avoid memory leak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++-- drivers/gpu/drm/scheduler/sched_main.c | 8 +++++++- include/drm/gpu_scheduler.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
@@ -4815,8 +4815,10 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, job ? job->base.id : -1);/* even we skipped this reset, still need to set the job to guilty */ -if (job) +if (job) {drm_sched_increase_karma (&job->base); + r =DRM_GPU_SCHED_STAT_BAILING ; + } goto skip_recovery; }
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6 -2
@@ -34,6 +34,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_job *job =to_amdgpu_job (s_job);struct amdgpu_task_info ti;struct amdgpu_device *adev = ring->adev; +int ret;memset (&ti,0 ,sizeof (struct amdgpu_task_info ));
@@ -52,8 +53,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { -amdgpu_device_gpu_recover (ring->adev, job); -return DRM_GPU_SCHED_STAT_NOMINAL ; + ret =amdgpu_device_gpu_recover (ring->adev, job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) +return DRM_GPU_SCHED_STAT_BAILING ; +else +return DRM_GPU_SCHED_STAT_NOMINAL ; }else {drm_sched_suspend_timeout (&ring->sched);if (amdgpu_sriov_vf (adev))
drivers/gpu/drm/scheduler/sched_main.c +7 -1
@@ -314,6 +314,7 @@ static void drm_sched_job_timedout(struct work_struct *work) {struct drm_gpu_scheduler *sched;struct drm_sched_job *job; +int ret; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);
@@ -331,8 +332,13 @@ static void drm_sched_job_timedout(struct work_struct *work)list_del_init (&job->list);spin_unlock (&sched->job_list_lock); - job->sched->ops->timedout_job (job); + ret = job->sched->ops->timedout_job (job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) { +spin_lock (&sched->job_list_lock); +list_add (&job->node, &sched->ring_mirror_list); +spin_unlock (&sched->job_list_lock); + }/* * Guilty job did complete and hence needs to be manually removed * See drm_sched_stop doc.
include/drm/gpu_scheduler.h +1 -0
@@ -210,6 +210,7 @@ enum drm_gpu_sched_stat {DRM_GPU_SCHED_STAT_NONE ,/* Reserve 0 */ DRM_GPU_SCHED_STAT_NOMINAL ,DRM_GPU_SCHED_STAT_ENODEV , + DRM_GPU_SCHED_STAT_BAILING, };/**
Signature · 6 lines
2.25.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
+dri-devel
Please be sure to cc dri-devel when you send out gpu scheduler patches.
Quoted 95 lines · Jack Zhang
re-insert Bailing jobs to avoid memory leak.
Signed-off-by Jack Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++-- drivers/gpu/drm/scheduler/sched_main.c | 8 +++++++- include/drm/gpu_scheduler.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4815,8 +4815,10 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, job ? job->base.id : -1);/* even we skipped this reset, still need to set the job to guilty */ -if (job) +if (job) {drm_sched_increase_karma (&job->base); + r =DRM_GPU_SCHED_STAT_BAILING ; + } goto skip_recovery; }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-2@@ -34,6 +34,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_job *job =to_amdgpu_job (s_job);struct amdgpu_task_info ti;struct amdgpu_device *adev = ring->adev; +int ret;memset (&ti,0 ,sizeof (struct amdgpu_task_info ));@@ -52,8 +53,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { -amdgpu_device_gpu_recover (ring->adev, job); -return DRM_GPU_SCHED_STAT_NOMINAL ; + ret =amdgpu_device_gpu_recover (ring->adev, job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) +return DRM_GPU_SCHED_STAT_BAILING ; +else +return DRM_GPU_SCHED_STAT_NOMINAL ; }else {drm_sched_suspend_timeout (&ring->sched);if (amdgpu_sriov_vf (adev))drivers/gpu/drm/scheduler/sched_main.c +7
-1@@ -314,6 +314,7 @@ static void drm_sched_job_timedout(struct work_struct *work) {struct drm_gpu_scheduler *sched;struct drm_sched_job *job; +int ret; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);@@ -331,8 +332,13 @@ static void drm_sched_job_timedout(struct work_struct *work)list_del_init (&job->list);spin_unlock (&sched->job_list_lock); - job->sched->ops->timedout_job (job); + ret = job->sched->ops->timedout_job (job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) { +spin_lock (&sched->job_list_lock); +list_add (&job->node, &sched->ring_mirror_list); +spin_unlock (&sched->job_list_lock); + }/* * Guilty job did complete and hence needs to be manually removed * See drm_sched_stop doc. include/drm/gpu_scheduler.h +1
-1@@ -210,6 +210,7 @@ enum drm_gpu_sched_stat {DRM_GPU_SCHED_STAT_NONE ,/* Reserve 0 */ DRM_GPU_SCHED_STAT_NOMINAL ,DRM_GPU_SCHED_STAT_ENODEV , + DRM_GPU_SCHED_STAT_BAILING, };/** -- 2.25.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Check panfrost driver at panfrost_scheduler_stop, and panfrost_job_timedout - they also terminate prematurely in both places so probably worth adding this there too.
Andrey
Quoted 74 lines · Alex Deucher
+dri-devel
Please be sure to cc dri-devel when you send out gpu scheduler patches.
Quoted 69 lines · Jack Zhang
re-insert Bailing jobs to avoid memory leak.
Signed-off-by Jack Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++-- drivers/gpu/drm/scheduler/sched_main.c | 8 +++++++- include/drm/gpu_scheduler.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4815,8 +4815,10 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, job ? job->base.id : -1);/* even we skipped this reset, still need to set the job to guilty */ -if (job) +if (job) {drm_sched_increase_karma (&job->base); + r =DRM_GPU_SCHED_STAT_BAILING ; + } goto skip_recovery; }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-2@@ -34,6 +34,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_job *job =to_amdgpu_job (s_job);struct amdgpu_task_info ti;struct amdgpu_device *adev = ring->adev; +int ret;memset (&ti,0 ,sizeof (struct amdgpu_task_info ));@@ -52,8 +53,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { -amdgpu_device_gpu_recover (ring->adev, job); -return DRM_GPU_SCHED_STAT_NOMINAL ; + ret =amdgpu_device_gpu_recover (ring->adev, job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) +return DRM_GPU_SCHED_STAT_BAILING ; +else +return DRM_GPU_SCHED_STAT_NOMINAL ; }else {drm_sched_suspend_timeout (&ring->sched);if (amdgpu_sriov_vf (adev))drivers/gpu/drm/scheduler/sched_main.c +1
-0@@ -314,6 +314,7 @@ static void drm_sched_job_timedout(struct work_struct *work) {struct drm_gpu_scheduler *sched;struct drm_sched_job *job; +int ret; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);@@ -331,8 +332,13 @@ static void drm_sched_job_timedout(struct work_struct *work)list_del_init (&job->list);spin_unlock (&sched->job_list_lock);
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_timedout(struct work_struct *work) · line 341
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +6
-1- job->sched->ops->timedout_job (job); + ret = job->sched->ops->timedout_job (job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) { +spin_lock (&sched->job_list_lock); +list_add (&job->node, &sched->ring_mirror_list); +spin_unlock (&sched->job_list_lock); + }
Problem here that since you already dropped the reset locks you are racing here now against other recovery threads as they process the same mirror list, and yet,I think this solution makes things better then they are now with the leak but still, it's only temporary band-aid until the full solution to be implemented. Probably then worth mentioning here with a comment this it's a temporary fix and that races are possible.
Andrey
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-0/* * Guilty job did complete and hence needs to be manually removed * See drm_sched_stop doc. include/drm/gpu_scheduler.h +1
-0@@ -210,6 +210,7 @@ enum drm_gpu_sched_stat {DRM_GPU_SCHED_STAT_NONE ,/* Reserve 0 */ DRM_GPU_SCHED_STAT_NOMINAL ,DRM_GPU_SCHED_STAT_ENODEV , + DRM_GPU_SCHED_STAT_BAILING, };
Quoted 8 lines
Quoted 8 lines
include/drm/gpu_scheduler.h +0
-1/** -- 2.25.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7CAndrey.Grodzovsky%40amd.com%7Cb8e9c87369a74a6b0f2a08d8e50d4707%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637511192474845823%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=FgOIeqk34Sk13L%2BbXYxbqja%2BDY8NSva4wDtUWBMS3q0%3D&reserved=0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
[AMD Official Use Only - Internal Distribution Only]
Hi, Andrey,
ok, I have changed it and uploaded V2 patch.
Thanks,
Jack
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, March 12, 2021 1:04 PM
To: Alex Deucher <[email protected]>; Zhang, Jack (Jian) <[email protected]>; Maling list - DRI developers <[email protected]>
Cc: amd-gfx list <[email protected]>; Koenig, Christian <[email protected]>; Liu, Monk <[email protected]>; Deng, Emily <[email protected]>
Subject: Re: [PATCH] drm/scheduler re-insert Bailing job to avoid memleak
Check panfrost driver at panfrost_scheduler_stop, and panfrost_job_timedout - they also terminate prematurely in both places so probably worth adding this there too.
Andrey
Quoted 78 lines · Alex Deucher
+dri-devel
Please be sure to cc dri-devel when you send out gpu scheduler patches.
Quoted 73 lines · Jack Zhang
re-insert Bailing jobs to avoid memory leak.
Signed-off-by Jack Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 8 ++++++-- drivers/gpu/drm/scheduler/sched_main.c | 8 +++++++- include/drm/gpu_scheduler.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3
-1@@ -4815,8 +4815,10 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev, job ? job->base.id : -1);/* even we skipped this reset, still need to set the job to guilty */ -if (job) +if (job) {drm_sched_increase_karma (&job->base); + r =DRM_GPU_SCHED_STAT_BAILING ; + } goto skip_recovery; }drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +6
-2@@ -34,6 +34,7 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job)struct amdgpu_job *job =to_amdgpu_job (s_job);struct amdgpu_task_info ti;struct amdgpu_device *adev = ring->adev; +int ret;memset (&ti,0 ,sizeof (struct amdgpu_task_info ));@@ -52,8 +53,11 @@ static enum drm_gpu_sched_stat amdgpu_job_timedout(struct drm_sched_job *s_job) ti.process_name, ti.tgid, ti.task_name, ti.pid);if (amdgpu_device_should_recover_gpu (ring->adev)) { -amdgpu_device_gpu_recover (ring->adev, job); -return DRM_GPU_SCHED_STAT_NOMINAL ; + ret =amdgpu_device_gpu_recover (ring->adev, job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) +return DRM_GPU_SCHED_STAT_BAILING ; +else +return DRM_GPU_SCHED_STAT_NOMINAL ; }else {drm_sched_suspend_timeout (&ring->sched); if (amdgpu_sriov_vf(adev)) diff --git
a/drivers/gpu/drm/scheduler/sched_main.cb/drivers/gpu/drm/scheduler/sched_main.c
index92d8de24d0a1..a44f621fb5c4100644drivers/gpu/drm/scheduler/sched_main.c +1
-0@@ -314,6 +314,7 @@ static void drm_sched_job_timedout(struct work_struct *work) {struct drm_gpu_scheduler *sched;struct drm_sched_job *job; +int ret; sched = container_of(work, struct drm_gpu_scheduler, work_tdr.work);@@ -331,8 +332,13 @@ static void drm_sched_job_timedout(struct work_struct *work)list_del_init (&job->list);spin_unlock (&sched->job_list_lock);
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c static void drm_sched_job_timedout(struct work_struct *work) · line 341
Quoted 8 lines
drivers/gpu/drm/scheduler/sched_main.c +6
-1- job->sched->ops->timedout_job (job); + ret = job->sched->ops->timedout_job (job); +if (ret ==DRM_GPU_SCHED_STAT_BAILING ) { +spin_lock (&sched->job_list_lock); +list_add (&job->node, &sched->ring_mirror_list); +spin_unlock (&sched->job_list_lock); + }
Problem here that since you already dropped the reset locks you are racing here now against other recovery threads as they process the same mirror list, and yet,I think this solution makes things better then they are now with the leak but still, it's only temporary band-aid until the full solution to be implemented. Probably then worth mentioning here with a comment this it's a temporary fix and that races are possible.
Andrey
Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/scheduler/sched_main.c +0
-0/* * Guilty job did complete and hence needs to be manually removed * See drm_sched_stop doc. (quoted diff) +0
-0
b/include/drm/gpu_scheduler.hindex4ea8606d91fe..8093ac2427ef100644include/drm/gpu_scheduler.h +1
-1@@ -210,6 +210,7 @@ enum drm_gpu_sched_stat {DRM_GPU_SCHED_STAT_NONE ,/* Reserve 0 */ DRM_GPU_SCHED_STAT_NOMINAL ,DRM_GPU_SCHED_STAT_ENODEV , + DRM_GPU_SCHED_STAT_BAILING, };/** -- 2.25.1
Quoted 10 lines
Quoted 10 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flis
ts.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7C Andrey.Grodzovsky%40amd.com%7Cb8e9c87369a74a6b0f2a08d8e50d4707%7C3dd8 961fe4884e608e11a82d994e183d%7C0%7C0%7C637511192474845823%7CUnknown%7 CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJX VCI6Mn0%3D%7C1000&sdata=FgOIeqk34Sk13L%2BbXYxbqja%2BDY8NSva4wDtUW BMS3q0%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx