Re: [Mesa-dev] [PATCH] swr: Limit memory held by defer deleted resources.

2017-07-01 Thread Ilia Mirkin
FWIW I added the exact same workaround in nouveau. I think I even also used 64:

https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/nouveau/nouveau_fence.c#n270

Reviewed-by: Ilia Mirkin 

On Fri, Jun 30, 2017 at 11:24 PM, Bruce Cherniak
 wrote:
> This patch limits the number of items on the fence work queue (the
> deferred deletion list) by submitting a sync fence when the queue size
> exceeds a threshold.  This initiates deferred deletion of all resources
> on the list and decreases the total amount of memory held waiting for
> "deferred deletion".
>
> This resolves  bug 101467 filed against swr for the piglit
> streaming-texture-leak test.  For those running on smaller memory
> (16GB?) systems, this will prevent oom-killer.
>
> Thus far, we have not seen any real world applications that exhibit
> behavior like the streaming-texture-leak test; as any form of pipeline
> flush will trigger the defer queue and properly free any retained
> allocations.  But, this addresses those as well.
>
> Cc: "17.1" 
> ---
>  src/gallium/drivers/swr/swr_screen.cpp | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/gallium/drivers/swr/swr_screen.cpp 
> b/src/gallium/drivers/swr/swr_screen.cpp
> index a80ec2adba..16a314c28a 100644
> --- a/src/gallium/drivers/swr/swr_screen.cpp
> +++ b/src/gallium/drivers/swr/swr_screen.cpp
> @@ -992,6 +992,12 @@ swr_resource_destroy(struct pipe_screen *p_screen, 
> struct pipe_resource *pt)
>swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
>swr_fence_work_free(screen->flush_fence,
>spr->secondary.pBaseAddress, true);
> +
> +  /* If work queue grows too large, submit a fence to force queue to
> +   * drain.  This is mainly to decrease the amount of memory used by the
> +   * piglit streaming-texture-leak test */
> +  if (screen->pipe && swr_fence(screen->flush_fence)->work.count > 64)
> + swr_fence_submit(swr_context(screen->pipe), screen->flush_fence);
> }
>
> FREE(spr);
> --
> 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] swr: Limit memory held by defer deleted resources.

2017-06-30 Thread Bruce Cherniak
This patch limits the number of items on the fence work queue (the
deferred deletion list) by submitting a sync fence when the queue size
exceeds a threshold.  This initiates deferred deletion of all resources
on the list and decreases the total amount of memory held waiting for
"deferred deletion".

This resolves  bug 101467 filed against swr for the piglit
streaming-texture-leak test.  For those running on smaller memory
(16GB?) systems, this will prevent oom-killer.

Thus far, we have not seen any real world applications that exhibit
behavior like the streaming-texture-leak test; as any form of pipeline
flush will trigger the defer queue and properly free any retained
allocations.  But, this addresses those as well.

Cc: "17.1" 
---
 src/gallium/drivers/swr/swr_screen.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/drivers/swr/swr_screen.cpp 
b/src/gallium/drivers/swr/swr_screen.cpp
index a80ec2adba..16a314c28a 100644
--- a/src/gallium/drivers/swr/swr_screen.cpp
+++ b/src/gallium/drivers/swr/swr_screen.cpp
@@ -992,6 +992,12 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct 
pipe_resource *pt)
   swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
   swr_fence_work_free(screen->flush_fence,
   spr->secondary.pBaseAddress, true);
+
+  /* If work queue grows too large, submit a fence to force queue to
+   * drain.  This is mainly to decrease the amount of memory used by the
+   * piglit streaming-texture-leak test */
+  if (screen->pipe && swr_fence(screen->flush_fence)->work.count > 64)
+ swr_fence_submit(swr_context(screen->pipe), screen->flush_fence);
}
 
FREE(spr);
-- 
2.11.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev