All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/4]  Add support for DRM cgroup memory accounting.
@ 2023-05-03  8:34 ` Maarten Lankhorst
  0 siblings, 0 replies; 89+ messages in thread
From: Maarten Lankhorst @ 2023-05-03  8:34 UTC (permalink / raw)
  To: dri-devel, cgroups, intel-xe
  Cc: Daniel Vetter, Tvrtko Ursulin, Thomas Zimmermann, intel-gfx,
	Maarten Lankhorst, linux-kernel, amd-gfx, Maxime Ripard, Zefan Li,
	Johannes Weiner, Tejun Heo, David Airlie

RFC as I'm looking for comments.

For long running compute, it can be beneficial to partition the GPU memory
between cgroups, so each cgroup can use its maximum amount of memory without
interfering with other scheduled jobs. Done properly, this can alleviate the
need for eviction, which might result in a job being terminated if the GPU
doesn't support mid-thread preemption or recoverable page faults.

This is done by adding a bunch of knobs to cgroup:
drm.capacity: Shows maximum capacity of each resource region.
drm.max: Display or limit max amount of memory.
drm.current: Current amount of memory in use.

TTM has not been made cgroup aware yet, so instead of evicting from
the current cgroup to stay within the cgroup limits, it simply returns
the error -ENOSPC to userspace.

I've used Tvrtko's cgroup controller series as a base, but it implemented
scheduling weight, not memory accounting, so I only ended up keeping the
base patch.

Xe is not upstream yet, so the driver specific patch will only apply on
https://gitlab.freedesktop.org/drm/xe/kernel

Maarten Lankhorst (3):
  drm/cgroup: Add memory accounting to DRM cgroup
  drm/ttm: Handle -EAGAIN in ttm_resource_alloc as -ENOSPC.
  drm/xe: Add support for the drm cgroup

Tvrtko Ursulin (1):
  cgroup: Add the DRM cgroup controller

 Documentation/admin-guide/cgroup-v2.rst    |  46 ++
 Documentation/gpu/drm-compute.rst          |  54 ++
 drivers/gpu/drm/ttm/ttm_bo.c               |   4 +-
 drivers/gpu/drm/xe/xe_device.c             |   4 +
 drivers/gpu/drm/xe/xe_device_types.h       |   4 +
 drivers/gpu/drm/xe/xe_ttm_vram_mgr.c       |  21 +-
 drivers/gpu/drm/xe/xe_ttm_vram_mgr_types.h |   5 +
 include/linux/cgroup_drm.h                 |  90 ++++
 include/linux/cgroup_subsys.h              |   4 +
 init/Kconfig                               |   7 +
 kernel/cgroup/Makefile                     |   1 +
 kernel/cgroup/drm.c                        | 557 +++++++++++++++++++++
 12 files changed, 794 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/gpu/drm-compute.rst
 create mode 100644 include/linux/cgroup_drm.h
 create mode 100644 kernel/cgroup/drm.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 89+ messages in thread

end of thread, other threads:[~2023-05-11 19:58 UTC | newest]

Thread overview: 89+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-03  8:34 [RFC PATCH 0/4] Add support for DRM cgroup memory accounting Maarten Lankhorst
2023-05-03  8:34 ` Maarten Lankhorst
2023-05-03  8:34 ` Maarten Lankhorst
2023-05-03  8:34 ` [Intel-xe] " Maarten Lankhorst
2023-05-03  8:34 ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  8:34 ` Maarten Lankhorst
2023-05-03  8:34 ` [RFC PATCH 1/4] cgroup: Add the DRM cgroup controller Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` [Intel-xe] " Maarten Lankhorst
2023-05-03  8:34   ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34 ` [RFC PATCH 2/4] drm/cgroup: Add memory accounting to DRM cgroup Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` [Intel-xe] " Maarten Lankhorst
2023-05-03  8:34   ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03 15:31   ` [Intel-gfx] " Tvrtko Ursulin
2023-05-03 15:31     ` Tvrtko Ursulin
2023-05-03 15:31     ` Tvrtko Ursulin
2023-05-03 15:31     ` [Intel-xe] " Tvrtko Ursulin
2023-05-03 15:31     ` Tvrtko Ursulin
2023-05-03 15:33     ` Maarten Lankhorst
2023-05-03 15:33       ` Maarten Lankhorst
2023-05-03 15:33       ` Maarten Lankhorst
2023-05-03 15:33       ` [Intel-xe] " Maarten Lankhorst
2023-05-03 15:33       ` Maarten Lankhorst
2023-05-05 14:21     ` [Intel-gfx] " Maarten Lankhorst
2023-05-05 14:21       ` Maarten Lankhorst
2023-05-05 14:21       ` Maarten Lankhorst
2023-05-05 14:21       ` [Intel-xe] " Maarten Lankhorst
2023-05-05 14:21       ` Maarten Lankhorst
2023-05-03  8:34 ` [RFC PATCH 3/4] drm/ttm: Handle -EAGAIN in ttm_resource_alloc as -ENOSPC Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  8:34   ` [Intel-xe] " Maarten Lankhorst
2023-05-03  8:34   ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  8:34   ` Maarten Lankhorst
2023-05-03  9:11   ` [Intel-xe] " Thomas Hellström
2023-05-03  9:11     ` Thomas Hellström
2023-05-03  9:11     ` Thomas Hellström
2023-05-03  9:11     ` [Intel-gfx] " Thomas Hellström
2023-05-03  9:11     ` Thomas Hellström
2023-05-03  9:36     ` Maarten Lankhorst
2023-05-03  9:36       ` Maarten Lankhorst
2023-05-03  9:36       ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  9:36       ` Maarten Lankhorst
2023-05-03  8:35 ` [RFC PATCH 4/4] drm/xe: Add support for the drm cgroup Maarten Lankhorst
2023-05-03  8:35   ` Maarten Lankhorst
2023-05-03  8:35   ` Maarten Lankhorst
2023-05-03  8:35   ` [Intel-xe] " Maarten Lankhorst
2023-05-03  8:35   ` [Intel-gfx] " Maarten Lankhorst
2023-05-03  8:35   ` Maarten Lankhorst
2023-05-03  8:38 ` [Intel-xe] ✓ CI.Patch_applied: success for Add support for DRM cgroup memory accounting Patchwork
2023-05-03  8:38 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
2023-05-03  9:54 ` [Intel-gfx] ✗ Fi.CI.BUILD: " Patchwork
2023-05-05 19:50 ` [RFC PATCH 0/4] " Tejun Heo
2023-05-05 19:50   ` Tejun Heo
2023-05-05 19:50   ` Tejun Heo
2023-05-05 19:50   ` [Intel-xe] " Tejun Heo
2023-05-05 19:50   ` [Intel-gfx] " Tejun Heo
2023-05-05 19:50   ` Tejun Heo
2023-05-10 14:59   ` Maarten Lankhorst
2023-05-10 14:59     ` Maarten Lankhorst
2023-05-10 14:59     ` [Intel-xe] " Maarten Lankhorst
2023-05-10 14:59     ` [Intel-gfx] " Maarten Lankhorst
2023-05-10 14:59     ` Maarten Lankhorst
2023-05-10 18:46     ` Tejun Heo
2023-05-10 18:46       ` Tejun Heo
2023-05-10 18:46       ` Tejun Heo
2023-05-10 18:46       ` [Intel-xe] " Tejun Heo
2023-05-10 18:46       ` [Intel-gfx] " Tejun Heo
2023-05-10 18:46       ` Tejun Heo
2023-05-11 10:03       ` Maarten Lankhorst
2023-05-11 10:03         ` Maarten Lankhorst
2023-05-11 10:03         ` Maarten Lankhorst
2023-05-11 10:03         ` [Intel-xe] " Maarten Lankhorst
2023-05-11 10:03         ` [Intel-gfx] " Maarten Lankhorst
2023-05-11 10:03         ` Maarten Lankhorst
2023-05-11 10:14       ` [Intel-gfx] " Tvrtko Ursulin
2023-05-11 10:14         ` Tvrtko Ursulin
2023-05-11 10:14         ` [Intel-xe] " Tvrtko Ursulin
2023-05-11 10:14         ` Tvrtko Ursulin
2023-05-11 19:58         ` Maarten Lankhorst
2023-05-11 19:58           ` Maarten Lankhorst
2023-05-11 19:58           ` Maarten Lankhorst
2023-05-11 19:58           ` [Intel-xe] " Maarten Lankhorst
2023-05-11 19:58           ` Maarten Lankhorst

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.