drm/sched: Document reclaim restrictions for ops->prepare_job()
Subsystems (3)
Philipp Stanner
maintainerPATCH 1/1 drm/sched: Document reclaim restrictions for ops->prepare_job()
drm_sched_backend_ops->prepare_job() gets called from drm_sched_entity_pop_job(). Thus, it's in the fence critical path where a memory reclaim might wait for the job / fence to complete.
Sleeping in general seems to be (currently) allowed in prepare_job(), but a sleeping allocation risks deadlock.
Document the allocation pitfals for prepare_job().
---
Didn't we recently discuss deprecating this callback for good? There's a great many users, though...
--- include/drm/gpu_scheduler.h | 4 ++++ 1 file changed, 4 insertions(+)
include/drm/gpu_scheduler.h +4 -0
@@ -447,6 +447,10 @@ struct drm_sched_backend_ops {* * Can be NULL if no additional preparation to the dependencies are * necessary. Skipped when jobs are killed instead of run. +* +* This gets called in the job submission path (dma_fence critical path). +* You must not perform sleeping allocations in your implementation, or +* deadlock can occur. */ struct dma_fence *(*prepare_job)(struct drm_sched_job *sched_job,struct drm_sched_entity *s_entity);
Signature · 1 line
2.56.0
Danilo Krummrich
maintainerQuoted 22 lines · Philipp Stanner
drm_sched_backend_ops->prepare_job()gets called fromdrm_sched_entity_pop_job(). Thus, it's in the fence critical path where a memory reclaim might wait for the job / fence to complete.Sleeping in general seems to be (currently) allowed in
prepare_job(), but a sleeping allocation risks deadlock.Document the allocation pitfals for
prepare_job().Signed-off-by Philipp Stanner <[email protected]>---
Didn't we recently discuss deprecating this callback for good? There's a great many users, though...--- include/drm/gpu_scheduler.h | 4 ++++ 1 file changed, 4 insertions(+)include/drm/gpu_scheduler.h +0
-0
include/drm/gpu_scheduler.h struct drm_sched_backend_ops { · line 451
Quoted 5 lines
include/drm/gpu_scheduler.h +2
-0@@ -447,6 +447,10 @@ struct drm_sched_backend_ops {* * Can be NULL if no additional preparation to the dependencies are * necessary. Skipped when jobs are killed instead of run. +* +* This gets called in the job submission path (dma_fence critical path).
I think "job submission path" is slightly misleading. Not all of the operations a driver performs on job submission are within the DMA fence signaling critical path.
Maybe something like "This is called after the job's fence may have been published and hence must be considered a DMA fence sginaling critical section."
Quoted 7 lines
include/drm/gpu_scheduler.h +2
-0+* You must not perform sleeping allocations in your implementation, or +* deadlock can occur. */ struct dma_fence *(*prepare_job)(struct drm_sched_job *sched_job,struct drm_sched_entity *s_entity);Signature · 1 line
2.56.0