Skip to contentSkip to conversation

drm/nouveau: Wire up dmem cgroups

PATCH In review Natalie Vock 2 participants 2 messages Apr 10 – Aug 5

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau: Wire up dmem cgroups

Userspace can now make use of memory protection via dmem cgroups. Let nouveau benefit from this as well by registering the vram region with the dmem cgroup controller.

This patch adapts the approach amdgpu and Xe have taken for enabling dmem cgroups.

---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/nouveau/nouveau_ttm.c +5 -0
index ad01f922aa86a..860bca7e3ce28 100644
@@ -188,6 +188,11 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
 
 		man->func = &nouveau_vram_manager;
 
+		man->cg = drmm_cgroup_register_region(drm->dev, "vram",
+						      drm->gem.vram_available);
+		if (IS_ERR(man->cg))
+			return PTR_ERR(man->cg);
+
 		ttm_resource_manager_init(man, &drm->ttm.bdev,
 					  drm->gem.vram_available >> PAGE_SHIFT);
 		ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi! I'm sorry, I have no clue how this patch got overlooked. Thank you for the contribution.

I will push this upstream in just a moment

Quoted 33 lines · Natalie Vock

Userspace can now make use of memory protection via dmem cgroups. Let nouveau benefit from this as well by registering the vram region with the dmem cgroup controller.

This patch adapts the approach amdgpu and Xe have taken for enabling dmem cgroups.

---
 drivers/gpu/drm/nouveau/nouveau_ttm.c | 5 +++++

 1 file changed, 5 insertions(+)
drivers/gpu/drm/nouveau/nouveau_ttm.c +0 -0
index ad01f922aa86a..860bca7e3ce28 100644
@@ -188,6 +188,11 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)


  man->func = &nouveau_vram_manager;

drivers/gpu/drm/nouveau/nouveau_ttm.c +1 -0
+		man->cg = drmm_cgroup_register_region(drm->dev,

"vram",

drivers/gpu/drm/nouveau/nouveau_ttm.c +1 -0
+						      drm-
Quoted 1 line

gem.vram_available);

drivers/gpu/drm/nouveau/nouveau_ttm.c +3 -0
+		if (IS_ERR(man->cg))
+			return PTR_ERR(man->cg);
+

  ttm_resource_manager_init(man, &drm->ttm.bdev, drm->gem.vram_available >> PAGE_SHIFT);
  ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_VRAM, man);