From: Priya Hosur <Priya.Hosur@amd.com>
To: amd-gfx@lists.freedesktop.org,
"Strahinja Stamenkovic" <strahinja.stamenkovic@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Felix Kuehling" <Felix.Kuehling@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Lijo Lazar" <lijo.lazar@amd.com>
Cc: Priya Hosur <Priya.Hosur@amd.com>,
Pratik Vishwakarma <Pratik.Vishwakarma@amd.com>,
Veerabadhran Gopalakrishnan <Veerabadhran.Gopalakrishnan@amd.com>
Subject: [PATCH v2 0/2] drm/amdkfd: report realistic free/total memory on GTT-backed APUs
Date: Fri, 27 Nov 2026 15:49:06 +0530 [thread overview]
Message-ID: <20261127101908.8313-1-Priya.Hosur@amd.com> (raw)
In-Reply-To: <20261127082854.112025-1-Priya.Hosur@amd.com>
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 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/20261127082854.112025-1-Priya.Hosur@amd.com/
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
next prev parent reply other threads:[~2026-11-27 10:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Priya Hosur [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127101908.8313-1-Priya.Hosur@amd.com \
--to=priya.hosur@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Pratik.Vishwakarma@amd.com \
--cc=Veerabadhran.Gopalakrishnan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=lijo.lazar@amd.com \
--cc=strahinja.stamenkovic@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.