[Mesa-dev] [PATCH 2/9] util: Make vma.c support non-power-of-two alignments.

Jordan Justen jordan.l.justen at intel.com
Wed May 23 07:30:17 UTC 2018


I replied to Ken's posting with an r-b. (I also mentioned that it
seems like this could potentially be folded into the previous patch.)

On 2018-05-22 14:52:29, Scott D Phillips wrote:
> From: Kenneth Graunke <kenneth at whitecape.org>
> 
> I want to use this in a bucketing allocator for i965.
> ---
> I've added this patch to the series because the
> util_is_power_of_two_nonzero that is removed will cause the unit test to
> fail for alignments of 4 GiB or larger.
> 
>  src/util/vma.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/util/vma.c b/src/util/vma.c
> index bedad6efa32..c8f55031c7e 100644
> --- a/src/util/vma.c
> +++ b/src/util/vma.c
> @@ -90,8 +90,7 @@ util_vma_heap_alloc(struct util_vma_heap *heap,
>  {
>     /* The caller is expected to reject zero-size allocations */
>     assert(size > 0);
> -
> -   assert(util_is_power_of_two_nonzero(alignment));
> +   assert(alignment > 0);
>  
>     util_vma_heap_validate(heap);
>  
> @@ -110,7 +109,7 @@ util_vma_heap_alloc(struct util_vma_heap *heap,
>        /* Align the offset.  We align down and not up because we are allocating
>         * from the top of the hole and not the bottom.
>         */
> -      offset &= ~(alignment - 1);
> +      offset = (offset / alignment) * alignment;
>  
>        if (offset < hole->offset)
>           continue;
> -- 
> 2.14.3
> 


More information about the mesa-dev mailing list