Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/sched: Simplify idle entity check
@ 2026-01-07 13:44 Tvrtko Ursulin
  2026-01-07 13:50 ` ✗ CI.checkpatch: warning for " Patchwork
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Tvrtko Ursulin @ 2026-01-07 13:44 UTC (permalink / raw)
  To: dri-devel
  Cc: kernel-dev, intel-xe, Tvrtko Ursulin, Christian König,
	Danilo Krummrich, Matthew Brost, Philipp Stanner

drm_sched_entity_is_idle() is called when flushing the entity before
destroying it and currently decides on the idle status based either on
number of jobs in its queue being zero, or whether the entity is not part
of any run-queue.

If entity is not part of a run-queue it is implied it can have no jobs in
its queue, from which it follows it is redundant to look at the both and
we can simplify to only look at the queue.

The list_empty() check was added in
a875f58e237a ("drm/scheduler: stop setting rq to NULL")
where it replaced the entity->rq check which was added in
741f01e636b7 ("drm/scheduler: Avoid using wait_event_killable for dying process (V4)").

Since for the submit race involving exiting entities, explicit handling
via entity->stopped was added soon after in
62347a33001c ("drm/scheduler: Add stopped flag to drm_sched_entity")
it indeed looks we are safe to remove the list_empty() check.

This mean we can remove the memory barrier as well and fewer memory
barriers the better.

While at it, we add READ_ONCE annotation on the entity->stopped check to
mark the unlocked read.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Philipp Stanner <phasta@kernel.org>
---
 drivers/gpu/drm/scheduler/sched_entity.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/scheduler/sched_entity.c b/drivers/gpu/drm/scheduler/sched_entity.c
index bb7e5fc47f99..2ed84504cfd6 100644
--- a/drivers/gpu/drm/scheduler/sched_entity.c
+++ b/drivers/gpu/drm/scheduler/sched_entity.c
@@ -137,14 +137,8 @@ EXPORT_SYMBOL(drm_sched_entity_modify_sched);
 
 static bool drm_sched_entity_is_idle(struct drm_sched_entity *entity)
 {
-	rmb(); /* for list_empty to work without lock */
-
-	if (list_empty(&entity->list) ||
-	    spsc_queue_count(&entity->job_queue) == 0 ||
-	    entity->stopped)
-		return true;
-
-	return false;
+	return spsc_queue_count(&entity->job_queue) == 0 ||
+	       READ_ONCE(entity->stopped);
 }
 
 /**
-- 
2.52.0


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

end of thread, other threads:[~2026-01-15 13:31 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 13:44 [PATCH] drm/sched: Simplify idle entity check Tvrtko Ursulin
2026-01-07 13:50 ` ✗ CI.checkpatch: warning for " Patchwork
2026-01-07 13:51 ` ✓ CI.KUnit: success " Patchwork
2026-01-07 14:08 ` [PATCH] " Danilo Krummrich
2026-01-09 14:08   ` Danilo Krummrich
2026-01-07 14:11 ` Philipp Stanner
2026-01-09 14:06   ` Tvrtko Ursulin
2026-01-09 14:31     ` Christian König
2026-01-15 13:30       ` Tvrtko Ursulin
2026-01-09 14:48     ` Philipp Stanner
2026-01-09 15:11       ` Christian König
2026-01-12 10:35       ` Tvrtko Ursulin
2026-01-07 14:29 ` ✓ Xe.CI.BAT: success for " Patchwork
2026-01-07 16:32 ` ✗ Xe.CI.Full: failure " Patchwork

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