summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2022-01-04 11:26:55 +0200
committerEric Engestrom <eric@engestrom.ch>2022-01-12 19:54:26 +0000
commita332907bbc57f6ae48f3f27c035dd5169efacc72 (patch)
treeb1d9fb95c16fb8c574cb990560dbb922f250675b
parent0db1699eabd6b64785a3e241a80c51b36feb3287 (diff)
iris: unref syncobjs and free r/w dependencies array for slab entries
Fixes memory leak with dependencies array: ==5224== 104 (96 direct, 8 indirect) bytes in 3 blocks are definitely lost in loss record 1,954 of 2,035 ==5224== at 0x484178A: malloc (vg_replace_malloc.c:380) ==5224== by 0x484670B: realloc (vg_replace_malloc.c:1437) ==5224== by 0x14DBAB9B: update_bo_syncobjs (iris_batch.c:819) ==5224== by 0x14DBADB8: update_batch_syncobjs (iris_batch.c:898) ==5224== by 0x14DBB3D5: _iris_batch_flush (iris_batch.c:1031) ==5224== by 0x14DB77D0: iris_transfer_map (iris_resource.c:2348) ==5224== by 0x157786FD: u_transfer_helper_transfer_map (u_transfer_helper.c:243) ==5224== by 0x14C479E7: tc_buffer_map (u_threaded_context.c:2252) ==5224== by 0x1434F3F8: pipe_buffer_map_range (u_inlines.h:393) ==5224== by 0x1435094A: _mesa_bufferobj_map_range (bufferobj.c:491) ==5224== by 0x143586D9: map_buffer_range (bufferobj.c:3737) ==5224== by 0x14358DA3: _mesa_MapBuffer (bufferobj.c:3947) ==5224== 240 (192 direct, 48 indirect) bytes in 6 blocks are definitely lost in loss record 1,984 of 2,035 ==5224== at 0x484178A: malloc (vg_replace_malloc.c:380) ==5224== by 0x484670B: realloc (vg_replace_malloc.c:1437) ==5224== by 0x14DBAB9B: update_bo_syncobjs (iris_batch.c:819) ==5224== by 0x14DBADB8: update_batch_syncobjs (iris_batch.c:898) ==5224== by 0x14DBB3D5: _iris_batch_flush (iris_batch.c:1031) ==5224== by 0x14FF72CC: iris_get_query_result (iris_query.c:631) ==5224== by 0x14C4396A: tc_get_query_result (u_threaded_context.c:880) ==5224== by 0x1458F4F7: get_query_result (st_cb_queryobj.c:273) ==5224== by 0x1458F7EB: st_WaitQuery (st_cb_queryobj.c:352) ==5224== by 0x144EFF66: get_query_object (queryobj.c:742) ==5224== by 0x144F01AE: _mesa_GetQueryObjectuiv (queryobj.c:811) And leak with syncobjs: ==13644== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1,846 ==13644== at 0x484186F: malloc (vg_replace_malloc.c:381) ==13644== by 0x639789B: iris_create_syncobj (iris_fence.c:69) ==13644== by 0x63B213A: iris_batch_reset (iris_batch.c:512) ==13644== by 0x63B3637: _iris_batch_flush (iris_batch.c:1056) ==13644== by 0x65EF2BC: iris_get_query_result (iris_query.c:631) ==13644== by 0x623B970: tc_get_query_result (u_threaded_context.c:880) ==13644== by 0x5B874F7: get_query_result (st_cb_queryobj.c:273) ==13644== by 0x5B877EB: st_WaitQuery (st_cb_queryobj.c:352) ==13644== by 0x5AE7F66: get_query_object (queryobj.c:742) ==13644== by 0x5AE8150: _mesa_GetQueryObjectiv (queryobj.c:801) Fixes: ce2e2296ab6 ("iris: Suballocate BO using the Gallium pb_slab mechanism") Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14387> (cherry picked from commit b8f0459d6f459f45688289ff3e96a2f5a7d68c65)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/drivers/iris/iris_bufmgr.c29
2 files changed, 19 insertions, 12 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 412f4197c28..ab2009b83be 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1066,7 +1066,7 @@
"description": "iris: unref syncobjs and free r/w dependencies array for slab entries",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": "ce2e2296ab61558f02ea2d05ae0cf4a922df84a7"
},
diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 6dbf1629c38..3e77dfc1039 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -594,19 +594,26 @@ iris_slab_free(void *priv, struct pb_slab *pslab)
assert(!slab->bo->aux_map_address);
- if (aux_map_ctx) {
- /* Since we're freeing the whole slab, all buffers allocated out of it
- * must be reclaimable. We require buffers to be idle to be reclaimed
- * (see iris_can_reclaim_slab()), so we know all entries must be idle.
- * Therefore, we can safely unmap their aux table entries.
- */
- for (unsigned i = 0; i < pslab->num_entries; i++) {
- struct iris_bo *bo = &slab->entries[i];
- if (bo->aux_map_address) {
- intel_aux_map_unmap_range(aux_map_ctx, bo->address, bo->size);
- bo->aux_map_address = 0;
+ /* Since we're freeing the whole slab, all buffers allocated out of it
+ * must be reclaimable. We require buffers to be idle to be reclaimed
+ * (see iris_can_reclaim_slab()), so we know all entries must be idle.
+ * Therefore, we can safely unmap their aux table entries.
+ */
+ for (unsigned i = 0; i < pslab->num_entries; i++) {
+ struct iris_bo *bo = &slab->entries[i];
+ if (aux_map_ctx && bo->aux_map_address) {
+ intel_aux_map_unmap_range(aux_map_ctx, bo->address, bo->size);
+ bo->aux_map_address = 0;
+ }
+
+ /* Unref read/write dependency syncobjs and free the array. */
+ for (int d = 0; d < bo->deps_size; d++) {
+ for (int b = 0; b < IRIS_BATCH_COUNT; b++) {
+ iris_syncobj_reference(bufmgr, &bo->deps[d].write_syncobjs[b], NULL);
+ iris_syncobj_reference(bufmgr, &bo->deps[d].read_syncobjs[b], NULL);
}
}
+ free(bo->deps);
}
iris_bo_unreference(slab->bo);