[PATCH 39/63] drm/i915: Retire oldest completed request before allocating next

Chris Wilson chris at chris-wilson.co.uk
Fri Jun 24 18:10:01 UTC 2016


In order to keep the memory allocated for requests reasonably tight, try
to reuse the oldest request (so long as it is completed and has no
external references) for the next allocation.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_request.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem_request.c b/drivers/gpu/drm/i915/i915_gem_request.c
index 7ef68a9b512e..54f0d2e9cc43 100644
--- a/drivers/gpu/drm/i915/i915_gem_request.c
+++ b/drivers/gpu/drm/i915/i915_gem_request.c
@@ -223,6 +223,13 @@ __i915_gem_request_alloc(struct intel_engine_cs *engine,
 	if (ret)
 		return ret;
 
+	if (!list_empty(&engine->request_list)) {
+		req = list_first_entry(&engine->request_list,
+				       typeof(*req), list);
+		if (i915_gem_request_completed(req))
+			i915_gem_request_retire(req);
+	}
+
 	req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL);
 	if (req == NULL)
 		return -ENOMEM;
-- 
2.8.1



More information about the Intel-gfx-trybot mailing list