All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/amdkfd: report realistic free/total memory on GTT-backed APUs
@ 2026-11-27  8:28 Priya Hosur
  2026-11-27  8:28 ` [PATCH 1/2] drm/amdkfd: bound APU available memory by host available memory Priya Hosur
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Priya Hosur @ 2026-11-27  8:28 UTC (permalink / raw)
  To: amd-gfx, Strahinja Stamenkovic, Alex Deucher, Felix Kuehling,
	Christian König, Lijo Lazar
  Cc: Priya Hosur, Pratik Vishwakarma, Veerabadhran Gopalakrishnan

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(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-27 10:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27  8:28 [PATCH 0/2] drm/amdkfd: report realistic free/total memory on GTT-backed APUs Priya Hosur
2026-11-27  8:28 ` [PATCH 1/2] drm/amdkfd: bound APU available memory by host available memory Priya Hosur
2026-11-27  8:37   ` sashiko-bot
2026-11-27  8:52   ` Stamenkovic, Strahinja
2026-11-27  8:28 ` [PATCH 2/2] drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit Priya Hosur
2026-11-27  8:43   ` sashiko-bot
2026-11-27  8:52   ` Stamenkovic, Strahinja
2026-11-27 10:19 ` [PATCH v2 0/2] drm/amdkfd: report realistic free/total memory on GTT-backed APUs Priya Hosur
2026-11-27 10:19 ` [PATCH v2 1/2] drm/amdkfd: bound APU available memory by host available memory Priya Hosur
2026-11-27 10:19 ` [PATCH v2 2/2] drm/amdkfd: bound the APU GTT pool size by KFD's system memory limit Priya Hosur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.