Mesa (main): anv/utrace: use a bo pool for utrace buffers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 7 19:08:51 UTC 2022
Module: Mesa
Branch: main
Commit: c67c9688c3ff61cc79787801b68ddd62cfbf66d7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c67c9688c3ff61cc79787801b68ddd62cfbf66d7
Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date: Thu May 19 20:53:30 2022 +0300
anv/utrace: use a bo pool for utrace buffers
When utrace/perfetto is active, we allocate/free utrace buffers at the
same rate as command buffers. It's useful to have a pool that avoids
GEM_CREATE/GEM_CLOSE ioctls.
v2: Use the pool more
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Acked-by: Caio Oliveira <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16613>
---
src/intel/vulkan/anv_private.h | 1 +
src/intel/vulkan/anv_utrace.c | 30 +++++++++++++++---------------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 7623c78a22e..b3c81f23a2c 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -1170,6 +1170,7 @@ struct anv_device {
struct list_head memory_objects;
struct anv_bo_pool batch_bo_pool;
+ struct anv_bo_pool utrace_bo_pool;
struct anv_bo_cache bo_cache;
diff --git a/src/intel/vulkan/anv_utrace.c b/src/intel/vulkan/anv_utrace.c
index 4e659529335..729d7a57ae8 100644
--- a/src/intel/vulkan/anv_utrace.c
+++ b/src/intel/vulkan/anv_utrace.c
@@ -119,19 +119,16 @@ anv_device_utrace_flush_cmd_buffers(struct anv_queue *queue,
goto error_sync;
if (utrace_copies > 0) {
- result =
- anv_device_alloc_bo(device, "utrace-copy-buf", utrace_copies * 4096,
- ANV_BO_ALLOC_MAPPED, 0 /* explicit_address */,
- &flush->trace_bo);
+ result = anv_bo_pool_alloc(&device->utrace_bo_pool,
+ utrace_copies * 4096,
+ &flush->trace_bo);
if (result != VK_SUCCESS)
goto error_trace_buf;
- result =
- anv_device_alloc_bo(device, "utrace-copy-batch",
- /* 128 dwords of setup + 64 dwords per copy */
- align_u32(512 + 64 * utrace_copies, 4096),
- ANV_BO_ALLOC_MAPPED, 0 /* explicit_address */,
- &flush->batch_bo);
+ result = anv_bo_pool_alloc(&device->utrace_bo_pool,
+ /* 128 dwords of setup + 64 dwords per copy */
+ align_u32(512 + 64 * utrace_copies, 4096),
+ &flush->batch_bo);
if (result != VK_SUCCESS)
goto error_batch_buf;
@@ -184,9 +181,9 @@ anv_device_utrace_flush_cmd_buffers(struct anv_queue *queue,
error_batch:
anv_reloc_list_finish(&flush->relocs, &device->vk.alloc);
error_reloc_list:
- anv_device_release_bo(device, flush->batch_bo);
+ anv_bo_pool_free(&device->utrace_bo_pool, flush->batch_bo);
error_batch_buf:
- anv_device_release_bo(device, flush->trace_bo);
+ anv_bo_pool_free(&device->utrace_bo_pool, flush->trace_bo);
error_trace_buf:
vk_sync_destroy(&device->vk, flush->sync);
error_sync:
@@ -202,8 +199,9 @@ anv_utrace_create_ts_buffer(struct u_trace_context *utctx, uint32_t size_b)
struct anv_bo *bo = NULL;
UNUSED VkResult result =
- anv_device_alloc_bo(device, "utrace-ts", align_u32(size_b, 4096),
- ANV_BO_ALLOC_MAPPED, 0, &bo);
+ anv_bo_pool_alloc(&device->utrace_bo_pool,
+ align_u32(size_b, 4096),
+ &bo);
assert(result == VK_SUCCESS);
return bo;
@@ -216,7 +214,7 @@ anv_utrace_destroy_ts_buffer(struct u_trace_context *utctx, void *timestamps)
container_of(utctx, struct anv_device, ds.trace_context);
struct anv_bo *bo = timestamps;
- anv_device_release_bo(device, bo);
+ anv_bo_pool_free(&device->utrace_bo_pool, bo);
}
static void
@@ -285,6 +283,7 @@ queue_family_to_name(const struct anv_queue_family *family)
void
anv_device_utrace_init(struct anv_device *device)
{
+ anv_bo_pool_init(&device->utrace_bo_pool, device, "utrace");
intel_ds_device_init(&device->ds, &device->info, device->fd,
device->physical->local_minor - 128,
INTEL_DS_API_VULKAN);
@@ -311,6 +310,7 @@ anv_device_utrace_finish(struct anv_device *device)
{
u_trace_context_process(&device->ds.trace_context, true);
intel_ds_device_fini(&device->ds);
+ anv_bo_pool_finish(&device->utrace_bo_pool);
}
enum intel_ds_stall_flag
More information about the mesa-commit
mailing list