From 8ebb9e2c13259aa636a0a65977e3a9845dd62904 Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Thu, 25 May 2023 13:14:56 +0300 Subject: [PATCH] anv: opportunistically align VMA to 2Mb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lionel Landwerlin Tested-by: José Roberto de Souza Reviewed-by: Kenneth Graunke Part-of: --- src/intel/vulkan/anv_allocator.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/intel/vulkan/anv_allocator.c b/src/intel/vulkan/anv_allocator.c index 7de44ff96ee..66b9bab99a7 100644 --- a/src/intel/vulkan/anv_allocator.c +++ b/src/intel/vulkan/anv_allocator.c @@ -1411,6 +1411,15 @@ anv_bo_vma_alloc_or_close(struct anv_device *device, if (device->info->has_aux_map && (alloc_flags & ANV_BO_ALLOC_IMPLICIT_CCS)) align = MAX2(intel_aux_map_get_alignment(device->aux_map_ctx), align); + /* Opportunistically align addresses to 2Mb when above 1Mb. We do this + * because this gives an opportunity for the kernel to use Transparent Huge + * Pages (the 2MB page table layout) for faster memory access. + * + * Only available on ICL+. + */ + if (device->info->ver >= 11 && (bo->size + bo->_ccs_size) >= 1 * 1024 * 1024) + align = MAX2(2 * 1024 * 1024, align); + if (alloc_flags & ANV_BO_ALLOC_FIXED_ADDRESS) { bo->has_fixed_address = true; bo->offset = explicit_address;