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

Thomas Hellström posted 5 patches 6 days, 7 hours ago
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                         | 102 ++++++++++++++++---
10 files changed, 265 insertions(+), 27 deletions(-)
[PATCH 0/5] Add reclaim to the dmem cgroup controller
Posted by Thomas Hellström 6 days, 7 hours ago
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 error propagation.
Patch 2 implements and documents a reclaim callback interface
      for the dmem controller.
Patch 3 implements a TTM reclaim callback.
Patch 4-5 hooks up the reclaim callback to the dmem cgroups-
      aware drivers xe and amdgpu.

Thomas Hellström (5):
  cgroup/dmem: Return error when setting max below current usage
  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                         | 102 ++++++++++++++++---
 10 files changed, 265 insertions(+), 27 deletions(-)

-- 
2.53.0

Re: [PATCH 0/5] Add reclaim to the dmem cgroup controller
Posted by Thomas Hellström 6 days, 7 hours ago
On Fri, 2026-03-27 at 09:15 +0100, Thomas Hellström wrote:
> 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 error propagation.
> Patch 2 implements and documents a reclaim callback interface
>       for the dmem controller.
> Patch 3 implements a TTM reclaim callback.
> Patch 4-5 hooks up the reclaim callback to the dmem cgroups-
>       aware drivers xe and amdgpu.
> 
> Thomas Hellström (5):
>   cgroup/dmem: Return error when setting max below current usage
>   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                         | 102 ++++++++++++++++-
> --
>  10 files changed, 265 insertions(+), 27 deletions(-)

For reference, Series introducing igt test is here:
https://patchwork.freedesktop.org/series/163935/

/Thomas