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

2017-10-06 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Fri, Oct 6, 2017 at 10:20 PM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> 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(>queue)) {
>util_queue_destroy(>queue);
>
>for (unsigned i = 0; i < TC_MAX_BATCHES; i++)
>   util_queue_fence_destroy(>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(>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@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2017-10-06 Thread Nicolai Hähnle
From: Nicolai Hähnle 

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(>queue)) {
   util_queue_destroy(>queue);
 
   for (unsigned i = 0; i < TC_MAX_BATCHES; i++)
  util_queue_fence_destroy(>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(>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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev