[PATCH v2 0/4] Add reclaim to the dmem cgroup controller

From: Thomas Hellström

Date: Tue Apr 28 2026 - 03:57:46 EST


When writing a "max" limit lower than the current usage, the
existing code silently failed. This series aims to improve
on that by returning -EBUSY on failure and also attempt
to synchronously reclaim device memory to push the usage
under the new max limit to avoid the error.

Patch 1 implements and documents a reclaim callback interface
for the dmem controller.
Patch 2 implements a TTM reclaim callback.
Patch 3-4 hooks up the reclaim callback to the dmem cgroups-
aware drivers xe and amdgpu.

v2:
- Remove the error propagation that was in a previous series (Maarten)
- A number of updates in patch 1. See its commit message for
details (Maarten)

User-space tests are at
https://patchwork.freedesktop.org/series/163935/

Test-with: 20260428065411.4222-1-thomas.hellstrom@xxxxxxxxxxxxxxx

Thomas Hellström (4):
cgroup/dmem: Add reclaim callback for lowering max below current usage
drm/ttm: Hook up a cgroup-aware reclaim callback for the dmem
controller
drm/xe: Wire up dmem cgroup reclaim for VRAM manager
drm/amdgpu: Wire up dmem cgroup reclaim for VRAM manager

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 10 ++-
drivers/gpu/drm/ttm/ttm_bo.c | 95 +++++++++++++++++++-
drivers/gpu/drm/ttm/ttm_bo_util.c | 3 +-
drivers/gpu/drm/ttm/ttm_resource.c | 36 ++++++++
drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 19 ++--
include/drm/ttm/ttm_bo.h | 10 +++
include/drm/ttm/ttm_resource.h | 4 +
include/linux/cgroup_dmem.h | 11 +++
kernel/cgroup/dmem.c | 83 +++++++++++++++--
10 files changed, 249 insertions(+), 24 deletions(-)

--
2.53.0