Module: Mesa Branch: main Commit: 0b6693a3a14029c31db2ee8576baa78fc914b9e5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b6693a3a14029c31db2ee8576baa78fc914b9e5
Author: Kenneth Graunke <[email protected]> Date: Wed Sep 27 18:53:58 2023 -0700 iris: Align fresh BO allocations to 2MB in size This should allow us to use 64K pages in more cases, and since the suballocator is typically used for BOs smaller than 2MB, it probably isn't going to waste a horrendous amount of memory. Reviewed-by: José Roberto de Souza <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25447> --- src/gallium/drivers/iris/iris_bufmgr.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c index b2fa6bfab11..cee92c883fa 100644 --- a/src/gallium/drivers/iris/iris_bufmgr.c +++ b/src/gallium/drivers/iris/iris_bufmgr.c @@ -1067,6 +1067,15 @@ alloc_fresh_bo(struct iris_bufmgr *bufmgr, uint64_t bo_size, unsigned flags) if (!bo) return NULL; + /* Try to allocate memory in multiples of 2MB, as this allows us to use + * 64K pages rather than the less-efficient 4K pages. Most BOs smaller + * than 64MB should hit the BO cache or slab allocations anyway, so this + * shouldn't waste too much memory. We do exclude small (< 1MB) sizes to + * be defensive in case any of those bypass the caches and end up here. + */ + if (bo_size >= 1024 * 1024) + bo_size = ALIGN(bo_size, 2 * 1024 * 1024); + bo->real.heap = flags_to_heap(bufmgr, flags); const struct intel_memory_class_instance *regions[2];
