anv: Skip anv_bo_pool if memory pool is enabled

The whole purpose of anv_bo_pool is to reduce the number of
gem_create/destroy calls in command buffers that is something with
a short life span.
But slab_bo/memory pool does the same with even other benefits like
doing 2MB allocations to enable THP.

So here skipping the meat of anv_bo_pool_free() to directly return
the bo to slab_bo. This change is also necessary because the way
anv_bo_pool stores freed buffers it requires that all bos has a unique
gem handle, what not true of buffer allocated by anv_slab.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Suggested-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-04-22 12:09:58 -07:00 committed by Marge Bot
parent 0b561f691b
commit a0a600ca5f

View file

@ -1294,6 +1294,19 @@ anv_bo_pool_free(struct anv_bo_pool *pool, struct anv_bo *bo)
{
VG(VALGRIND_MEMPOOL_FREE(pool, bo->map));
/* When a BO is part of a slab, don't put it on the free list. First
* it doesn't have a GEM handle that we could use in managing the free
* list, second the BO is going to return to the slab and will not
* necessarily get freed immediately which is what the bo_pool is also
* trying to achieve.
*/
if (anv_bo_get_real(bo) != bo) {
VG(VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, 1));
anv_device_release_bo(pool->device, bo);
return;
}
assert(util_is_power_of_two_or_zero(bo->size));
const unsigned size_log2 = util_logbase2_ceil(bo->size);
const unsigned bucket = size_log2 - 12;