asahi: Do not overallocate BOs by more than 2x
authorAsahi Lina <lina@asahilina.net>
Sat, 22 Jul 2023 09:33:09 +0000 (18:33 +0900)
committerMarge Bot <emma+marge@anholt.net>
Fri, 11 Aug 2023 20:31:27 +0000 (20:31 +0000)
This is not likely to be useful, and might take over a correctly-sized
BO that is going to be reused later.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>

src/asahi/lib/agx_bo.c

index d3f1059..2d455cd 100644 (file)
@@ -63,6 +63,10 @@ agx_bo_cache_fetch(struct agx_device *dev, size_t size, uint32_t flags,
       if (entry->size < size || entry->flags != flags)
          continue;
 
+      /* Do not return more than 2x oversized BOs. */
+      if (entry->size > 2 * size)
+         continue;
+
       /* If the oldest BO in the cache is busy, likely so is
        * everything newer, so bail. */
       if (!agx_bo_wait(entry, dontwait ? 0 : INT64_MAX))