public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/sched: Document racy behavior of drm_sched_entity_push_job()
@ 2025-11-12  7:31 Philipp Stanner
  2025-11-12  9:42 ` Tvrtko Ursulin
  0 siblings, 1 reply; 6+ messages in thread
From: Philipp Stanner @ 2025-11-12  7:31 UTC (permalink / raw)
  To: Matthew Brost, Philipp Stanner, Christian König,
	Maarten Lankhorst, tursulin
  Cc: dri-devel, linux-kernel

drm_sched_entity_push_job() uses the unlocked spsc_queue. It takes a
reference to that queue's tip at the start, and some time later removes
that entry from that list, without locking or protection against
preemption.

This is by design, since the spsc_queue demands single producer and
single consumer. It was, however, never documented.

Document that you must not call drm_sched_entity_push_job() in parallel
for the same entity.

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

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index 5a4697f636f2..b31e8d14aa20 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -562,6 +562,9 @@ void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
  * drm_sched_entity_push_job - Submit a job to the entity's job queue
  * @sched_job: job to submit
  *
+ * It is illegal to call this function in parallel, at least for jobs belonging
+ * to the same entity. Doing so leads to undefined behavior.
+ *
  * Note: To guarantee that the order of insertion to queue matches the job's
  * fence sequence number this function should be called with drm_sched_job_arm()
  * under common lock for the struct drm_sched_entity that was set up for
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-12 13:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12  7:31 [PATCH] drm/sched: Document racy behavior of drm_sched_entity_push_job() Philipp Stanner
2025-11-12  9:42 ` Tvrtko Ursulin
2025-11-12 12:15   ` Philipp Stanner
2025-11-12 13:13     ` Tvrtko Ursulin
2025-11-12 13:31       ` Philipp Stanner
2025-11-12 13:38         ` Tvrtko Ursulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox