[Intel-gfx] [PATCH 3/3] drm/i915/execlists: Cache the last priolist lookup

Chris Wilson chris at chris-wilson.co.uk
Mon Sep 25 12:49:29 UTC 2017


From: Michał Winiarski <michal.winiarski at intel.com>

Avoid the repeated rbtree lookup for each request as we unwind them by
tracking the last priolist.

Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_lrc.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c84831c7ea4a..7802b1bd2b5c 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -357,13 +357,14 @@ static void unwind_wa_tail(struct drm_i915_gem_request *rq)
 
 static void unwind_incomplete_requests(struct intel_engine_cs *engine)
 {
+	struct i915_priolist *p = &engine->execlists.default_priolist;
+	int last_prio = I915_PRIORITY_NORMAL;
 	struct drm_i915_gem_request *rq, *rn;
 
 	lockdep_assert_held(&engine->timeline->lock);
 	list_for_each_entry_safe_reverse(rq, rn,
 					 &engine->timeline->requests,
 					 link) {
-		struct i915_priolist *p;
 
 		if (i915_gem_request_completed(rq))
 			return;
@@ -371,11 +372,16 @@ static void unwind_incomplete_requests(struct intel_engine_cs *engine)
 		__i915_gem_request_unsubmit(rq);
 		unwind_wa_tail(rq);
 
-		p = lookup_priolist(engine,
-				    &rq->priotree,
-				    rq->priotree.priority);
-		list_add(&rq->priotree.link,
-			 &ptr_mask_bits(p, 1)->requests);
+		if (rq->priotree.priority != last_prio) {
+			p = lookup_priolist(engine,
+					    &rq->priotree,
+					    rq->priotree.priority);
+			p = ptr_mask_bits(p, 1);
+
+			last_prio = rq->priotree.priority;
+		}
+
+		list_add(&rq->priotree.link, &p->requests);
 	}
 }
 
-- 
2.14.1



More information about the Intel-gfx mailing list