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@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13850>
This commit is contained in:
Mike Blumenkrantz
2021-11-17 16:45:20 -05:00
committed by Marge Bot
parent da9acf7088
commit ea761a40d5
+10 -2
View File
@@ -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;