Mesa (main): zink: use pb_slab_alloc_reclaimed(reclaim_all) for BAR heap sometimes
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Nov 18 21:57:02 UTC 2021
Module: Mesa
Branch: main
Commit: ea761a40d596edca419132f6625126616b475c65
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea761a40d596edca419132f6625126616b475c65
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Wed Nov 17 16:45:20 2021 -0500
zink: use pb_slab_alloc_reclaimed(reclaim_all) for BAR heap sometimes
this forces a full slab reclaim any time the device is known to have a
too-small BAR in order to keep memory usage at a minimum when it might otherwise
balloon out and crash us
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13850>
---
src/gallium/drivers/zink/zink_bo.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
index 083d6d9fa50..6623e99c82e 100644
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -579,12 +579,20 @@ zink_bo_create(struct zink_screen *screen, uint64_t size, unsigned alignment, en
}
struct pb_slabs *slabs = get_slabs(screen, alloc_size, flags);
- entry = pb_slab_alloc(slabs, alloc_size, heap);
+ bool reclaim_all = false;
+ if (heap == ZINK_HEAP_DEVICE_LOCAL_VISIBLE && !screen->resizable_bar) {
+ unsigned low_bound = 128 * 1024 * 1024; //128MB is a very small BAR
+ if (screen->info.driver_props.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY)
+ low_bound *= 2; //nvidia has fat textures or something
+ unsigned heapidx = screen->info.mem_props.memoryTypes[screen->heap_map[heap]].heapIndex;
+ reclaim_all = screen->info.mem_props.memoryHeaps[heapidx].size <= low_bound;
+ }
+ entry = pb_slab_alloc_reclaimed(slabs, alloc_size, heap, reclaim_all);
if (!entry) {
/* Clean up buffer managers and try again. */
clean_up_buffer_managers(screen);
- entry = pb_slab_alloc(slabs, alloc_size, heap);
+ entry = pb_slab_alloc_reclaimed(slabs, alloc_size, heap, true);
}
if (!entry)
return NULL;
More information about the mesa-commit
mailing list