Incrementing the reference count on all objects walked when searching
for space in the aperture is a non-neglible amount of overhead. In fact,
we only need to hold on to a reference for objects that we will evict,
so we can therefore delay the referencing until we find a suitable hole
and only add those objects that fall inside.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_evict.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c 
b/drivers/gpu/drm/i915/i915_gem_evict.c
index b61f4f0f..354b584 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -39,7 +39,6 @@ mark_free(struct drm_i915_gem_object *obj, struct list_head 
*unwind)
                return false;
 
        list_add(&obj->exec_list, unwind);
-       drm_gem_object_reference(&obj->base);
        return drm_mm_scan_add_block(obj->gtt_space);
 }
 
@@ -144,7 +143,6 @@ none:
                BUG_ON(ret);
 
                list_del_init(&obj->exec_list);
-               drm_gem_object_unreference(&obj->base);
        }
 
        /* We expect the caller to unpin, evict all and try again, or give up.
@@ -163,10 +161,10 @@ found:
                                       exec_list);
                if (drm_mm_scan_remove_block(obj->gtt_space)) {
                        list_move(&obj->exec_list, &eviction_list);
+                       drm_gem_object_reference(&obj->base);
                        continue;
                }
                list_del_init(&obj->exec_list);
-               drm_gem_object_unreference(&obj->base);
        }
 
        /* Unbinding will emit any required flushes */
-- 
1.7.9.1

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

Reply via email to