Repository navigation
fix(rocr): fix incorrect ALLOC_MAX_SIZE reporting for HSA_HEAPTYPE_DEVICE_SVM pools - #11355
Conversation
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
…SVM pools MemoryRegion::GetInfo() and AllocateImpl() used max_sysmem_alloc_size_ for HSA_HEAPTYPE_DEVICE_SVM regions, so device-SVM/AIE pools advertised the system-memory allocation cap instead of their own per-pool limit. This let allocators request sizes the pool cannot actually satisfy, which fails during concurrent alloc/free on AIE pools (e.g. aie2p Pool 8) with HSA_STATUS_ERROR_OUT_OF_RESOURCES. Report max_single_alloc_size_ for HSA_HEAPTYPE_DEVICE_SVM instead, matching the same value already used in AllocateImpl()'s own local-memory size check. Verified on gfx1151 (Strix Halo APU) with rocrtst: - rocrtstStress.Memory_Concurrent_Allocate_Test: FAIL -> PASS - rocrtstStress.Memory_Concurrent_Free_Test: FAIL -> PASS
169aa7f to
e4f386c
Compare
shwetagkhatri
left a comment
There was a problem hiding this comment.
These are non blocking comments - but while you are owning this change - i would like to fix the following corresponding files as well -
2 comments in other files below are - now saying the opposite of what the code is doing and whoever reads them next - is going to think this bug is still open.
amd_aie_agent.cpp -
is currently saying:
// The system will report the max allocatable size as MemoryRegion::max_sysmem_alloc_size_, but
// this is incorrect. The pool is exactly XdnaDriver::GetDevHeapByteSize() bytes.
this can be fixed now:
// The pool reports its max allocatable size as MemoryRegion::max_single_alloc_size_, which is exactly
// XdnaDriver::GetDevHeapByteSize() bytes.
amd_xdna_driver.cpp -
is currently saying:
// While this is already checked in MemoryRegion::AllocateImpl, the max size is
// MemoryRegion::max_sysmem_alloc_size_ for HSA_HEAPTYPE_DEVICE_SVM which is incorrect
// for dev heap.
can be fixed now:
// MemoryRegion::AllocateImpl already caps this at MemoryRegion::max_single_alloc_size_, which
// is dev_heap_size for HSA_HEAPTYPE_DEVICE_SVM. Kept as a defensive duplicate returning the
// same status, so an oversized CREATE_BO cannot reach the driver if that cap ever regresses.
| case HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE: | ||
| case HSA_HEAPTYPE_FRAME_BUFFER_PUBLIC: | ||
| case HSA_HEAPTYPE_GPU_SCRATCH: | ||
| *((size_t*)value) = max_single_alloc_size_; | ||
| break; |
There was a problem hiding this comment.
Actually looking into the full source code - the new lines 238-240 have the code body same as 241-245. Please fold the label into the existing group here as below:
case HSA_HEAPTYPE_DEVICE_SVM:
case HSA_HEAPTYPE_FRAME_BUFFER_PRIVATE:
case HSA_HEAPTYPE_FRAME_BUFFER_PUBLIC:
case HSA_HEAPTYPE_GPU_SCRATCH:
*((size_t*)value) = max_single_alloc_size_;
break;
cfreeamd
left a comment
There was a problem hiding this comment.
🤖 AI-assisted pre-review (for @cfreeamd)
Verdict: approve-with-nits — the fix is correct. One Required item on the PR title before merge.
What this PR does
Fixes two related bugs where HSA_HEAPTYPE_DEVICE_SVM pools were using the system-memory allocation cap (max_sysmem_alloc_size_) instead of the device allocation cap (max_single_alloc_size_):
GetInfo(HSA_REGION_INFO_ALLOC_MAX_SIZE)—HSA_HEAPTYPE_DEVICE_SVMwas grouped withHSA_HEAPTYPE_SYSTEMand returnedmax_sysmem_alloc_size_. Now split out and returnsmax_single_alloc_size_.AllocateImpl()— TheIsSystem()allocation-size guard was usingmax_sysmem_alloc_size_even whenIsDeviceSVM()is true. Fixed to usemax_single_alloc_size_whenIsDeviceSVM().
Both sites are now consistent: HSA_HEAPTYPE_DEVICE_SVM is VRAM-backed (device memory), so reporting and enforcing max_single_alloc_size_ is correct.
[Required] PR title missing type(component): format
Current title: rocr: fix incorrect ALLOC_MAX_SIZE reporting for HSA_HEAPTYPE_DEVICE_SVM pools
Suggested: fix(rocr): fix incorrect ALLOC_MAX_SIZE reporting for HSA_HEAPTYPE_DEVICE_SVM pools
ROCm squash-merges, so the PR title becomes the permanent commit title. The type(component): prefix is required by the commit convention.
What looks correct
- Both
GetInfo()andAllocateImpl()are updated consistently — they now agree on which cap applies toHSA_HEAPTYPE_DEVICE_SVM. - The
IsDeviceSVM()check inAllocateImpl()is correctly placed before themax_sysmem_alloc_size_guard, so the ternary selects the right cap. - No performance impact — both changed paths are in the cold allocation path.
|
Please address Shweta's comment and change the PR title to the github friendly format; e.g., fix(rocr): fix incorrect ALLOC_MAX_SIZE reporting for HSA_HEAPTYPE_DEVICE_SVM pools Otherwise, LGTM. |
ypapadop-amd
left a comment
There was a problem hiding this comment.
LGTM, only one comment.
For some context, I was hesitant to change what SVM was reporting for size (thus the comments in XdnaDriver) because I did not have any insight on if someone was expecting the system memory as a result.
|
Merging, only failed test is the system-pr bot which failed for existing issue: rocm-systems #11156 (open, created 2026-09-02): "therock-pr-bot fails on every develop PR: |
TheRock Submodule Bump ActivityNewest first
|
Motivation
Device-SVM/AIE memory pools advertised the wrong maximum allocation
size, causing concurrent allocate/free stress to fail on AIE pools
(e.g.
aie2pPool 8) on gfx1151 (Strix Halo APU).Technical Details
MemoryRegion::GetInfo()returnedmax_sysmem_alloc_size_forHSA_HEAPTYPE_DEVICE_SVMregions instead of the pool's ownmax_single_alloc_size_.MemoryRegion::AllocateImpl()had the sameissue in its
IsSystem()size-cap check. As a result, device-SVM/AIEpools advertised the system-memory allocation limit instead of their
real per-pool limit, letting allocators request sizes the pool cannot
satisfy and fail with
HSA_STATUS_ERROR_OUT_OF_RESOURCES.Fix: use
max_single_alloc_size_forHSA_HEAPTYPE_DEVICE_SVMin bothGetInfo()'sHSA_REGION_INFO_ALLOC_MAX_SIZEcase andAllocateImpl()'s size-cap check, matching the value already used forlocal-memory allocations.
Issue Tracking
JIRA ID: ROCM-21660
Test Plan
Built
hsa-runtime64with the fix and ran the rocrtst reproducerbefore/after on gfx1151 (Strix Halo APU) hardware.
Test Result
rocrtstStress.Memory_Concurrent_Allocate_TestHSA_STATUS_ERROR_OUT_OF_RESOURCES, Pool 8)rocrtstStress.Memory_Concurrent_Free_TestHSA_STATUS_ERROR_OUT_OF_RESOURCES, Pool 8)Submission Checklist