Skip to content

freedreno/drm: Add sub-alloc heaps

Rob Clark requested to merge robclark/mesa:fd/drm-suballoc into main

Mapping lots of small buffers to the guest for PIPE_BUFFER and cmdstream is expensive. So add a sub-alloc heap mechanism to mitigate this. Buffers will be allocated and added to the heap in larger (currently 2MB) chunks, and then suballocated from. For suballocated buffers, userspace fences are used to avoid over-synchronization.

This extends util_vma slightly to teach it to avoid allocations spanning a block boundary[1].

The first part of the series is general freedreno/drm cleanups, etc. The middle part is resolving the big-table_lock issue, which turned out to be unavoidable (but IME the results are nice). The latter part is prep and then finally adding fd_bo_heap.

[1] I was tempted to rely on userspace IOVA and mmap's MAP_FIXED to make the heap blocks virtually contiguous on both the CPU and GPU. If I didn't have to care about 32b apps I would have done this, since pre-reserving a big chunk of CPU VA is no biggie if you have 64b of address space. But that isn't so great if you only have 32b of address space, and I don't see a good alternative that doesn't involve leaking VA space when up-sizing. Also teaching util_vma to not span block sizes should be useful for dealing with devices/fw that can't cope with allocations spanning 32b boundaries, so that was the approach I landed on.

Merge request reports