Re: [PATCH v2 3/6] drm/sched: Warn if pending list is not empty

From: Tvrtko Ursulin
Date: Fri May 16 2025 - 05:40:29 EST



On 24/04/2025 10:55, Philipp Stanner wrote:
drm_sched_fini() can leak jobs under certain circumstances.

Warn if that happens.

Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
---
drivers/gpu/drm/scheduler/sched_main.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
index c2ad6c70bfb6..0c56b85c574f 100644
--- a/drivers/gpu/drm/scheduler/sched_main.c
+++ b/drivers/gpu/drm/scheduler/sched_main.c
@@ -1457,6 +1457,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
sched->ready = false;
kfree(sched->sched_rq);
sched->sched_rq = NULL;
+
+ if (!list_empty(&sched->pending_list))
+ dev_err(sched->dev, "Tearing down scheduler while jobs are pending!\n");

Is this expected to trigger for many drivers? In that case I am not sure if it helps anyone, apart from generating bug tracker entries across the world, for the issue we know about and could work
"quietly" on addressing it? Only if you think we don't really know who leaks and who doesn't and this will help figure out.

Hm wait, at this point in the series it would fire incorrectly for the mock scheduler. It should go last in the series at minimum.

Regards,

Tvrtko

}
EXPORT_SYMBOL(drm_sched_fini);