Skip to content
Snippets Groups Projects
Commit a332907b authored by Tapani Pälli's avatar Tapani Pälli Committed by Eric Engestrom
Browse files

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: ce2e2296 ("iris: Suballocate BO using the Gallium pb_slab mechanism")
Signed-off-by: default avatarTapani Pälli <tapani.palli@intel.com>
Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
Part-of: <mesa/mesa!14387>
(cherry picked from commit b8f0459d)
parent 0db1699e
No related branches found
No related tags found
Loading
......@@ -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"
},
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment