Mesa (master): iris: Be lazy about cleaning up purged BOs in the cache.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 30 07:13:29 UTC 2019


Module: Mesa
Branch: master
Commit: 53878f7a8989879b0f3ca37df9fd1fb37f2525ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=53878f7a8989879b0f3ca37df9fd1fb37f2525ca

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed May 29 23:20:31 2019 -0700

iris: Be lazy about cleaning up purged BOs in the cache.

Mathias Fröhlich reported that commit 6244da8e23e5470d067680 crashes.
list_for_each_entry_safe is safe against removing the current entry,
but iris_bo_cache_purge_bucket was potentially removing next entries
too, which broke our saved next pointer.

To fix this, don't bother with the iris_bo_cache_purge_bucket step.
We just detected a single entry where the kernel has purged the BO's
memory, and so it isn't a usable entry for our cache.  We're about to
continue the search with the next BO.  If that one's purged, we'll
clean it up too.  And so on.

We may miss cleaning up purged BOs that are further down the list
after non-purged BOs...but that's probably fine.  We still have the
time-based cleaner (cleanup_bo_cache) which will take care of them
eventually, and the kernel's already freed their memory, so it's not
that harmful to have a few kicking around a little longer.

Fixes: 6244da8e23e iris: Dig through the cache to find a BO in the right memzone
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>

---

 src/gallium/drivers/iris/iris_bufmgr.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 40559b4c1f9..6531118d1b0 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -336,20 +336,6 @@ iris_bo_madvise(struct iris_bo *bo, int state)
    return madv.retained;
 }
 
-/* drop the oldest entries that have been purged by the kernel */
-static void
-iris_bo_cache_purge_bucket(struct iris_bufmgr *bufmgr,
-                          struct bo_cache_bucket *bucket)
-{
-   list_for_each_entry_safe(struct iris_bo, bo, &bucket->head, head) {
-      if (iris_bo_madvise(bo, I915_MADV_DONTNEED))
-         break;
-
-      list_del(&bo->head);
-      bo_free(bo);
-   }
-}
-
 static struct iris_bo *
 bo_calloc(void)
 {
@@ -392,10 +378,8 @@ alloc_bo_from_cache(struct iris_bufmgr *bufmgr,
          break;
       }
 
-      /* This BO was purged, clean up any others and retry */
+      /* This BO was purged, throw it out and keep looking. */
       bo_free(cur);
-
-      iris_bo_cache_purge_bucket(bufmgr, bucket);
    }
 
    if (!bo)




More information about the mesa-commit mailing list