All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/20] drm/i915/execlists: Convert recursive defer_request() into iterative
@ 2019-06-25 13:01 Chris Wilson
  2019-06-25 13:01 ` [PATCH 02/20] drm/i915/gt: Pass intel_gt to pm routines Chris Wilson
                   ` (28 more replies)
  0 siblings, 29 replies; 36+ messages in thread
From: Chris Wilson @ 2019-06-25 13:01 UTC (permalink / raw)
  To: intel-gfx

As this engine owns the lock around rq->sched.link (for those waiters
submitted to this engine), we can use that link as an element in a local
list. We can thus replace the recursive algorithm with an iterative walk
over the ordered list of waiters.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_lrc.c | 52 +++++++++++++++--------------
 1 file changed, 27 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 28685ba91a2c..22afd2616d7f 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -833,10 +833,9 @@ last_active(const struct intel_engine_execlists *execlists)
 	return *last;
 }
 
-static void
-defer_request(struct i915_request * const rq, struct list_head * const pl)
+static void defer_request(struct i915_request *rq, struct list_head * const pl)
 {
-	struct i915_dependency *p;
+	LIST_HEAD(list);
 
 	/*
 	 * We want to move the interrupted request to the back of
@@ -845,34 +844,37 @@ defer_request(struct i915_request * const rq, struct list_head * const pl)
 	 * flight and were waiting for the interrupted request to
 	 * be run after it again.
 	 */
-	list_move_tail(&rq->sched.link, pl);
+	do {
+		struct i915_dependency *p;
 
-	list_for_each_entry(p, &rq->sched.waiters_list, wait_link) {
-		struct i915_request *w =
-			container_of(p->waiter, typeof(*w), sched);
+		GEM_BUG_ON(i915_request_is_active(rq));
+		list_move_tail(&rq->sched.link, pl);
 
-		/* Leave semaphores spinning on the other engines */
-		if (w->engine != rq->engine)
-			continue;
+		list_for_each_entry(p, &rq->sched.waiters_list, wait_link) {
+			struct i915_request *w =
+				container_of(p->waiter, typeof(*w), sched);
 
-		/* No waiter should start before the active request completed */
-		GEM_BUG_ON(i915_request_started(w));
+			/* Leave semaphores spinning on the other engines */
+			if (w->engine != rq->engine)
+				continue;
 
-		GEM_BUG_ON(rq_prio(w) > rq_prio(rq));
-		if (rq_prio(w) < rq_prio(rq))
-			continue;
+			/* No waiter should start before its signaler */
+			GEM_BUG_ON(i915_request_started(w) &&
+				   !i915_request_completed(rq));
 
-		if (list_empty(&w->sched.link))
-			continue; /* Not yet submitted; unready */
+			GEM_BUG_ON(i915_request_is_active(w));
+			if (list_empty(&w->sched.link))
+				continue; /* Not yet submitted; unready */
 
-		/*
-		 * This should be very shallow as it is limited by the
-		 * number of requests that can fit in a ring (<64) and
-		 * the number of contexts that can be in flight on this
-		 * engine.
-		 */
-		defer_request(w, pl);
-	}
+			if (rq_prio(w) < rq_prio(rq))
+				continue;
+
+			GEM_BUG_ON(rq_prio(w) > rq_prio(rq));
+			list_move_tail(&w->sched.link, &list);
+		}
+
+		rq = list_first_entry_or_null(&list, typeof(*rq), sched.link);
+	} while (rq);
 }
 
 static void defer_active(struct intel_engine_cs *engine)
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2019-06-25 23:29 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 13:01 [PATCH 01/20] drm/i915/execlists: Convert recursive defer_request() into iterative Chris Wilson
2019-06-25 13:01 ` [PATCH 02/20] drm/i915/gt: Pass intel_gt to pm routines Chris Wilson
2019-06-25 18:07   ` Matthew Auld
2019-06-25 13:01 ` [PATCH 03/20] drm/i915/selftests: Serialise nop reset with retirement Chris Wilson
2019-06-25 13:01 ` [PATCH 04/20] drm/i915/selftests: Drop manual request wakerefs around hangcheck Chris Wilson
2019-06-25 13:01 ` [PATCH 05/20] drm/i915/selftests: Fixup atomic reset checking Chris Wilson
2019-06-25 13:01 ` [PATCH 06/20] drm/i915: Rename intel_wakeref_[is]_active Chris Wilson
2019-06-25 13:01 ` [PATCH 07/20] drm/i915: Add a wakeref getter for iff the wakeref is already active Chris Wilson
2019-06-25 13:01 ` [PATCH 08/20] drm/i915: Only recover active engines Chris Wilson
2019-06-25 13:01 ` [PATCH 09/20] drm/i915: Lift intel_engines_resume() to callers Chris Wilson
2019-06-25 13:01 ` [PATCH 10/20] drm/i915: Teach execbuffer to take the engine wakeref not GT Chris Wilson
2019-06-25 13:01 ` [PATCH 11/20] drm/i915/gt: Track timeline activeness in enter/exit Chris Wilson
2019-06-25 13:01 ` [PATCH 12/20] drm/i915/gt: Convert timeline tracking to spinlock Chris Wilson
2019-06-25 13:01 ` [PATCH 13/20] drm/i915/gt: Guard timeline pinning with its own mutex Chris Wilson
2019-06-25 13:01 ` [PATCH 14/20] drm/i915/selftests: Hold ref on request across waits Chris Wilson
2019-06-25 18:39   ` Matthew Auld
2019-06-25 13:01 ` [PATCH 15/20] drm/i915/gt: Always call kref_init for the timeline Chris Wilson
2019-06-25 18:42   ` Matthew Auld
2019-06-25 13:01 ` [PATCH 16/20] drm/i915/gt: Drop stale commentary for timeline density Chris Wilson
2019-06-25 23:28   ` Daniele Ceraolo Spurio
2019-06-25 13:01 ` [PATCH 17/20] drm/i915/gt: Add some debug tracing for context pinning Chris Wilson
2019-06-25 18:47   ` Matthew Auld
2019-06-25 13:01 ` [PATCH 18/20] drm/i915: Include the breadcrumb when asserting request completion Chris Wilson
2019-06-25 14:42   ` [PATCH] " Chris Wilson
2019-06-25 13:01 ` [PATCH 19/20] drm/i915: Protect request retirement with timeline->mutex Chris Wilson
2019-06-25 13:01 ` [PATCH 20/20] drm/i915: Replace struct_mutex for batch pool serialisation Chris Wilson
2019-06-25 14:09 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/20] drm/i915/execlists: Convert recursive defer_request() into iterative Patchwork
2019-06-25 14:38 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-06-25 15:10 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/20] drm/i915/execlists: Convert recursive defer_request() into iterative (rev2) Patchwork
2019-06-25 15:18 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-25 15:45 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-06-25 18:01 ` [PATCH 01/20] drm/i915/execlists: Convert recursive defer_request() into iterative Matthew Auld
2019-06-25 18:19 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/20] drm/i915/execlists: Convert recursive defer_request() into iterative (rev3) Patchwork
2019-06-25 18:28 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-25 19:35 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-25 22:10 ` ✓ Fi.CI.IGT: " Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.