<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Apr 27, 2017 at 9:20 AM, Juan A. Suarez Romero <span dir="ltr"><<a href="mailto:jasuarez@igalia.com" target="_blank">jasuarez@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, 2017-04-26 at 07:35 -0700, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/vulkan/anv_<wbr>allocator.c | 24 +++++++++++++++++++-----<br>
> 1 file changed, 19 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/src/intel/vulkan/anv_<wbr>allocator.c b/src/intel/vulkan/anv_<wbr>allocator.c<br>
> index 784191e..594cf49 100644<br>
> --- a/src/intel/vulkan/anv_<wbr>allocator.c<br>
> +++ b/src/intel/vulkan/anv_<wbr>allocator.c<br>
> @@ -684,8 +684,9 @@ anv_state_pool_finish(struct anv_state_pool *pool)<br>
> VG(VALGRIND_DESTROY_MEMPOOL(<wbr>pool));<br>
> }<br>
><br>
> -struct anv_state<br>
> -anv_state_pool_alloc(struct anv_state_pool *pool, size_t size, size_t align)<br>
> +static struct anv_state<br>
> +anv_state_pool_alloc_no_vg(<wbr>struct anv_state_pool *pool,<br>
> + size_t size, size_t align)<br>
> {<br>
> unsigned size_log2 = ilog2_round_up(size < align ? align : size);<br>
> assert(size_log2 <= ANV_MAX_STATE_SIZE_LOG2);<br>
> @@ -698,12 +699,19 @@ anv_state_pool_alloc(struct anv_state_pool *pool, size_t size, size_t align)<br>
> state.offset = anv_fixed_size_state_pool_<wbr>alloc(&pool->buckets[bucket],<br>
> pool->block_pool);<br>
> state.map = pool->block_pool->map + state.offset;<br>
> + return state;<br>
> +}<br>
> +<br>
> +struct anv_state<br>
> +anv_state_pool_alloc(struct anv_state_pool *pool, size_t size, size_t align)<br>
> +{<br>
> + struct anv_state state = anv_state_pool_alloc_no_vg(<wbr>pool, size, align);<br>
> VG(VALGRIND_MEMPOOL_ALLOC(<wbr>pool, state.map, size));<br>
> return state;<br>
> }<br>
><br>
<br>
<br>
</div></div>Is it really worth to have a different function? I would understand if<br>
the valgrind and no-valgrind where totally different.<span class=""><br></span></blockquote><div><br></div><div>The valgrind step has to be done at the last possible moment before we hand the pointer back to the "user". With the state stream pulling from the state pool, this means that, for anything allocated by the stream, it needs to be done by the stream and not the pool. These helpers let us skip the valgrind alloc/free markers when we're pulling through the stream until state_stream_alloc/free.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
><br>
> -void<br>
> -anv_state_pool_free(struct anv_state_pool *pool, struct anv_state state)<br>
> +static void<br>
> +anv_state_pool_free_no_vg(<wbr>struct anv_state_pool *pool, struct anv_state state)<br>
> {<br>
> assert(util_is_power_of_two(<wbr>state.alloc_size));<br>
> unsigned size_log2 = ilog2_round_up(state.alloc_<wbr>size);<br>
> @@ -711,11 +719,17 @@ anv_state_pool_free(struct anv_state_pool *pool, struct anv_state state)<br>
> size_log2 <= ANV_MAX_STATE_SIZE_LOG2);<br>
> unsigned bucket = size_log2 - ANV_MIN_STATE_SIZE_LOG2;<br>
><br>
> - VG(VALGRIND_MEMPOOL_FREE(pool, state.map));<br>
> anv_fixed_size_state_pool_<wbr>free(&pool->buckets[bucket],<br>
> pool->block_pool, state.offset);<br>
> }<br>
><br>
> +void<br>
> +anv_state_pool_free(struct anv_state_pool *pool, struct anv_state state)<br>
> +{<br>
> + VG(VALGRIND_MEMPOOL_FREE(pool, state.map));<br>
> + anv_state_pool_free_no_vg(<wbr>pool, state);<br>
> +}<br>
> +<br>
> #define NULL_BLOCK 1<br>
> struct anv_state_stream_block {<br>
> /* The next block */<br>
</span>______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>