Re: [PATCH v2 3/4] drm/xe: Wire up dmem cgroup reclaim for VRAM manager

Thomas Hellström
2026-04-28T10:02:43Z

On Tue, 2026-04-28 at 11:50 +0200, Maarten Lankhorst wrote:
>
>
> Den 2026-04-28 kl. 09:31, skrev Thomas Hellström:
> > Register the VRAM manager with the dmem cgroup reclaim
> > infrastructure
> > so that lowering dmem.max below current VRAM usage triggers TTM
> > eviction rather than failing with -EBUSY.
> >
> > Assisted-by: GitHub Copilot:claude-sonnet-4.6
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_ttm_vram_mgr.c | 19 ++++++++++++-------
> >  1 file changed, 12 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > index 5fd0d5506a7e..1bdcb3fee901 100644
> > --- a/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > +++ b/drivers/gpu/drm/xe/xe_ttm_vram_mgr.c
> > @@ -303,13 +303,6 @@ int __xe_ttm_vram_mgr_init(struct xe_device
> > *xe, struct xe_ttm_vram_mgr *mgr,
> >   struct ttm_resource_manager *man = &mgr->manager;
> >   int err;
> >
> > - if (mem_type != XE_PL_STOLEN) {
> > - const char *name = mem_type == XE_PL_VRAM0 ?
> > "vram0" : "vram1";
> > - man->cg = drmm_cgroup_register_region(&xe->drm,
> > name, size);
> > - if (IS_ERR(man->cg))
> > - return PTR_ERR(man->cg);
> > - }
> > -
> >   man->func = &xe_ttm_vram_mgr_func;
> >   mgr->mem_type = mem_type;
> >   mutex_init(&mgr->lock);
> > @@ -318,6 +311,18 @@ int __xe_ttm_vram_mgr_init(struct xe_device
> > *xe, struct xe_ttm_vram_mgr *mgr,
> >   mgr->visible_avail = io_size;
> >
> >   ttm_resource_manager_init(man, &xe->ttm, size);
> > +
> > + if (mem_type != XE_PL_STOLEN) {
> > + const char *name = mem_type == XE_PL_VRAM0 ?
> > "vram0" : "vram1";
> > + struct dmem_cgroup_region *cg =
> > + drmm_cgroup_register_region(&xe->drm,
> > name, size);
> > +
> > + if (IS_ERR(cg))
> > + return PTR_ERR(cg);
> > +
> > + ttm_resource_manager_set_dmem_region(man, cg);
> > + }
> > +
> >   err = gpu_buddy_init(&mgr->mm, man->size,
> > default_page_size);
> >   if (err)
> >   return err;
>
> This patch will conflict with
> https://patchwork.freedesktop.org/series/164694/ which removes
> stolen support, can we merge that patch first while we wait for AMD
> acks?

Sure, np.

>
> Do I need an ack to get the series through drm-misc?

Which series? The stolen support or this cgroup series?

Thanks,
Thomas

>
> Kind regards,
> ~Maarten Lankhorst