drm/amdkfd: report realistic free/total memory on GTT-backed APUs
Subsystems (3)
cover drm/amdkfd: report realistic free/total memory on GTT-backed APUs
On APUs where KFD serves VRAM allocations from GTT (apu_prefer_gtt), the memory reported to user space does not match what can be allocated:
- Free (AMDKFD_IOC_AVAILABLE_MEMORY -> hipMemGetInfo()) only subtracts KFD's own allocations, so host memory used by other processes is ignored.
- Total (topology local memory size) is the TTM pages limit, which may be above physical RAM, while KFD refuses allocations beyond its system memory limit.
Frameworks such as vLLM, llama.cpp and PyTorch size buffers from these values and over-commit, ending in the OOM killer.
Patch 1 bounds the reported free memory by si_mem_available(). Patch 2 bounds the reported pool size by KFD's system memory limit. Only the reported values change; allocation limits and GTT/TTM sizing are not touched. Both are skipped with no_system_mem_limit=1. Carve-out backed APUs and dGPUs are not affected.
Tested on gfx1151 (Ryzen AI MAX+ 395, 62 GiB RAM), HIP free/total vs MemAvailable (GiB):
ttm.pages_limit = 80 GiB stock 7.0.0-44 patched
total 80.00 59.69
40 GiB held by another process
free / MemAvailable 59.67 / 20.39 19.60 / 19.60
default ttm.pages_limit (31.08 GiB) patched
total 31.08 (unchanged)
40 GiB held: free / MemAvailable 19.16 / 19.16
With no_system_mem_limit=1 the reported values are the same as without this series. kfdtest (KFDMemoryTest, KFDLocalMemoryTest, KFDTopologyTest, KFDOpenCloseKFDTest) results are identical with and without the series at ttm.pages_limit = 80 GiB. Not tested: MI300A, dGPU.
Strahinja found the issue and wrote the original patches; he is listed as Co-developed-by. Strahinja, please reply with your Signed-off-by for both patches so it can be added next to the Co-developed-by tags.
Changes in v1:
- Initial version, based on amd-staging-drm-next. In patch 1 the bound is applied in the amdgpu_amdkfd_get_available_memory() wrapper, since __get_available_memory() is also used by the is_app_apu allocation path after commit 32abf4fe544b ("drm/amdkfd: correct vram_available calculation").
Priya Hosur (2):
drm/amdkfd: bound APU available memory by host available memory drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 6 ++++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 drm/amdkfd: bound APU available memory by host available memory
On APUs where the VRAM carve-out is smaller than GTT (apu_prefer_gtt), KFD serves VRAM allocations from GTT, which is ordinary system memory. amdgpu_amdkfd_get_available_memory() then reports the minimum of the static KFD system limit, the TTM limit and the XCP size, each reduced only by KFD's own allocations. Memory used by the rest of the system is never subtracted, so AMDKFD_IOC_AVAILABLE_MEMORY, and hipMemGetInfo() on top of it, overstates what can be allocated.
On a Ryzen AI MAX+ 395 (gfx1151, 62 GiB RAM, ttm.pages_limit 80 GiB) with 40 GiB held by another process, hipMemGetInfo() reports 59.67 GiB free while MemAvailable is 20.39 GiB. Applications that size buffers from it (e.g. a KV cache) overcommit and, without swap, trigger the OOM killer instead of failing cleanly.
Bound the reported value by si_mem_available() when apu_prefer_gtt is set, unless no_system_mem_limit is set, which explicitly allows KFD to overcommit system memory. si_mem_available() includes reclaimable page cache, so this does not under-report on an idle system.
Apply the bound in amdgpu_amdkfd_get_available_memory() rather than in __get_available_memory(), which is also used by the allocation path for is_app_apu. Allocation limits are unchanged; only the reported value is affected.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +10 -0
@@ -1732,6 +1732,16 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev, adev->kfd.vram_used_aligned[xcp_id]);spin_unlock (&kfd_mem_limit.mem_limit_lock); +/* +* In GTT mode, KFD allocations are backed by ordinary system pages, so +* memory used elsewhere on the host is not available to the GPU either. +* KFD only tracks its own usage, so also bound the reported value by the +* host's available memory. This affects reporting only, not the limits. +*/ +if (adev->apu_prefer_gtt && !no_system_mem_limit) + available =min_t (size_t, available, + (size_t )si_mem_available () <<PAGE_SHIFT ); +return available; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 1/2] drm/amdkfd: bound APU available memory by host available memory
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amdkfd: missing Signed-off-by trailer for Co-developed-by author --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/amdkfd: missing Signed-off-by trailer for Co-developed-by author
--
commit 420a8aac5bafb2838f8e3671bb8ebf0a0f48b7bc
Author: Priya Hosur <[email protected]>
Quoted 21 lines
drm/amdkfd: bound APU available memory by host available memory
On APUs where the VRAM carve-out is smaller than GTT (
apu_prefer_gtt), KFD serves VRAM allocations from GTT, which is ordinary system memory.amdgpu_amdkfd_get_available_memory()then reports the minimum of the static KFD system limit, the TTM limit and the XCP size, each reduced only by KFD's own allocations. Memory used by the rest of the system is never subtracted, soAMDKFD_IOC_AVAILABLE_MEMORY, andhipMemGetInfo()on top of it, overstates what can be allocated.On a Ryzen AI MAX+ 395 (gfx1151, 62 GiB RAM, ttm.pages_limit 80 GiB) with 40 GiB held by another process,
hipMemGetInfo()reports 59.67 GiB free while MemAvailable is 20.39 GiB. Applications that size buffers from it (e.g. a KV cache) overcommit and, without swap, trigger the OOM killer instead of failing cleanly.Bound the reported value by
si_mem_available()whenapu_prefer_gttis set, unlessno_system_mem_limitis set, which explicitly allows KFD to overcommit system memory.si_mem_available()includes reclaimable page cache, so this does not under-report on an idle system.
Quoted 8 lines
Apply the bound in
amdgpu_amdkfd_get_available_memory()rather than in__get_available_memory(), which is also used by the allocation path foris_app_apu. Allocation limits are unchanged; only the reported value is affected.Co-developed-by Strahinja Stamenkovic <[email protected]>Assisted-by Claude:claude-opus-5-5Signed-off-by Priya Hosur <[email protected]>
[Severity: High]
Per Documentation/process/submitting-patches.rst, every Co-developed-by trailer must be immediately followed by a matching Signed-off-by trailer from that co-author. Should a Signed-off-by trailer for Strahinja Stamenkovic be added right after the Co-developed-by line?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
RE: [PATCH 1/2] drm/amdkfd: bound APU available memory by host available memory
In reply to Priya HosurPATCH 2/2 drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
In reply to Priya HosurWith apu_prefer_gtt, KFD reports ttm_tt_pages_limit() as the local memory size, which HIP exposes as the device's total memory. TTM may legitimately be configured above physical memory, since it can swap buffers out, but KFD allocations are additionally bounded by kfd_mem_limit.max_system_mem_limit, which is derived from physical memory. KFD therefore advertises a pool it will never allocate from: on a Ryzen AI MAX+ 395 with 62 GiB RAM and ttm.pages_limit set to 80 GiB, HIP reports 80 GiB total while KFD caps allocations at 59.69 GiB, so applications sizing against a fraction of total fail.
Report the smaller of the TTM limit and KFD's system memory limit, via a new amdgpu_amdkfd_system_mem_limit() accessor. When no_system_mem_limit is set to allow overcommit, the TTM limit is reported unchanged. GTT and TTM sizing are not affected.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 +++++++++ 3 files changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13 -2
@@ -521,6 +521,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev,return 0 ; } +/* +* Size of the GTT-backed pool reported on APUs. TTM may be configured above +* physical RAM, but KFD will not allocate beyond its system memory limit, so +* don't report more than that. +*/ +static u64 amdgpu_amdkfd_gtt_pool_size (void ) +{ +return min ((u64 )ttm_tt_pages_limit () <<PAGE_SHIFT , +amdgpu_amdkfd_system_mem_limit ()); +} +void amdgpu_amdkfd_get_local_mem_info (struct amdgpu_device *adev,struct kfd_local_mem_info *mem_info,struct amdgpu_xcp *xcp)
@@ -535,7 +546,7 @@ void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, mem_info->local_mem_size_private =KFD_XCP_MEMORY_SIZE (adev, xcp->id); }else if (adev->apu_prefer_gtt) { - mem_info->local_mem_size_public = (ttm_tt_pages_limit () <<PAGE_SHIFT ); + mem_info->local_mem_size_public =amdgpu_amdkfd_gtt_pool_size (); mem_info->local_mem_size_private =0 ; }else { mem_info->local_mem_size_public = adev->gmc.visible_vram_size;
@@ -863,7 +874,7 @@ u64 amdgpu_amdkfd_xcp_memory_size(struct amdgpu_device *adev, int xcp_id)return ALIGN_DOWN (tmp,PAGE_SIZE ); }else if (adev->apu_prefer_gtt) { -return (ttm_tt_pages_limit () <<PAGE_SHIFT ); +return amdgpu_amdkfd_gtt_pool_size (); }else {return adev->gmc.real_vram_size; }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +6 -0
@@ -400,6 +400,7 @@ void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo);void amdgpu_amdkfd_account_vram_pin (struct amdgpu_bo *bo,int xcp_id);void amdgpu_amdkfd_account_vram_unpin (struct amdgpu_bo *bo,int xcp_id);void amdgpu_amdkfd_reserve_system_mem (uint64_t size); +u64 amdgpu_amdkfd_system_mem_limit (void );#else static inline void amdgpu_amdkfd_gpuvm_init_mem_limits (void )
@@ -426,6 +427,11 @@ static inlinevoid amdgpu_amdkfd_account_vram_unpin (struct amdgpu_bo *bo,int xcp_id) { } + +static inline u64 amdgpu_amdkfd_system_mem_limit (void ) +{ +return U64_MAX ; +}#endif #if IS_ENABLED (CONFIG_HSA_AMD_SVM )
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +9 -0
@@ -130,6 +130,15 @@ void amdgpu_amdkfd_gpuvm_init_mem_limits(void) (kfd_mem_limit.max_ttm_mem_limit >> 20)); } +/* Returns U64_MAX if the system memory limit is disabled or not yet set up. */ +u64 amdgpu_amdkfd_system_mem_limit (void ) +{ +if (no_system_mem_limit || !kfd_mem_limit.max_system_mem_limit) +return U64_MAX ; + +return kfd_mem_limit.max_system_mem_limit; +} +void amdgpu_amdkfd_reserve_system_mem (uint64_t size) { kfd_mem_limit.system_mem_used += size;
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/2] drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/amdkfd: unaligned GTT pool size in amdgpu_amdkfd_gtt_pool_size() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/amdkfd: unaligned GTT pool size in amdgpu_amdkfd_gtt_pool_size()
--
commit 17502322da1ca7a12d9a6715a32b9c3d4e96b211
Author: Priya Hosur <[email protected]>
drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
This commit caps the reported APU GTT pool size in amdgpu_amdkfd_get_local_mem_info() and amdgpu_amdkfd_xcp_memory_size() by the smaller of TTM's page limit and KFD's system memory limit.
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0
-0@@ -521,6 +521,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev,return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev, · line 533
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +10
-0+/* +* Size of the GTT-backed pool reported on APUs. TTM may be configured above +* physical RAM, but KFD will not allocate beyond its system memory limit, so +* don't report more than that. +*/ +static u64 amdgpu_amdkfd_gtt_pool_size (void ) +{ +return min ((u64 )ttm_tt_pages_limit () <<PAGE_SHIFT , +amdgpu_amdkfd_system_mem_limit ()); +}
[Severity: Low]
Can amdgpu_amdkfd_gtt_pool_size() return a byte count that is not aligned to PAGE_SIZE?
In amdgpu_amdkfd_gpuvm_init_mem_limits(), max_system_mem_limit is derived from mem - (mem >> 6), which is only 64-byte aligned whenever si.totalram - si.totalhigh is not a multiple of 64 pages. Since amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu() rounds every allocation up with PAGE_ALIGN(size) before checking max_system_mem_limit, any sub-page remainder advertised in local_mem_size_public and amdgpu_amdkfd_xcp_memory_size() cannot be allocated. Rounding the result down with ALIGN_DOWN(..., PAGE_SIZE) would match the partition branch in amdgpu_amdkfd_xcp_memory_size().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
RE: [PATCH 2/2] drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
In reply to Priya Hosurv2 cover drm/amdkfd: report realistic free/total memory on GTT-backed APUs
In reply to Priya HosurOn APUs where KFD serves VRAM allocations from GTT (apu_prefer_gtt), the memory reported to user space does not match what can be allocated:
- Free (AMDKFD_IOC_AVAILABLE_MEMORY -> hipMemGetInfo()) only subtracts KFD's own allocations, so host memory used by other processes is ignored.
- Total (topology local memory size) is the TTM pages limit, which may be above physical RAM, while KFD refuses allocations beyond its system memory limit.
Frameworks such as vLLM, llama.cpp and PyTorch size buffers from these values and over-commit, ending in the OOM killer.
Patch 1 bounds the reported free memory by si_mem_available(). Patch 2 bounds the reported pool size by KFD's system memory limit. Only the reported values change; allocation limits and GTT/TTM sizing are not touched. Both are skipped with no_system_mem_limit=1. Carve-out backed APUs and dGPUs are not affected.
Tested on gfx1151 (Ryzen AI MAX+ 395, 62 GiB RAM), HIP free/total vs MemAvailable (GiB):
ttm.pages_limit = 80 GiB stock 7.0.0-44 v2
total 80.00 59.69
40 GiB held by another process
free / MemAvailable 59.67 / 20.39 19.52 / 19.52
default ttm.pages_limit (31.08 GiB) v1
total 31.08 (unchanged)
40 GiB held: free / MemAvailable 19.16 / 19.16
With v2 the reported total is 64089890816 bytes, i.e. KFD's system memory limit rounded down to PAGE_SIZE.
With no_system_mem_limit=1 the reported values are the same as without this series. kfdtest (KFDMemoryTest, KFDLocalMemoryTest, KFDTopologyTest, KFDOpenCloseKFDTest) results are identical with and without the series at ttm.pages_limit = 80 GiB. Not tested: MI300A, dGPU.
Changes in v2:
- Add Strahinja's Signed-off-by after Co-developed-by (Sashiko review).
- Patch 2: round the reported pool size down to PAGE_SIZE, since max_system_mem_limit is not necessarily page aligned while KFD allocations are (Sashiko review).
Changes in v1:
- Initial version, based on amd-staging-drm-next. In patch 1 the bound is applied in the amdgpu_amdkfd_get_available_memory() wrapper, since __get_available_memory() is also used by the is_app_apu allocation path after commit 32abf4fe544b ("drm/amdkfd: correct vram_available calculation").
v1: https://lore.kernel.org/amd-gfx/[email protected]/
Priya Hosur (2):
drm/amdkfd: bound APU available memory by host available memory drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 6 ++++++ .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 drm/amdkfd: bound APU available memory by host available memory
In reply to Priya HosurOn APUs where the VRAM carve-out is smaller than GTT (apu_prefer_gtt), KFD serves VRAM allocations from GTT, which is ordinary system memory. amdgpu_amdkfd_get_available_memory() then reports the minimum of the static KFD system limit, the TTM limit and the XCP size, each reduced only by KFD's own allocations. Memory used by the rest of the system is never subtracted, so AMDKFD_IOC_AVAILABLE_MEMORY, and hipMemGetInfo() on top of it, overstates what can be allocated.
On a Ryzen AI MAX+ 395 (gfx1151, 62 GiB RAM, ttm.pages_limit 80 GiB) with 40 GiB held by another process, hipMemGetInfo() reports 59.67 GiB free while MemAvailable is 20.39 GiB. Applications that size buffers from it (e.g. a KV cache) overcommit and, without swap, trigger the OOM killer instead of failing cleanly.
Bound the reported value by si_mem_available() when apu_prefer_gtt is set, unless no_system_mem_limit is set, which explicitly allows KFD to overcommit system memory. si_mem_available() includes reclaimable page cache, so this does not under-report on an idle system.
Apply the bound in amdgpu_amdkfd_get_available_memory() rather than in __get_available_memory(), which is also used by the allocation path for is_app_apu. Allocation limits are unchanged; only the reported value is affected.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +10 -0
@@ -1732,6 +1732,16 @@ size_t amdgpu_amdkfd_get_available_memory(struct amdgpu_device *adev, adev->kfd.vram_used_aligned[xcp_id]);spin_unlock (&kfd_mem_limit.mem_limit_lock); +/* +* In GTT mode, KFD allocations are backed by ordinary system pages, so +* memory used elsewhere on the host is not available to the GPU either. +* KFD only tracks its own usage, so also bound the reported value by the +* host's available memory. This affects reporting only, not the limits. +*/ +if (adev->apu_prefer_gtt && !no_system_mem_limit) + available =min_t (size_t, available, + (size_t )si_mem_available () <<PAGE_SHIFT ); +return available; }
Signature · 1 line
2.43.0
PATCH v2 2/2 drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit
In reply to Priya HosurWith apu_prefer_gtt, KFD reports ttm_tt_pages_limit() as the local memory size, which HIP exposes as the device's total memory. TTM may legitimately be configured above physical memory, since it can swap buffers out, but KFD allocations are additionally bounded by kfd_mem_limit.max_system_mem_limit, which is derived from physical memory. KFD therefore advertises a pool it will never allocate from: on a Ryzen AI MAX+ 395 with 62 GiB RAM and ttm.pages_limit set to 80 GiB, HIP reports 80 GiB total while KFD caps allocations at 59.69 GiB, so applications sizing against a fraction of total fail.
Report the smaller of the TTM limit and KFD's system memory limit, via a new amdgpu_amdkfd_system_mem_limit() accessor, rounded down to PAGE_SIZE since max_system_mem_limit is not necessarily page aligned while KFD allocations are. When no_system_mem_limit is set to allow overcommit, the TTM limit is reported unchanged. GTT and TTM sizing are not affected.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 15 +++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 9 +++++++++ 3 files changed, 28 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +13 -2
@@ -521,6 +521,17 @@ uint32_t amdgpu_amdkfd_get_fw_version(struct amdgpu_device *adev,return 0 ; } +/* +* Size of the GTT-backed pool reported on APUs. TTM may be configured above +* physical RAM, but KFD will not allocate beyond its system memory limit, so +* don't report more than that. +*/ +static u64 amdgpu_amdkfd_gtt_pool_size (void ) +{ +return ALIGN_DOWN (min ((u64 )ttm_tt_pages_limit () <<PAGE_SHIFT , +amdgpu_amdkfd_system_mem_limit ()),PAGE_SIZE ); +} +void amdgpu_amdkfd_get_local_mem_info (struct amdgpu_device *adev,struct kfd_local_mem_info *mem_info,struct amdgpu_xcp *xcp)
@@ -535,7 +546,7 @@ void amdgpu_amdkfd_get_local_mem_info(struct amdgpu_device *adev, mem_info->local_mem_size_private =KFD_XCP_MEMORY_SIZE (adev, xcp->id); }else if (adev->apu_prefer_gtt) { - mem_info->local_mem_size_public = (ttm_tt_pages_limit () <<PAGE_SHIFT ); + mem_info->local_mem_size_public =amdgpu_amdkfd_gtt_pool_size (); mem_info->local_mem_size_private =0 ; }else { mem_info->local_mem_size_public = adev->gmc.visible_vram_size;
@@ -863,7 +874,7 @@ u64 amdgpu_amdkfd_xcp_memory_size(struct amdgpu_device *adev, int xcp_id)return ALIGN_DOWN (tmp,PAGE_SIZE ); }else if (adev->apu_prefer_gtt) { -return (ttm_tt_pages_limit () <<PAGE_SHIFT ); +return amdgpu_amdkfd_gtt_pool_size (); }else {return adev->gmc.real_vram_size; }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +6 -0
@@ -400,6 +400,7 @@ void amdgpu_amdkfd_release_notify(struct amdgpu_bo *bo);void amdgpu_amdkfd_account_vram_pin (struct amdgpu_bo *bo,int xcp_id);void amdgpu_amdkfd_account_vram_unpin (struct amdgpu_bo *bo,int xcp_id);void amdgpu_amdkfd_reserve_system_mem (uint64_t size); +u64 amdgpu_amdkfd_system_mem_limit (void );#else static inline void amdgpu_amdkfd_gpuvm_init_mem_limits (void )
@@ -426,6 +427,11 @@ static inlinevoid amdgpu_amdkfd_account_vram_unpin (struct amdgpu_bo *bo,int xcp_id) { } + +static inline u64 amdgpu_amdkfd_system_mem_limit (void ) +{ +return U64_MAX ; +}#endif #if IS_ENABLED (CONFIG_HSA_AMD_SVM )
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +9 -0
@@ -130,6 +130,15 @@ void amdgpu_amdkfd_gpuvm_init_mem_limits(void) (kfd_mem_limit.max_ttm_mem_limit >> 20)); } +/* Returns U64_MAX if the system memory limit is disabled or not yet set up. */ +u64 amdgpu_amdkfd_system_mem_limit (void ) +{ +if (no_system_mem_limit || !kfd_mem_limit.max_system_mem_limit) +return U64_MAX ; + +return kfd_mem_limit.max_system_mem_limit; +} +void amdgpu_amdkfd_reserve_system_mem (uint64_t size) { kfd_mem_limit.system_mem_used += size;
Signature · 1 line
2.43.0