linux/drivers/gpu/drm/scheduler
Tvrtko Ursulin 2ab510e631 drm/sched: Fix virtual runtime race
Prevent pushing a new job to an entity seeing it being the first in the
queue, and hence entering the drm_sched_rq_add_entity() path, if the pop
side in drm_sched_entity_pop_job() has just de-queued the job but not yet
updated the saved virtual time.

Restoring the unsaved virtual time, which is at this point not a delta but
still an absolute value, pushes the said entity to the rear of the run queue
for a potentially very long time.

We close this race by pulling the locked sections out to encompass both
the queue push/pop and corresponding rbtree management.

This is aligned with the future direction to replace the current lockless
job queue with one of the fully locked standard list primitives.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Fixes: 2fa4d8e2c1 ("drm/sched: Add fair scheduling policy")
Suggested-by: Luke.Wildhardt@proton.me # via Claude Opus
Tested-by: Luke.Wildhardt@proton.me
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Philipp Stanner <phasta@kernel.org>
Cc: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Vitaly Prosyak <vitaly.prosyak@amd.com>
Cc: stable@vger.kernel.org # v7.2+
[phasta: commit title]
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20260915150557.62847-1-tvrtko.ursulin@igalia.com
2026-09-16 09:17:51 +02:00
..
tests drm/sched: Create a fake device for KUnit tests 2026-09-08 14:25:54 +02:00
.kunitconfig drm/sched: Add scheduler unit testing infrastructure and some basic tests 2025-03-24 10:41:52 +01:00
gpu_scheduler_trace.h drm/doc: Document some tracepoints as uAPI 2025-05-28 16:16:18 +02:00
Makefile drm/sched: Move run queue related code into a separate file 2026-04-17 14:43:28 +02:00
sched_entity.c drm/sched: Fix virtual runtime race 2026-09-16 09:17:51 +02:00
sched_fence.c Revert "drm/sched: Embed run queue singleton into the scheduler" 2026-08-11 17:34:06 +01:00
sched_internal.h Revert "drm/sched: Remove FIFO and RR and simplify to a single run queue" 2026-08-11 17:34:10 +01:00
sched_main.c Linux 7.2 2026-08-20 10:58:44 +10:00
sched_rq.c drm/sched: Fix virtual runtime race 2026-09-16 09:17:51 +02:00