Re: [Mesa-dev] [PATCH v2] util/ralloc: Remove double zero'ing of rzalloc buffers

2016-05-10 Thread Kenneth Graunke
On Tuesday, May 10, 2016 3:54:05 PM PDT Jordan Justen wrote:
> Juha-Pekka found this back in May 2015:
> <1430915727-28677-1-git-send-email-juhapekka.heikk...@gmail.com>
> 
> From the discussion, obviously it would be preferable to make
> ralloc_size no longer return zeroed memory, but Juha-Pekka found that
> it would break Mesa.
> 
> In <56af1c57.2030...@gmail.com>, Juha-Pekka mentioned that patches
> exist to fix i965 when ralloc_size is fixed to not zero memory, but
> the patches have not made their way to mesa-dev yet.
> 
> For now, let's stop doing the double zeroing of rzalloc buffers.
> 
> v2:
>  * Move ralloc_size code to rzalloc_size, and add a comment as
>suggested by Ken.
> 
> Signed-off-by: Jordan Justen 
> Cc: Juha-Pekka Heikkila 
> Cc: Kenneth Graunke 
> ---
>  src/util/ralloc.c | 21 -
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/src/util/ralloc.c b/src/util/ralloc.c
> index 6d4032b..9526011 100644
> --- a/src/util/ralloc.c
> +++ b/src/util/ralloc.c
> @@ -110,6 +110,18 @@ ralloc_context(const void *ctx)
>  void *
>  ralloc_size(const void *ctx, size_t size)
>  {
> +   /* ralloc_size was originally implemented using calloc, which meant some
> +* code accidentally relied on its zero filling behavior.
> +*
> +* TODO: Make ralloc_size not zero fill memory, and cleanup any code 
that
> +* should instead be using rzalloc.
> +*/
> +   return rzalloc_size(ctx, size);
> +}
> +
> +void *
> +rzalloc_size(const void *ctx, size_t size)
> +{
> void *block = calloc(1, size + sizeof(ralloc_header));
> ralloc_header *info;
> ralloc_header *parent;
> @@ -128,15 +140,6 @@ ralloc_size(const void *ctx, size_t size)
> return PTR_FROM_HEADER(info);
>  }
>  
> -void *
> -rzalloc_size(const void *ctx, size_t size)
> -{
> -   void *ptr = ralloc_size(ctx, size);
> -   if (likely(ptr != NULL))
> -  memset(ptr, 0, size);
> -   return ptr;
> -}
> -
>  /* helper function - assumes ptr != NULL */
>  static void *
>  resize(void *ptr, size_t size)

Reviewed-by: Kenneth Graunke 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] util/ralloc: Remove double zero'ing of rzalloc buffers

2016-05-10 Thread Jordan Justen
Juha-Pekka found this back in May 2015:
<1430915727-28677-1-git-send-email-juhapekka.heikk...@gmail.com>

From the discussion, obviously it would be preferable to make
ralloc_size no longer return zeroed memory, but Juha-Pekka found that
it would break Mesa.

In <56af1c57.2030...@gmail.com>, Juha-Pekka mentioned that patches
exist to fix i965 when ralloc_size is fixed to not zero memory, but
the patches have not made their way to mesa-dev yet.

For now, let's stop doing the double zeroing of rzalloc buffers.

v2:
 * Move ralloc_size code to rzalloc_size, and add a comment as
   suggested by Ken.

Signed-off-by: Jordan Justen 
Cc: Juha-Pekka Heikkila 
Cc: Kenneth Graunke 
---
 src/util/ralloc.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/util/ralloc.c b/src/util/ralloc.c
index 6d4032b..9526011 100644
--- a/src/util/ralloc.c
+++ b/src/util/ralloc.c
@@ -110,6 +110,18 @@ ralloc_context(const void *ctx)
 void *
 ralloc_size(const void *ctx, size_t size)
 {
+   /* ralloc_size was originally implemented using calloc, which meant some
+* code accidentally relied on its zero filling behavior.
+*
+* TODO: Make ralloc_size not zero fill memory, and cleanup any code that
+* should instead be using rzalloc.
+*/
+   return rzalloc_size(ctx, size);
+}
+
+void *
+rzalloc_size(const void *ctx, size_t size)
+{
void *block = calloc(1, size + sizeof(ralloc_header));
ralloc_header *info;
ralloc_header *parent;
@@ -128,15 +140,6 @@ ralloc_size(const void *ctx, size_t size)
return PTR_FROM_HEADER(info);
 }
 
-void *
-rzalloc_size(const void *ctx, size_t size)
-{
-   void *ptr = ralloc_size(ctx, size);
-   if (likely(ptr != NULL))
-  memset(ptr, 0, size);
-   return ptr;
-}
-
 /* helper function - assumes ptr != NULL */
 static void *
 resize(void *ptr, size_t size)
-- 
2.8.1

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