[Mesa-dev] [PATCH] u_threaded_context: fix a memory leak

Marek Olšák maraeo at gmail.com
Fri Oct 6 22:24:07 UTC 2017


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Fri, Oct 6, 2017 at 10:20 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> The uploaders can own transfers which need to be unmapped. Destroy them
> before the final sync (they're not used from the driver thread anyway)
> so that the transfer_unmap call is processed by the driver.
> ---
>  src/gallium/auxiliary/util/u_threaded_context.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
> index 043d4e67df1..7e28b87a7ff 100644
> --- a/src/gallium/auxiliary/util/u_threaded_context.c
> +++ b/src/gallium/auxiliary/util/u_threaded_context.c
> @@ -2226,37 +2226,38 @@ tc_resource_commit(struct pipe_context *_pipe, struct pipe_resource *res,
>  /********************************************************************
>   * create & destroy
>   */
>
>  static void
>  tc_destroy(struct pipe_context *_pipe)
>  {
>     struct threaded_context *tc = threaded_context(_pipe);
>     struct pipe_context *pipe = tc->pipe;
>
> +   if (tc->base.const_uploader &&
> +       tc->base.stream_uploader != tc->base.const_uploader)
> +      u_upload_destroy(tc->base.const_uploader);
> +
> +   if (tc->base.stream_uploader)
> +      u_upload_destroy(tc->base.stream_uploader);
> +
>     tc_sync(tc);
>
>     if (util_queue_is_initialized(&tc->queue)) {
>        util_queue_destroy(&tc->queue);
>
>        for (unsigned i = 0; i < TC_MAX_BATCHES; i++)
>           util_queue_fence_destroy(&tc->batch_slots[i].fence);
>     }
>
> -   if (tc->base.const_uploader &&
> -       tc->base.stream_uploader != tc->base.const_uploader)
> -      u_upload_destroy(tc->base.const_uploader);
> -
> -   if (tc->base.stream_uploader)
> -      u_upload_destroy(tc->base.stream_uploader);
> -
>     slab_destroy_child(&tc->pool_transfers);
> +   assert(tc->batch_slots[tc->next].num_total_call_slots == 0);
>     pipe->destroy(pipe);
>     os_free_aligned(tc);
>  }
>
>  static const tc_execute execute_func[TC_NUM_CALLS] = {
>  #define CALL(name) tc_call_##name,
>  #include "u_threaded_context_calls.h"
>  #undef CALL
>  };
>
> --
> 2.11.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list