From 9762c55589999bd436d9d7a7a3e861867099d728 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Sat, 22 Jul 2023 18:33:09 +0900 Subject: [PATCH] asahi: Do not overallocate BOs by more than 2x 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 Part-of: --- src/asahi/lib/agx_bo.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/asahi/lib/agx_bo.c b/src/asahi/lib/agx_bo.c index d3f1059..2d455cd 100644 --- a/src/asahi/lib/agx_bo.c +++ b/src/asahi/lib/agx_bo.c @@ -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)) -- 2.7.4