Skip to content

RFC Deadline scheduler and other ideas

Tvrtko Ursulin dri-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 RFC Latest18 patches 21 repliesIn review

Changes in v2 from the cover letter

* Fixed many rebase errors.
* Added some new patches.
* Dropped single shot dependecy handling.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18drm/amdgpu: Use DRM scheduler API in amdgpu_xcp_release_scheddrivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c+1 -13 replies
2/18drm/sched: Delete unused update_job_creditsdrivers/gpu/drm/scheduler/sched_main.c include/drm/gpu_scheduler.h+0 -260 replies
3/18drm/sched: Remove one local variabledrivers/gpu/drm/scheduler/sched_main.c+1 -44 replies
4/18drm/sched: Remove weak paused submission checksdrivers/gpu/drm/scheduler/sched_main.c+0 -60 replies
5/18drm/sched: Avoid double re-lock on the job free pathdrivers/gpu/drm/scheduler/sched_main.c+11 -210 replies
6/18drm/sched: Add helper to check job dependenciesdrivers/gpu/drm/scheduler/sched_main.c include/drm/gpu_scheduler.h+25 -11 reply
7/18drm/imagination: Use the drm_sched_job_has_dependency helperdrivers/gpu/drm/imagination/pvr_job.c+3 -92 replies
8/18drm/sched: Clarify locked section in drm_sched_rq_select_entity_fifodrivers/gpu/drm/scheduler/sched_main.c+17 -140 replies
9/18drm/sched: Remove idle entity from treedrivers/gpu/drm/scheduler/sched_entity.c drivers/gpu/drm/scheduler/sched_main.c include/drm/gpu_scheduler.h+12 -90 replies
10/18drm/sched: Implement RR via FIFOdrivers/gpu/drm/scheduler/sched_entity.c drivers/gpu/drm/scheduler/sched_main.c include/drm/gpu_scheduler.h+39 -1004 replies
11/18drm/sched: Consolidate entity run queue managementdrivers/gpu/drm/scheduler/sched_entity.c drivers/gpu/drm/scheduler/sched_main.c include/drm/gpu_scheduler.h+88 -840 replies
12/18drm/sched: Move run queue related code into a separate filedrivers/gpu/drm/scheduler/Makefile drivers/gpu/drm/scheduler/sched_main.c drivers/gpu/drm/scheduler/sched_rq.c +1 more+222 -2092 replies
13/18drm/sched: Add deadline policydrivers/gpu/drm/scheduler/sched_entity.c drivers/gpu/drm/scheduler/sched_main.c drivers/gpu/drm/scheduler/sched_rq.c +1 more+64 -180 replies
14/18drm/sched: Remove FIFO and RR and simplify to a single run queuedrivers/gpu/drm/amd/amdgpu/amdgpu_job.c drivers/gpu/drm/scheduler/sched_entity.c drivers/gpu/drm/scheduler/sched_main.c +2 more+56 -1821 reply
15/18drm/sched: Queue all free credits in one worker invocationdrivers/gpu/drm/scheduler/sched_main.c drivers/gpu/drm/scheduler/sched_rq.c include/drm/gpu_scheduler.h+54 -740 replies
16/18drm/sched: Connect with dma-fence deadlinesdrivers/gpu/drm/scheduler/sched_entity.c+22 -24 replies
17/18drm/sched: Embed run queue singleton into the schedulerdrivers/gpu/drm/amd/amdgpu/amdgpu_cs.c drivers/gpu/drm/amd/amdgpu/amdgpu_job.c drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +8 more+58 -790 replies
18/18drm/sched: Scale deadlines depending on queue depthdrivers/gpu/drm/scheduler/sched_entity.c include/drm/gpu_scheduler.h+20 -60 replies

Reviews trailers per patch

4 of 18 patches have a Reviewed-by or Acked-by.

PatchDanilo KrummrichBoris BrezillonMatt CosterChristian König
1/18R-b
2/18A-b A-b A-b
3/18
4/18
5/18
6/18R-b
7/18R-b
8/18
9/18
10/18
11/18
12/18
13/18
14/18
15/18
16/18
17/18
18/18

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.

Read the v2 thread

Cover letter [RFC v2 00/18] Deadline scheduler and other ideas

<tldr>
Replacing FIFO with a flavour of deadline driven scheduling and removing round- robin. Connecting the scheduler with dma-fence deadlines. Second draft and testing by different drivers and feedback would be nice. I was only able to test it with amdgpu. Other drivers may not even compile.
</tldr>

If I remember correctly Christian mentioned recently (give or take) that maybe round-robin could be removed. That got me thinking how and what could be improved and simplified. So I played a bit in the scheduler code and came up with something which appears to not crash at least. Whether or not there are significant advantages apart from maybe code consolidation and reduction is the main thing to be determined.

One big question is whether round-robin can really be removed. Does anyone use it, rely on it, or what are even use cases where it is much better than FIFO.

See "drm/sched: Add deadline policy" commit message for a short description on what flavour of deadline scheduling it is. But in essence it should a more fair FIFO where higher priority can not forever starve lower priorities.

"drm/sched: Connect with dma-fence deadlines" wires up dma-fence deadlines to the scheduler because it is easy and makes logical sense with this. And I noticed userspace already uses it so why not wire it up fully.

Otherwise the series is a bit of progression from trivial cleanups to consolidating RR into FIFO code paths and going from there to deadline and then some code simplification to 1:1 run queue to scheduler relationship, because deadline does not need per priority run queues.

There is quite a bit of code to go throught here so I think it could be even better if other drivers could give it a spin as is and see if some improvements can be detected. Or at least no regressions.

v2:
* Fixed many rebase errors.
* Added some new patches.
* Dropped single shot dependecy handling.

Cc Christian König <[email protected]>
Cc Danilo Krummrich <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Philipp Stanner <[email protected]>

Tvrtko Ursulin (18):
drm/amdgpu: Use DRM scheduler API in amdgpu_xcp_release_sched drm/sched: Delete unused update_job_credits
drm/sched: Remove one local variable
drm/sched: Remove weak paused submission checks drm/sched: Avoid double re-lock on the job free path drm/sched: Add helper to check job dependencies drm/imagination: Use the drm_sched_job_has_dependency helper drm/sched: Clarify locked section in drm_sched_rq_select_entity_fifo drm/sched: Remove idle entity from tree
drm/sched: Implement RR via FIFO
drm/sched: Consolidate entity run queue management drm/sched: Move run queue related code into a separate file drm/sched: Add deadline policy
drm/sched: Remove FIFO and RR and simplify to a single run queue drm/sched: Queue all free credits in one worker invocation drm/sched: Connect with dma-fence deadlines
drm/sched: Embed run queue singleton into the scheduler drm/sched: Scale deadlines depending on queue depth

 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c      |   6 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c     |  27 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.h     |   5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h   |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c |   8 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c     |  10 +-
 drivers/gpu/drm/imagination/pvr_job.c       |  12 +-
 drivers/gpu/drm/scheduler/Makefile          |   2 +-
 drivers/gpu/drm/scheduler/sched_entity.c    | 147 +++---
 drivers/gpu/drm/scheduler/sched_fence.c     |   2 +-
 drivers/gpu/drm/scheduler/sched_main.c      | 541 ++++----------------
 drivers/gpu/drm/scheduler/sched_rq.c        | 177 +++++++
 include/drm/gpu_scheduler.h                 |  55 +-
 13 files changed, 424 insertions(+), 576 deletions(-)
 create mode 100644 drivers/gpu/drm/scheduler/sched_rq.c
Signature · 1 line
2.47.1