We treat our free list as a rough bidirectional MRU, at the tail we have
active buffers to be reallocated for rendering, and at the head we have
the inactive buffers that we can reallocate for use by the CPU. At both
ends we want the most recently used of each category to limit RSS upon
reuse.

At the time of freeing, we can inspect the busyness of the buffer to
decide if we should place it at the tail (for reuse of active buffers)
or head (for reuse of inactive buffers).

The question comes at the middle, what should we do? If we attempt to
allocate from the tail for an active buffer, but it is already idle,
should we prefer to reuse that or the mru idle from the head? Since we
have no immediate means for ranking the last access of the pair, we just
continue to use the one to hand.

Cc: Kenneth Graunke <kenn...@whitecape.org>
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 17036b53bc..19c9ba2fa5 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -633,7 +633,10 @@ bo_unreference_final(struct brw_bo *bo, time_t time)
       bo->name = NULL;
       bo->kflags = 0;
 
-      list_addtail(&bo->head, &bucket->head);
+      if (brw_bo_busy(bo))
+         list_addtail(&bo->head, &bucket->head);
+      else
+         list_add(&bo->head, &bucket->head);
    } else {
       bo_free(bo);
    }
-- 
2.15.0.rc1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to