Hi, this is v2 of my attempt at improving sparse binding perf.
The motivator is that many games have come to heavily use sparse bindings, and they often rely on being able to overlap frame work on gfx/compute queues with sparse binding work on sdma. If PRT mappings are synced to every other submissions like they are right now, heavy sparse binding load can stall the gfx/compute submissions for quite a long while, leading to very noticeable stutters and hitches. Another problem is that each sparse binding update requires a separate ioctl, so the CPU will also spend significant time constantly switching between user and kernel mode to execute the binding changes one at a time. To remedy this, this patchset introduces a "VM update context" structure. This context encapsulates some state that is carried around different VM update functions, in patch 1 this is the mappings that were freed along the way. amdgpu_vm_clear_freed then only clears the mappings that were actually freed in the update operation, which is a requirement for being able to explicitly sync that unmap. In later patches, the update context is expanded to hold a set of pending mapping changes, so that a future ioctl that changes many mappings at a time has a place to keep pending changes while every change is validated, before applying everything atomically if things look okay. Best, Natalie Signed-off-by: Natalie Vock <[email protected]> --- Changes in v2: - Added pending change structures to update context in order to batch changes - Link to v1: https://patch.msgid.link/[email protected] --- Natalie Vock (10): drm/amdgpu: Remove unused parameter from amdgpu_vm_pte_fragment drm/amdgpu: Add and use vm_update_ctx struct drm/amdgpu: Make VM maps pending per update context drm/amdgpu: Make removed/cleared mappings pending per update context drm/amdgpu: Track dirty bo_va structures in update ctx drm/amdgpu: Add function to roll back a VM update ctx drm/amdgpu: Move some VA op validation to a helper drm/amdgpu: Only reject conflicting mappings if they are not cleared drm/amdgpu: Add new AMDGPU_GEM_VA2 ioctl drm/amdgpu: Bump minor version drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 33 +- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 31 +- drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c | 21 +- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 6 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 477 ++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_seq64.c | 9 +- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 660 +++++++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 100 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 8 +- include/uapi/drm/amdgpu_drm.h | 46 ++ 15 files changed, 1099 insertions(+), 311 deletions(-) --- base-commit: 65b7b0d2cf8c3cba99d599493ac96f3ab32c0a06 change-id: 20260529-prt-explicit-sync-3d74b9dd420c Best regards, -- Natalie Vock <[email protected]>
