anv: Align size of bos larger than 1MB to 64k to enable 64k pages

BOs larger than 1MB don't go memory pool due the size but applications
tend to use a lot of VkMemory with size larger than 1MB so to reduce
the number of pages and improve performance here I'm aligning the size
of BOs larger than 1MB to 64kb, this allows 64kb pages to be used at
least on Xe KMD.
This bring substantial perfomance benefit in exchange of a small
memory waste.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33558>
This commit is contained in:
José Roberto de Souza 2025-03-19 12:47:49 -07:00 committed by Marge Bot
parent dde91cf9cb
commit 2c05488be1

View file

@ -489,6 +489,15 @@ anv_device_has_perf_improvement_with_2mb_pages(struct anv_device *device)
return device->info->verx10 >= 110;
}
static bool
anv_device_has_perf_improvement_with_64k_pages(struct anv_device *device)
{
if (device->info->has_local_mem || device->info->verx10 < 110)
return false;
return device->info->kmd_type == INTEL_KMD_TYPE_XE;
}
/** Grows and re-centers the block pool.
*
* We grow the block pool in one or both directions in such a way that the
@ -1672,6 +1681,14 @@ anv_device_alloc_bo(struct anv_device *device,
size = align64(size, 4096);
}
/* bos larger than 1MB can't be allocated with slab but to reduce pages we
* could align size to 64k pages to gain performance with minimum memory
* waste.
*/
if ((size > (1 * 1024 * 1024)) &&
anv_device_has_perf_improvement_with_64k_pages(device))
size = align64(size, 64 * 1024);
const struct intel_memory_class_instance *regions[2];
uint32_t nregions = 0;