[Intel-gfx] [PATCH] drm/i915: Evict everything if we detect we are buffer thrashing

Chris Wilson chris at chris-wilson.co.uk
Tue Dec 1 18:40:36 CET 2009


By scanning the inactive list for a single buffer to evict instead of
just popping the first elements until we have sufficient room may be
give measurably higher throughput, but opens the possibility of
thrashing between two large objects. If we spot that this happening,
then simply clear the entire aperture and start afresh. The alternate
is the page-fault-of-doom!

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 6dd451e..2f2ccbc 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2156,10 +2156,23 @@ i915_gem_evict_something(struct drm_device *dev, int min_size)
 		if (obj) {
 			struct drm_i915_gem_object *obj_priv;
 
+			obj_priv = obj->driver_private;
+
+			/* In the event that we have selected the most recently
+			 * bound object to evict, then we are in the midst of
+			 * thrashing the inactive list -- imagine a nearly full
+			 * aperture and we are copying between large objects,
+			 * only one of which can fit in at any one time. In
+			 * this case it is better just to evict everything and
+			 * start afresh -- or else suffer the page fault of
+			 * doom.
+			 */
+			if (obj_priv->list.next == &dev_priv->mm.inactive_list)
+				return i915_gem_evict_everything(dev);
+
 #if WATCH_LRU
 			DRM_INFO("%s: evicting %p\n", __func__, obj);
 #endif
-			obj_priv = obj->driver_private;
 			BUG_ON(obj_priv->pin_count != 0);
 			BUG_ON(obj_priv->active);
 
-- 
1.6.5.3




More information about the Intel-gfx mailing list