All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC 0/3] mm/memcontrol drm/ttm: charge ttm buffer backed by system memory
@ 2020-01-13 15:35 ` Qiang Yu
  0 siblings, 0 replies; 19+ messages in thread
From: Qiang Yu @ 2020-01-13 15:35 UTC (permalink / raw)
  To: linux-mm, cgroups, dri-devel
  Cc: Johannes Weiner, Michal Hocko, Andrew Morton, Tejun Heo,
	Christian Koenig, Huang Rui, David Airlie, Daniel Vetter,
	Kenny Ho, Qiang Yu

Buffers created by GPU driver could be huge (often several MB and even hundred
or thousand MB). Some GPU driver call drm_gem_get_pages() which uses shmem to
allocate these buffers which will charge memcg already, while some GPU driver
like amdgpu use TTM which just allocate these system memory backed buffers with
alloc_pages() so won't charge memcg currently.

Not like pure kernel memory, GPU buffer need to be mapped to user space for user
filling data and command then let GPU hardware consume these buffers. So it is
not proper to use memcg kmem by adding __GFP_ACCOUNT to alloc_pages gfp flags.

Another reason is back memory of GPU buffer may be allocated latter after the
buffer object is created, and even in other processes. So we need to record the
memcg when buffer object creation, then charge it latter when needed.

TTM will use a page pool acting as a cache for write-combine/no-cache pages.
So adding new GFP flags for alloc_pages also does not work.

Qiang Yu (3):
  mm: memcontrol: add mem_cgroup_(un)charge_drvmem
  mm: memcontrol: record driver memory statistics
  drm/ttm: support memcg for ttm_tt

 drivers/gpu/drm/ttm/ttm_bo.c         | 10 +++++
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 18 ++++++++-
 drivers/gpu/drm/ttm/ttm_tt.c         |  3 ++
 include/drm/ttm/ttm_bo_api.h         |  5 +++
 include/drm/ttm/ttm_tt.h             |  4 ++
 include/linux/memcontrol.h           | 22 +++++++++++
 mm/memcontrol.c                      | 58 ++++++++++++++++++++++++++++
 7 files changed, 119 insertions(+), 1 deletion(-)

-- 
2.17.1



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

end of thread, other threads:[~2020-01-19 13:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-13 15:35 [PATCH RFC 0/3] mm/memcontrol drm/ttm: charge ttm buffer backed by system memory Qiang Yu
2020-01-13 15:35 ` Qiang Yu
2020-01-13 15:35 ` Qiang Yu
2020-01-13 15:35 ` [PATCH RFC 1/3] mm: memcontrol: add mem_cgroup_(un)charge_drvmem Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:35 ` [PATCH RFC 2/3] mm: memcontrol: record driver memory statistics Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:35 ` [PATCH RFC 3/3] drm/ttm: support memcg for ttm_tt Qiang Yu
2020-01-13 15:35   ` Qiang Yu
2020-01-13 15:55   ` Christian König
2020-01-13 15:55     ` Christian König
2020-01-13 15:55     ` Christian König
2020-01-19  2:47     ` Qiang Yu
2020-01-19  2:47       ` Qiang Yu
2020-01-19  2:47       ` Qiang Yu
2020-01-19 13:03       ` Christian König
2020-01-19 13:03         ` Christian König
2020-01-19 13:03         ` Christian König

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.