[Intel-gfx] [PATCH 29/42] drm/i915/gt: Defer the kmem_cache_free() until after the HW submit
Chris Wilson
chris at chris-wilson.co.uk
Sun Aug 2 16:43:59 UTC 2020
Watching lock_stat, we noticed that the kmem_cache_free() would cause
the occasional multi-millisecond spike (directly affecting max-holdtime
and so the max-waittime). Delaying our submission of the next ELSP by a
millisecond will leave the GPU idle, so defer the kmem_cache_free()
until afterwards.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/gt/intel_lrc.c | 10 +++++++++-
drivers/gpu/drm/i915/i915_scheduler.c | 13 +++++++++++++
drivers/gpu/drm/i915/i915_scheduler.h | 12 ++++++++++++
3 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index e8f6d0a80c8e..7ac864cd57e3 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -2029,6 +2029,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
struct i915_request **port = execlists->pending;
struct i915_request ** const last_port = port + execlists->port_mask;
struct i915_request *last = *execlists->active;
+ struct list_head *free = NULL;
struct virtual_engine *ve;
struct rb_node *rb;
bool submit = false;
@@ -2316,8 +2317,9 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
}
}
+ /* Remove the node, but defer the free for later */
rb_erase_cached(&p->node, &execlists->queue);
- i915_priolist_free(p);
+ free = i915_priolist_free_defer(p, free);
}
done:
*port++ = i915_request_get(last);
@@ -2369,6 +2371,12 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
i915_request_put(*port);
*execlists->pending = NULL;
}
+
+ /*
+ * We noticed that kmem_cache_free() may cause 1ms+ latencies, so
+ * we defer the frees until after we have submitted the ELSP.
+ */
+ i915_priolist_free_many(free);
}
static inline void clear_ports(struct i915_request **ports, int count)
diff --git a/drivers/gpu/drm/i915/i915_scheduler.c b/drivers/gpu/drm/i915/i915_scheduler.c
index a9973d7a724c..bfbbd94dfcbc 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.c
+++ b/drivers/gpu/drm/i915/i915_scheduler.c
@@ -126,6 +126,19 @@ void __i915_priolist_free(struct i915_priolist *p)
kmem_cache_free(global.slab_priorities, p);
}
+void i915_priolist_free_many(struct list_head *list)
+{
+ while (list) {
+ struct i915_priolist *p;
+
+ p = container_of(list, typeof(*p), requests);
+ list = p->requests.next;
+
+ GEM_BUG_ON(p->priority == I915_PRIORITY_NORMAL);
+ kmem_cache_free(global.slab_priorities, p);
+ }
+}
+
struct sched_cache {
struct list_head *priolist;
};
diff --git a/drivers/gpu/drm/i915/i915_scheduler.h b/drivers/gpu/drm/i915/i915_scheduler.h
index b089d5cace1d..d8bf335c5e96 100644
--- a/drivers/gpu/drm/i915/i915_scheduler.h
+++ b/drivers/gpu/drm/i915/i915_scheduler.h
@@ -46,4 +46,16 @@ static inline void i915_priolist_free(struct i915_priolist *p)
__i915_priolist_free(p);
}
+void i915_priolist_free_many(struct list_head *list);
+
+static inline struct list_head *
+i915_priolist_free_defer(struct i915_priolist *p, struct list_head *free)
+{
+ if (p->priority != I915_PRIORITY_NORMAL) {
+ p->requests.next = free;
+ free = &p->requests;
+ }
+ return free;
+}
+
#endif /* _I915_SCHEDULER_H_ */
--
2.20.1
More information about the Intel-gfx
mailing list