[Mesa-dev] [PATCH] gallium/u_threaded: replace pipe_resource_reference with atomic_inc
Michel Dänzer
michel at daenzer.net
Tue Jun 13 03:18:12 UTC 2017
On 13/06/17 01:31 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> ---
> src/gallium/auxiliary/util/u_threaded_context.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c
> index 3038fc6..a97f016 100644
> --- a/src/gallium/auxiliary/util/u_threaded_context.c
> +++ b/src/gallium/auxiliary/util/u_threaded_context.c
> @@ -195,22 +195,27 @@ _tc_sync(struct threaded_context *tc, const char *info, const char *func)
>
> tc_debug_check(tc);
> }
>
> #define tc_sync(tc) _tc_sync(tc, "", __func__)
> #define tc_sync_msg(tc, info) _tc_sync(tc, info, __func__)
>
> static void
> tc_set_resource_reference(struct pipe_resource **dst, struct pipe_resource *src)
> {
> - *dst = NULL;
> - pipe_resource_reference(dst, src);
> + /* Unexpectedly, pipe_resource_reference is a bottleneck here, taking 3.7%
> + * of CPU time in a state-heavy microbenchmark. The problem here is that
> + * pipe_resource_reference isn't inlined here.
> + */
> + *dst = src;
> + if (src)
> + p_atomic_inc(&src->reference.count);
> }
That's pretty ugly. Does the attached patch help as well? It allows
pipe_resource_reference to be inlined again, and has a pretty dramatic
effect on the size of the generated code for me:
text data bss dec hex filename
42586 512 0 43098 a85a u_threaded_context.o
35282 512 0 35794 8bd2 u_threaded_context.o.patched
text data bss dec hex filename
10434626 271176 2062272 12768074 c2d34a /tmp/radeonsi_dri.so
10001218 271176 2062272 12334666 bc364a /tmp/radeonsi_dri.so.patched
It might also help for other pipe_resource_reference callers.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-gallium-util-Allow-pipe_resource_reference-to-be-inl.patch
Type: text/x-patch
Size: 1755 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170613/c37e8198/attachment.bin>
More information about the mesa-dev
mailing list