A range-restricted allocation walks every split block in the range, so its cost grows linearly with the number of live allocations there. amdgpu restricts every VRAM allocation to its memory partition under NPS2/NPS4, so on MI300X in CPX/NPS4 KFD allocation latency grows with every live BO, under a VRAM manager lock shared by the compute partitions.
Patch 1 replaces the walk with an O(log n) lookup in the offset-sorted free trees, based on Arun's class-aware version of v1; placement is unchanged. Patch 2 adds a KUnit test for the NPS4 pattern (range-biased, cleared, top-down, 64 KiB) that also checks placement: 1103 ms before, 2 ms after. v2: https://patchwork.freedesktop.org/series/178108/ v1: https://patchwork.freedesktop.org/series/176957/ William Palacek (2): gpu/buddy: find range-biased blocks in the free trees gpu/tests/buddy: add range-biased allocation performance test drivers/gpu/buddy.c | 214 +++++++++++++++++++---------- drivers/gpu/tests/gpu_buddy_test.c | 27 ++++ include/linux/gpu_buddy.h | 1 + 3 files changed, 172 insertions(+), 70 deletions(-) -- 2.43.0
