[Mesa-dev] [PATCH 8/8] i965/bufmgr: Allocate from the tail of the bucket free list

Jason Ekstrand jason at jlekstrand.net
Wed Jun 13 20:27:00 UTC 2018

The previous approach gave a sort of round-robin behavior which made
sense because we didn't want to walk the entire list looking for the
first idle BO.  Now that everything is idle, we can pick any BO in the
list and it should be fine.  Using the most recently used BO should give
us less over-all thrash than the round-robin because we will be trying
to re-use BOs as much as possible.
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index ef918315c65..02aea435e84 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -539,14 +539,10 @@ bo_alloc_internal(struct brw_bufmgr *bufmgr,
    alloc_from_cache = false;
    if (bucket != NULL && !list_empty(&bucket->head)) {
-      /* For non-render-target BOs (where we're probably
-       * going to map it first thing in order to fill it
-       * with data), check if the last BO in the cache is
-       * unbusy, and only reuse in that case. Otherwise,
-       * allocating a new buffer is probably faster than
-       * waiting for the GPU to finish.
+      /* Allocate BOs from the tail (MRU) of the list as it will likely be
+       * hotter in the GPU cache and in the aperature for us.
-      bo = LIST_ENTRY(struct brw_bo, bucket->head.next, head);
+      bo = LIST_ENTRY(struct brw_bo, bucket->head.prev, head);
       alloc_from_cache = true;

More information about the mesa-dev mailing list