All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v4 0/8] Proposal for a GPU cgroup controller
@ 2022-03-28  3:59 ` T.J. Mercier
  0 siblings, 0 replies; 66+ messages in thread
From: T.J. Mercier @ 2022-03-28  3:59 UTC (permalink / raw)
  To: tjmercier, David Airlie, Daniel Vetter, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, Jonathan Corbet,
	Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
	Martijn Coenen, Joel Fernandes, Christian Brauner,
	Hridya Valsaraju, Suren Baghdasaryan, Sumit Semwal,
	Christian König, Benjamin Gaignard, Liam Mark, Laura Abbott,
	Brian Starkey, John Stultz, Tejun Heo, Zefan Li, Johannes Weiner,
	Shuah Khan
  Cc: kaleshsingh, Kenny.Ho, mkoutny, skhan, dri-devel, linux-doc,
	linux-kernel, linux-media, linaro-mm-sig, cgroups,
	linux-kselftest

This patch series revisits the proposal for a GPU cgroup controller to
track and limit memory allocations by various device/allocator
subsystems. The patch series also contains a simple prototype to
illustrate how Android intends to implement DMA-BUF allocator
attribution using the GPU cgroup controller. The prototype does not
include resource limit enforcements.

Changelog:
v4:
Skip test if not run as root per Shuah Khan

Add better test logging for abnormal child termination per Shuah Khan

Adjust ordering of charge/uncharge during transfer to avoid potentially
hitting cgroup limit per Michal Koutný

Adjust gpucg_try_charge critical section for charge transfer functionality

Fix uninitialized return code error for dmabuf_try_charge error case

v3:
Remove Upstreaming Plan from gpu-cgroup.rst per John Stultz

Use more common dual author commit message format per John Stultz

Remove android from binder changes title per Todd Kjos

Add a kselftest for this new behavior per Greg Kroah-Hartman

Include details on behavior for all combinations of kernel/userspace
versions in changelog (thanks Suren Baghdasaryan) per Greg Kroah-Hartman.

Fix pid and uid types in binder UAPI header

v2:
See the previous revision of this change submitted by Hridya Valsaraju
at: https://lore.kernel.org/all/20220115010622.3185921-1-hridya@google.com/

Move dma-buf cgroup charge transfer from a dma_buf_op defined by every
heap to a single dma-buf function for all heaps per Daniel Vetter and
Christian König. Pointers to struct gpucg and struct gpucg_device
tracking the current associations were added to the dma_buf struct to
achieve this.

Fix incorrect Kconfig help section indentation per Randy Dunlap.

History of the GPU cgroup controller
====================================
The GPU/DRM cgroup controller came into being when a consensus[1]
was reached that the resources it tracked were unsuitable to be integrated
into memcg. Originally, the proposed controller was specific to the DRM
subsystem and was intended to track GEM buffers and GPU-specific
resources[2]. In order to help establish a unified memory accounting model
for all GPU and all related subsystems, Daniel Vetter put forth a
suggestion to move it out of the DRM subsystem so that it can be used by
other DMA-BUF exporters as well[3]. This RFC proposes an interface that
does the same.

[1]: https://patchwork.kernel.org/project/dri-devel/cover/20190501140438.9506-1-brian.welty@intel.com/#22624705
[2]: https://lore.kernel.org/amd-gfx/20210126214626.16260-1-brian.welty@intel.com/
[3]: https://lore.kernel.org/amd-gfx/YCVOl8%2F87bqRSQei@phenom.ffwll.local/

Hridya Valsaraju (5):
  gpu: rfc: Proposal for a GPU cgroup controller
  cgroup: gpu: Add a cgroup controller for allocator attribution of GPU
    memory
  dmabuf: heaps: export system_heap buffers with GPU cgroup charging
  dmabuf: Add gpu cgroup charge transfer function
  binder: Add a buffer flag to relinquish ownership of fds

T.J. Mercier (3):
  dmabuf: Use the GPU cgroup charge/uncharge APIs
  binder: use __kernel_pid_t and __kernel_uid_t for userspace
  selftests: Add binder cgroup gpu memory transfer test

 Documentation/gpu/rfc/gpu-cgroup.rst          | 183 +++++++
 Documentation/gpu/rfc/index.rst               |   4 +
 drivers/android/binder.c                      |  26 +
 drivers/dma-buf/dma-buf.c                     | 107 ++++
 drivers/dma-buf/dma-heap.c                    |  27 +
 drivers/dma-buf/heaps/system_heap.c           |   3 +
 include/linux/cgroup_gpu.h                    | 139 +++++
 include/linux/cgroup_subsys.h                 |   4 +
 include/linux/dma-buf.h                       |  22 +-
 include/linux/dma-heap.h                      |  11 +
 include/uapi/linux/android/binder.h           |   5 +-
 init/Kconfig                                  |   7 +
 kernel/cgroup/Makefile                        |   1 +
 kernel/cgroup/gpu.c                           | 362 +++++++++++++
 .../selftests/drivers/android/binder/Makefile |   8 +
 .../drivers/android/binder/binder_util.c      | 254 +++++++++
 .../drivers/android/binder/binder_util.h      |  32 ++
 .../selftests/drivers/android/binder/config   |   4 +
 .../binder/test_dmabuf_cgroup_transfer.c      | 484 ++++++++++++++++++
 19 files changed, 1679 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/gpu/rfc/gpu-cgroup.rst
 create mode 100644 include/linux/cgroup_gpu.h
 create mode 100644 kernel/cgroup/gpu.c
 create mode 100644 tools/testing/selftests/drivers/android/binder/Makefile
 create mode 100644 tools/testing/selftests/drivers/android/binder/binder_util.c
 create mode 100644 tools/testing/selftests/drivers/android/binder/binder_util.h
 create mode 100644 tools/testing/selftests/drivers/android/binder/config
 create mode 100644 tools/testing/selftests/drivers/android/binder/test_dmabuf_cgroup_transfer.c

-- 
2.35.1.1021.g381101b075-goog


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

end of thread, other threads:[~2022-04-06  0:51 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  3:59 [RFC v4 0/8] Proposal for a GPU cgroup controller T.J. Mercier
2022-03-28  3:59 ` T.J. Mercier
2022-03-28  3:59 ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 1/8] gpu: rfc: " T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 2/8] cgroup: gpu: Add a cgroup controller for allocator attribution of GPU memory T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-29 16:59   ` Tejun Heo
2022-03-29 16:59     ` Tejun Heo
2022-03-29 16:59     ` Tejun Heo
2022-03-30 20:56     ` T.J. Mercier
2022-03-30 20:56       ` T.J. Mercier
2022-03-30 20:56       ` T.J. Mercier
2022-04-04 17:41       ` Tejun Heo
2022-04-04 17:41         ` Tejun Heo
2022-04-04 17:41         ` Tejun Heo
2022-04-04 17:49         ` T.J. Mercier
2022-04-04 17:49           ` T.J. Mercier
2022-04-04 17:49           ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 3/8] dmabuf: Use the GPU cgroup charge/uncharge APIs T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 4/8] dmabuf: heaps: export system_heap buffers with GPU cgroup charging T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28 14:36   ` Daniel Vetter
2022-03-28 14:36     ` Daniel Vetter
2022-03-28 14:36     ` Daniel Vetter
     [not found]     ` <YkHH/0Use7F30UUE-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2022-03-28 18:28       ` T.J. Mercier
2022-03-28 18:28     ` T.J. Mercier
2022-03-28 18:28       ` T.J. Mercier
2022-03-29  8:42       ` Daniel Vetter
2022-03-29  8:42         ` Daniel Vetter
2022-03-29  8:42         ` Daniel Vetter
2022-03-29 16:50         ` Tejun Heo
2022-03-29 16:50           ` Tejun Heo
2022-03-29 16:50           ` Tejun Heo
2022-03-29 17:52         ` T.J. Mercier
2022-03-29 17:52           ` T.J. Mercier
     [not found]         ` <YkLGbL5Z3HVCyVkK-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2022-03-29 17:52           ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 5/8] dmabuf: Add gpu cgroup charge transfer function T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-29 15:21   ` Michal Koutný
2022-03-29 15:21     ` Michal Koutný
2022-03-29 15:21     ` Michal Koutný
2022-04-01 18:41     ` T.J. Mercier
2022-04-01 18:41       ` T.J. Mercier
2022-04-01 18:41       ` T.J. Mercier
2022-04-05 12:12       ` Michal Koutný
2022-04-05 12:12         ` Michal Koutný
2022-04-05 12:12         ` Michal Koutný
2022-04-05 17:48         ` T.J. Mercier
2022-04-05 17:48           ` T.J. Mercier
2022-04-05 17:48           ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 6/8] binder: Add a buffer flag to relinquish ownership of fds T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 7/8] binder: use __kernel_pid_t and __kernel_uid_t for userspace T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59 ` [RFC v4 8/8] selftests: Add binder cgroup gpu memory transfer test T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier
2022-03-28  3:59   ` T.J. Mercier

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.