util/vma: Add function to get max continuous free size

Useful to find out what's the biggest allocation we could make.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28276>
This commit is contained in:
Danylo Piliaiev 2024-03-19 17:00:22 +01:00 committed by Marge Bot
parent bcf793306f
commit df3ba95a24
2 changed files with 12 additions and 0 deletions

View file

@ -352,6 +352,16 @@ util_vma_heap_free(struct util_vma_heap *heap,
util_vma_heap_validate(heap);
}
uint64_t
util_vma_heap_get_max_free_continuous_size(struct util_vma_heap *heap)
{
if (list_is_empty(&heap->holes))
return 0;
struct util_vma_hole *top_hole = list_first_entry(&heap->holes, struct util_vma_hole, link);
return top_hole->size;
}
void
util_vma_heap_print(struct util_vma_heap *heap, FILE *fp,
const char *tab, uint64_t total_size)

View file

@ -66,6 +66,8 @@ bool util_vma_heap_alloc_addr(struct util_vma_heap *heap,
void util_vma_heap_free(struct util_vma_heap *heap,
uint64_t offset, uint64_t size);
uint64_t util_vma_heap_get_max_free_continuous_size(struct util_vma_heap *heap);
void util_vma_heap_print(struct util_vma_heap *heap, FILE *fp,
const char *tab, uint64_t total_size);