drm/amdkfd: account for non-KFD DRM VRAM residency - #224
Open
liminfei-amd wants to merge 1 commit into
Open
Conversation
AMDKFD_IOC_AVAILABLE_MEMORY only subtracts KFD allocations and pinned VRAM. Unpinned VRAM buffer objects allocated through DRM therefore remain invisible to HSA_AMD_AGENT_INFO_MEMORY_AVAIL and can make compute applications overcommit VRAM. Track non-KFD user BO residency in the VRAM resource manager and subtract it from KFD availability. Mark KFD allocations already represented by vram_used_aligned to avoid double counting, and keep an orthogonal counter for pinned VRAM not represented by either source. Preserve the existing paths on APUs and partitioned devices until their memory-domain attribution is validated. Closes: ROCm#223 Signed-off-by: liminfei-amd <91481003+liminfei-amd@users.noreply.github.com>
liminfei-amd
marked this pull request as ready for review
August 5, 2026 13:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #223.
Summary
KFD available-memory accounting does not include unpinned VRAM resident through
other DRM clients, so
hipMemGetInfocan over-report free VRAM on Linux dGPUs.Track non-KFD user BO residency with the VRAM resource lifetime and subtract it
from the KFD query and allocation limit. Mark BOs already represented by KFD
accounting to avoid double counting, and leave APU and memory-partition paths
unchanged.
Validation
0 B.
runs; KFD allocation/free behavior remained unchanged.
masterbuilt a SVM-enabledamdgpu.o; strictcheckpatch.plreported 0 errors, 0 warnings, and 0 checks.
APU and XCP/memory-partition runtime coverage is not included yet.
This is an experimental, AI-generated code change, reviewed by AMD engineers before submission.