Files
geramyloveless 6b75868c1e kfd session: wait for freed VRAM before refusing an allocation
A KFD VRAM allocation is checked against the VRAM manager before KFD
sees it (vram_fits), so that a full manager refuses it instead of TTM
evicting the process's buffers across the link. The manager still
counts buffers that were freed but not yet released: every freed KFD
VRAM buffer is wiped on release (AMDGPU_GEM_CREATE_VRAM_WIPE_ON_RELEASE)
and TTM's delayed delete returns its memory only after that SDMA fill
retires, about 12 ms per GB on an R9700.

An LSE server short of memory trims its caches and allocates at once.
The trimmed buffers were still being wiped, so the check refused the
allocation with gigabytes about to come free: "KFD VRAM used 26.25 GB
... VRAM manager used 31.52 GB", where the 5.3 GB difference was the
trimmed caches, not memory held by the display or other clients (with
no KFD client the manager holds 63 MiB). Upstream TTM waits for such
buffers when it evicts (ttm_bo_evict_cb, bo->deleted), so on Linux the
same allocation succeeds.

When an allocation does not fit, count the freed buffers still on the
VRAM manager's LRU. If their release would make room, wait for it,
bounded by RT_KFD_PENDING_FREE_MS (the copy timeout, 5 s); otherwise
refuse at once as before. The refusal message now says how much of the
manager's use is freed buffers still being released.
2026-10-10 18:06:07 -07:00
..
2026-10-02 20:56:19 -07:00